Friday, April 27, 2007

Artifactory 1.2.1-rc1 released

Today I changed my Artifactory maven-prox version from 1.2.1-rc0 tp 1.2.1-rc1. Just copy the bin, lib, webapp and artifactory.jar to your existing artifactory application and overwrite it. Then restart your proxy and everything just should work right. To get the actual release-notes please check out the following link.

From Maven


From Maven

Take care

Continuum vs. Derby and how to...

... stop an invoked build on the build-server (Continuum) which seems to run in an endless loop. Yesterday, it was the first time we had a problem with one of our projects on the build-server. After a three hour build one of our core-developer came over to my place and told me to stop the project on Continuum because some of our India-colleagues checked in some bad code which caused an endless loop on the database-side of the application.

So how am I able to stop a running project on Continuum? After a ten minutes search on the web-interface of the build-server my second thought was to restart Continuum but despite of the restart the project still kept building so Continuum some how remebers the state of the project's build. *confused* The next thing I did was to find some threads on Nabble.com of developers who maybe already had the same problem as we had and finally I did.

So, after I have finished reading those threads it was clear that I had to handle this problem by manipulating Continuum's database (Derby). So how am I able to do this when the build-server is on a different machine and I'm not allowed to install any oder software on this machine.

I rememberd the fact that NetBeans had it's cool integrated database-ui, by the way this IDE has also integrated support for Derby-databases, so I tried to connect to my Continuum-database by using NetBeans. First I had to stop Continuum or NetBeans would not allow me to connect to the database. After I had stopped the build-server it finally was possible to connect to the Derby-database over NetBeans. So it was possible to connect with the following connection-string: jdbc:derby :\\server\D$\path\to\derby


But then I had the problem that I didn't know which schema I should use to connect to so I tried out every of it. Another problem was that I couldn't see the tables of the database schema so I had to guess the name of the table. In one of the threads there was a sample select-statement but this was only to change the role of an user.

From Maven

So after a while of studiing those threads I found a log-file and saw that Continuum creates all tables on start up and in this log-output I found some tables and one of it was the PROJECT-table and after a 'select * from SA.PROJECT' I saw all installed projects. A second table was the BUILDRESULT-table. The last entry in this table was the project which caused the problem. So I decided to delete this entry.

From Maven

After restarting Continuum the project wasn't building anymore and then I invoked a 'Build All' and today everything was fine. There is one thing I'd like to mention, in one of a thread that I didn't post was a suggestions to invoke a 'Build All' as solution to stop a project but an answer to this post was that this doesn't work so I'm not sure if my decision to delete the entry from the table was the right solution or the that I invoked the 'Build All'-command over the web-interface of Continuum.

But everything works fine now and maybe this may help you or will give you some ideas if you also run in such kind of problems with the Continuum build-server.

Cheers

Wednesday, April 25, 2007

Maven & Co

Today, I decided to set up myself a reference-environtment with the following technologies and how you have to configure this tools that they work properly together. The following list shows all technologies and their versions I've used to set up this environment:

Reference-Project Bookstore

My plan is to develop an online bookstore just to show how maven works with a small web-app which consists of some submodules. In this first post I'd like to show only the build-configuration settings for this web-app. First I created a file structure where to store all my tools, projects and their settings. I created the following folders:

  • Continuum (my Build-Server)
  • Locals (my local maven-repository)
  • Projects (all my projects)
  • Proxies (all maven-proxies => e.g. Artifactory)
  • SVN (my Suversion-Repository)

The following picture shows the file-structure. I haven't collapse all folders because those are just some configuration-specific folders of the tools.

From Maven

All folders marked green are ander Subversion source-control. After I created this structure I had to create a subversion-repository. You just have to invoke the command 'svnadmin create path/to/your/custom/folder' and then import your structure with 'svn import /path/to/repo/ -m "some message"'. Then you have to checkout the project for the first time with 'svn checkout /path/to/repo'.


If everything works fine you can now set up you Continuum build-server to interact with your subversion-repo. This server will execute a specific maven commands (which you will be able to configure) to a certain time (cron job syntax) so you always will haven an overview of the checked in sources and if the application is clean.


There is one custom configuration you have to do if you would like to use the file-protocoll when you would like to set the path to your project's pom-file. By default the file-protocoll is turned off but you can turn it on by setting the 'allowedScheme'file'allowedScheme' in the application.xml of continuum which you will find in the CONTINUUM_HOME\apps\continuum\conf folder.

From Maven


After changing this property everything should work fine. Now you will be able to set up a maven-proxy which enables you to share your application and other artefacts with more developer.

From Maven

Artifactory is really easy to configure but I'm still a bit confused about some settings. I'm going to write about it in upcoming posts. There is only one thing, if you are behind a proxy you have to configure it in the artifactory.config.xml which you can find in the etc-folder of your Artifactory-installation. The following screenshots show some interesting maven-settings about the scm-Tag (Subversion) and the distributionManagement-Tag which configures the path to the snapshot-repository where you can deploy your snapshot-releases to the Artifactory repositories.



From Maven


From Maven

The last thing is to install a webserver where you can deploy your project-site. I have installed Xampp for this kind of purpose. You just have to confiugre your site-tag within your distributionManagement-Tag and then after invoking the mvn site:site site:deploy command your complete project-site will be generated and transfered to your configured path.

So now you have set up a good infrastructure to develop your application and can concentrate on your application logic. In upoming posts I will begin to design my bookstore-application and try to solve the remaining build-configuration-issues
.

Of course you're welcome to descripe your best-practices with this kind of technologies and I also would like to mention the fact that this is not a complete description but should give you an idea on how to set up a possible way for a building-environment for a Java-based web-application.

Cheers

Tuesday, April 24, 2007

Archivia doesn't work either

In my last post I tried to find a solution to learn maven to skip external, public repositories e.g. Ibiblio/repo1 if I invoke any maven-commands and only check the local and the internal maven-proxy. First I thought Archiva was the solution for my problem but I was wrong. Archiva will also behave like Mave-Proxy if I configure any remote repositories over Archivia's web-interface.

So, I kept researching and after a while I found another maven-proxy called Artifactory. As I read the description I recognized the fact that Artifactory is a complete rewrite of the old Maven-Proxy with many new features. For a detailed overview please check out Artifactory's official website.

So, filled with new hope I installed Artifactory and after a few configuration-troubles maven and this new proxy worked fine, but to my regret the feature I would like have also didn't work so I decided to write a mail to Artifactory's lead-developer and hope he will have a solution for my problem.

In spite of everything I would like to mention the cool Ajax-based feature of Artifactory's repository-browser and pom-preview. The following picutres shows the login, the browser, a right click on a pom-file and the preview.


From Maven


From Maven


From Maven


From Maven


I also found a thread on Nabble where two workarounds are described but both of them didn't work with my environment. So please, if you have any ideas let me know! *help*


Cheers

Friday, April 20, 2007

Maven 2 featuring Archiva

The last days I spent some time on finding a solution to help the developers at my office, to get their build process faster. All the developers (still) use Maven 2.0.4 as their build-tool and Maven-Proxy as their internal office repository. But what is the concrete problem now. So far everything sounds pretty easy to understand and you might aks yourself why there are any problems. If you have already some experience on how to use Maven in combination with an internal Maven-poxy for your build process then you know of course how maven's build lifecycle works. If not please check out the description on the maven's main homepage.

But what is the problem? Everytime a developer invokes some maven commands, maven checks if there are any new versions of the used artefacts. First maven checks the local, then the internal proxy and then all of the configured external repositories. But how can you configure maven only to check the local and internal maven-proxy and to skip all the external check? So I decided to configure a local configuration of the same environment we use at work with a little difference: I use maven 2.0.6 and the Archivia proxy.

I configured my old local ./m2 repository which I used with maven 2.0.4 at work as my internal (but don't muddle up the local repository with the internal one) repository and created a new local repository on my C drive which i called "M2_Local". So if you are a bit confused now have a look at the following drawing.

From Maven


By the way you can configure all these changes in the settings.xml of your Maven installation. I will explain this changes more in detail later in this post. If you set up your Archivia-proxy successfully then you will be able to add some repositories which should be monitored by the server.


From Maven

Now, back to the actual problem. So, if a developer invokes e.g. a mvn install then Maven checks every artefact if there is a new version somewhere on the web. But what if the developer knows that there aren't any updates and just would like Maven only to use the internal office-proxy. Of course I know the -o (offline-mode) option for Maven but this also will skip the internal proxy. Why should a developer want to skip the external repositories anyway?

If you have a very huge business module which is devided in many, many submodules and e.g. the Maven core-developer do some restructering work on the public repositories at same time as you work, then it's possible that even a simple mvn clean command can take very, very long (~20 min) because the online-checks of Maven are extremly slow. So what can we do something to stop Maven doing this online-update-checks?

My first idea was to configure the maven-proxy (in my case Archivia) also as external repository in the settings.xml. You just have to set the id of one repository to 'central'. Now Maven won't check other external repositories except the configured one.


From Maven


So if your project needs some artefacts which aren't already in your local or internal proxy repository, the build will fail because Maven doesn't check the public repositories e.g. repo1 or Ibiblio. Here you can see the BUILD FAILURE and the configured remote repositories.

From Maven

If you would like to receive updates again, just uncomment the 'central' configuration or rename the id to any other name than 'central'. In fact this is the bahaviour I'd like to have. The problem is, that the maven-proxy (Maven-Proxy not Archivia) will still check the remote repositories for updates. I think that's because you can set this configuration in some property file of the Proxy. The following code-snipped is from the Maven 2.0.4 which we use at work:

From Maven

As you can see, the id 'central' has also been set but Maven still checks the public repositories. *confused* The following picture shows that indeed Maven checks the internal maven-proxy but stills receives data from repo1 or Ibiblio.

From Maven

I also checked if there isn't the artifact I'd like to receive on any public server by changing the version number of the artefact to an ivalid one. Maven prints out the following set up remote repositories:


From Maven

So it must be a Mave-Proxy specifig configuration. I don't have a better explanation but I'll keep on researching that problem. Maybe also Archivia will behave like this if I set up remote repositories over the Archivia's web-interface.

But I will write more about my experiences and if I have found a solution in later posts. Maybe there is a simple Maven-setting for this problem which I haven't found yet. You are welcome to post some better solution for this problem.

Cheers