Maven repository woes easily solved

Maven 1 users might have discovered this already: the Maven 1 repository at ibiblio.org doesn’t work with Maven 1 anymore. Some network setting at the ibiblio server was changed, which causes a redirect that the httpclient library used by Maven 1 doesn’t know how to follow, and fails.

Fortunately the fix is easy: put the following setting in your build.properties in your home directory (C:\Documents and Settings\[username]):

maven.repo.remote=http://repo1.maven.org/maven

and you’re back in business.

Updating your maven2 plugins to new releases

Whilst building our final release, I wanted to upgrade the maven assembly plugin because currently it always appends -bin to the distribution. As our packages always include both source and binary in the same zip file, the -bin is not correct. The 2.1 version of this plugin fixes this with a setting.

The biggest challenge is finding out how to update your maven plugins, without having to specify the version in your pom. As you may notice, I have scourged the maven documentation site and wasn’t able to find it within 5 minutes. So to save you the trouble of having to go through this yourself, here’s how you update your plugins to use the newest released versions:

mvn -U somegoal

Where you substitute the ‘somegoal’ string with a goal of your liking. The documentation doesn’t state wether the goal you supply has any relationship to the plugins that get updated. I have my new version of the assembly plugin, so I’m a happy camper again. On with releasing 1.2 final!

UPDATE OK, I’ve celebrated too early. The update also ‘fixed’ bugs in other plugins, and now my carefully constructed velocity template for our website doesn’t work anymore. AARGH.

And WORST OF ALL somehow now my Wicket homepage is called ‘Maven – Home’. WTF?

Apparently, the ‘name’ attribute of the ‘project’ tag in the site-descriptor is now actually used, where it previously wasn’t.

Maven 2 rant

I’m a big fan of maven, but now that I am trying to move the build of Wicket to Maven 2, I’m in a big world of hurt.

First of all, my customized website generation stopped working, because they wanted to move to APT. Now that is excusable, as the custom Jelly script I created for doing this is a lot more magic than the velocity template I now can use. But the stylesheet I have crafted stopped working correctly with some of the automatic generated pages. And I can’t supply my own templates for some of the reports they have. The current dependency report is much too basic in my opinion and I’d rather change it: it takes too much horizontal space.

The assembly plugin is quite promising, as long as you keep to the maven standards. I am able to create a nice packaged source+bin zip file, using the assembly descriptor. This works pretty well, until you want to do the same for a WAR file where you only want to add the direct dependencies instead of /all/ transitive dependencies:

-rw-r--r--   1 martijn  martijn   165119 Feb 12 22:20 commons-collections-2.1.jar
-rw-r--r--   1 martijn  martijn   169763 Feb 12 22:23 commons-lang-2.0.jar
-rw-r--r--   1 martijn  martijn    38015 Jan 29 13:33 commons-logging-1.0.4.jar
-rw-r--r--   1 martijn  martijn   313898 Feb 12 22:27 dom4j-1.6.1.jar
-rw-r--r--   1 martijn  martijn   411014 Feb 12 22:28 httpunit-1.6.jar
-rw-r--r--   1 martijn  martijn  2450757 Feb 12 22:35 icu4j-2.6.1.jar
-rw-r--r--   1 martijn  martijn   181664 Feb 12 22:29 jasper-compiler-4.1.30.jar
-rw-r--r--   1 martijn  martijn    72406 Feb 12 22:34 jasper-runtime-4.1.30.jar
-rw-r--r--   1 martijn  martijn   231706 Feb 12 22:28 jaxen-1.1-beta-8.jar
-rw-r--r--   1 martijn  martijn    30479 Feb 12 22:28 jaxme-api-0.3.jar
-rw-r--r--   1 martijn  martijn   153253 Feb 12 22:29 jdom-1.0.jar
-rw-r--r--   1 martijn  martijn   699081 Feb 12 22:28 js-1.6R1.jar
-rw-r--r--   1 martijn  martijn   137835 Feb 12 22:35 jtidy-4aug2000r7-dev.jar
-rw-r--r--   1 martijn  martijn   121070 Jan 29 13:38 junit-3.8.1.jar
-rw-r--r--   1 martijn  martijn    36572 Feb 12 22:34 jwebunit-1.2.jar
-rw-r--r--   1 martijn  martijn   358085 Feb  9 22:21 log4j-1.2.12.jar
-rw-r--r--   1 martijn  martijn   105672 Feb 12 22:30 nekohtml-0.9.5.jar
-rw-r--r--   1 martijn  martijn   575351 Feb 12 22:31 org.mortbay.jetty-4.2.24.jar
-rw-r--r--   1 martijn  martijn   105883 Feb 12 22:29 pull-parser-2.jar
-rw-r--r--   1 martijn  martijn    19097 Feb 12 22:29 relaxngDatatype-20030807.jar
-rw-r--r--   1 martijn  martijn    77977 Jan 29 13:33 servlet-api-2.3.jar
-rw-r--r--   1 martijn  martijn    25863 Feb 12 22:30 stax-api-1.0.jar
-rw-r--r--   1 martijn  martijn    38025 Feb 12 22:28 tagsoup-0.9.7.jar
-rw-r--r--   1 martijn  martijn   929053 Feb 26 09:52 wicket-1.2-beta1.jar
-rw-r--r--   1 martijn  martijn   274677 Feb 26 09:53 wicket-extensions-1.2-beta1.jar
-rw-r--r--   1 martijn  martijn  3149655 Feb 12 22:37 xalan-2.6.0.jar
-rw-r--r--   1 martijn  martijn   895924 Feb 12 22:32 xerces-2.4.0.jar
-rw-r--r--   1 martijn  martijn  1010675 Feb 12 22:33 xercesImpl-2.6.2.jar
-rw-r--r--   1 martijn  martijn   109318 Feb 12 22:29 xml-apis-1.0.b2.jar
-rw-r--r--   1 martijn  martijn   124724 Feb 12 22:34 xmlParserAPIs-2.6.2.jar
-rw-r--r--   1 martijn  martijn   104102 Feb 12 22:30 xom-1.0b3.jar
-rw-r--r--   1 martijn  martijn    93395 Feb 12 22:29 xpp3-1.1.3.3.jar
-rw-r--r--   1 martijn  martijn   246365 Feb 12 22:34 xsdlib-20030807.jar

How many xml dependencies can you discover here?

The old way of annotating a dependency to be included in your WAR archive was much easier than the soup I’m in now. I have to tag all my dependencies as compile scope, and then exclude the ones I don’t need.

I know it is hard for projects to write documentation when you have so much coding to do. Heck, even Wicket is a victim of the too many programmers, too few writers syndrome. I have a lot of respect for what the maven guys have accomplished in documenting so far, but it is still too scattered, too little and confusing. The user mailinglist of maven is such high traffic, my google mail can’t even keep up.

In the very least make sure the documentation doesn’t contain errors. I had a blast figuring out why the changes plugin (now part of codehaus, instead of the default maven distro?) didn’t want to execute. Turns out that the documentation tells you to add a dependency on the SNAPSHOT version of the plugin, instead of the final (i.e. BETA) version of the plugin. Fortunately I have about 100000 user mailinglist messages in my google mail account, so googling on the error showed a message from several weeks ago that the SNAPSHOT string had to be removed.

Even the pom.xml hasn’t been documented properly, and this is the most fundamental artifact of a maven project. I see a lot of concepts there that don’t have an explanation anywhere. execution, modules?

The maven team has created a bohemoth to maintain, and I pity them for that. There was a lot of work to be done, but I think the move to maven 2 was too soon and too drastic. The complexity they have added to a build system may be necessary but then I think very good and complete documentation is also necessary.

Maven gems: Check those Wicked Dependencies

While building the final 1.0 release for Wicket I needed to see whether all projects use the same version of the Wicket libraries. Using the Maven multiproject plugin I am able to quickly see whether the projects are using the same version of each library.

First you need to check out the projects you want to check into the same workspace:

wicket/
wicket-extensions/
wicket-examples/
wicket-contrib-data/
wicket-contrib-hibernate2/
wicket-contrib-hibernate3/

Then create in the root directory of the workspace two files: project.xml and project.properties. The project.xml file contains the following:


    
        maven-multiproject-plugin
    

Note that this is not a complete, nor a valid project.xml for serious development using maven.

The project.properties file contains the following properties:

maven.multiproject.basedir=.
maven.multiproject.includes=*/project.xml

Now all you need to do is to run:

maven site

in the workspace root folder where you saved the two Maven project files. The resulting report can then be found in the subdirectory: target/docs/dependency-convergence-report.html.

This is one of the gems why I really like Maven as a project management tool.

Technorati Tags: , ,

Getting Maven 2 to work

In my previous post, I mentioned that I was going to run maven 2, continuum, fedora core 3, IBM JDK 1.4, etc. on an obsolete laptop (Toshiba satelite pro 4200). I use this 4 year old laptop mainly because of the following reasons:

  • I have trouble letting hardware go unused
  • Wicket needs a continuous integration machine
  • I want to test maven 2, but don’t want to do this on my own boxes, it might break stuff
  • I heard from co-workers that the IBM JDK is faster on Linux than the Sun JDK
  • I like a challenge
  • more things I can’t think of right now

After downloading the maven 2 distribution, I unzipped the archive in my home directory and chmod +x */bin/m2 made sure that the m2 script is executable. I also made sure $JAVA_HOME is set to my IBM JDK installation (for some reason in /opt :-S).

According to the maven 2 website, I can issue m2 --version in order to verify the installation:

[dashorst@localhost maven2-test]$ ~/maven-2.0-alpha-1/bin/m2 --version
Maven version: 2.0-alpha-1

So far so good… Next in the getting started guide is creating your own project:

m2 archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

Alas, this doesn’t work, as apparently, a transitive dependency cannot be resolved, as it isn’t in the ibiblio repository… It appears to be the velocity 1.4 pom (to be found in your local repository, most probably in a subdir called .m2/repository in your home directory). Removing this dependency from the velocity 1.4 pom made sure the project generation works. Now I have my first Maven 2 project!

First findings:

  • I don’t find it particularly fast, but that can be attributed to several factors: slow laptop (very likely, slow operating system (not likely), slow JDK (possibility)
  • I don’t like the fact I need to download some (unknown!) jdbc jar, or edit the velocity pom in order to pass the ‘getting started’
  • The current structure is still a blur to me, I don’t know how to run the unittests

As my experience with maven 2 will grown, this blog will be filled with more findings on this subject! Keep posted…