Red Hat

Seam published to Maven

Posted by Pete Muir    |    Sep 24, 2007    |    Tagged as Seam

Those of you who keep up with Seam CVS will have noticed a lot of changes recently to the build system. I'm going to give a brief tour of them here, and discuss how they affect you when you use Seam.

Maven

We chose to use Maven to manage Seam dependencies as it offers reasonable support for transitive dependencies, it's emerging as the de-facto standard both in the Java Enterprise world and at JBoss.org, tools like Ant (using Maven Ant Tasks) and Ivy can consume Maven POMs and the 40 odd votes for publishing Seam to Maven pushed us somewhat ;)

Using Seam with Maven

For those Maven pro's among you, here's the essential information to get you started. If you are considering dabbling with Maven, then you might want to wait for a couple of weeks for Seam 2.0.0.GA which will include a brief tutorial on using Maven with Seam.

To checkout the support you'll need to add http://snapshots.jboss.org/maven2 as a snapshot repository to your POM; having done this, you can add Seam to your projects POM:

<dependency>
  <groupId>org.jboss.seam</groupId>
  <artifactId>jboss-seam</artifactId>
</dependency>
<dependency>
  <groupId>org.jboss.seam</groupId>
  <artifactId>jboss-seam-ui</artifactId>
</dependency>
<dependency>
  <groupId>org.jboss.seam</groupId>
  <artifactId>jboss-seam-pdf</artifactId>
</dependency>
<dependency>
  <groupId>org.jboss.seam</groupId>
  <artifactId>jboss-seam-remoting</artifactId>
</dependency>
<dependency>
  <groupId>org.jboss.seam</groupId>
  <artifactId>jboss-seam-ioc</artifactId>
</dependency>
<dependency>
  <groupId>org.jboss.seam</groupId>
  <artifactId>jboss-seam-ioc</artifactId>
</dependency>

We'll shortly start publishing snapshots from our continuous integration server.

As Seam is an integration framework we spend a lot of time ensuring that the integrated libraries work well, both together and with Seam. If you want to always use the recommended library versions with Seam you may want to use the Seam root POM (which just declares repositories and dependencyManagement) as your parent POM:

<parent>
  <groupId>org.jboss.seam</groupId>
  <artifactId>root</artifactId>
  <version>2.0.0.SNAPSHOT</version>
</parent>

You can then just declare your dependencies versionless in your POM:

<dependency>
  <groupId>org.jboss.seam</groupId>
  <artifactId>jboss-seam</artifactId>
</dependency>

<dependency>
  <groupId>org.jboss.seam</groupId>
  <artifactId>jboss-seam-ui</artifactId>
</dependency>

<dependency>
  <groupId>org.jbpm</groupId>
  <artifactId>jbpm-jpdl</artifactId>
</dependency>

You'll then get the SNAPSHOT of Seam core and ui and jBPM jPDL 3.2.1.

Maven/Dependency Management Roadmap

So, what else is on the cards?

  • Write some documentation!
  • Release the next version of Seam to http://repository.jboss.org
  • Improve the handling of JBoss Embedded in the build scripts
  • Alter the seamdiscs example to use Maven for dependency management
  • Provide an option to use Maven-based dependency management in seam-gen

Feedback and Troubleshooting

Whilst this is a good start there a still some bumps to iron out! I'm really hoping for strong (and fast!) feedback on this one to get it just right for the GA.

I've got a couple of questions/discussion points for you maven experts out there:

  • Is there a way to read external properties into maven? As we're using Maven Ant Tasks we can't use -Dproperty=foo and we need to be able to specify the property file relative to the POM's location.
  • Is there a nice way to provide dependency profiles without putting empty jars all over the place?
  • Is using the Seam root POM as your parent POM an acceptable alternative?

If you are following Seam CVS and are having problems building Seam:

  1. Grab the latest CVS
  2. Make sure your build.properties file /doesn't/ contain any references to version or patchlevel
  3. Run ant clean build
  4. If the build fails due to
    The <urn:maven-artifact-ant:dependencies> type doesn't support the "versionsid" attribute.
    you probably have an older version of maven-ant-tasks.jar on your classpath. Try running ant -nouserlib or update Maven Ant Tasks to 2.0.7.
  5. Report your problem on the forum!

Maven in Seam

So, how did we use Seam and Maven Ant Tasks to build Seam?

Building Seam using Maven

However good Maven is at dependency management, we're not in love with using Maven for building software (it seems slow, and incredibly restrictive) so we decided on the half-way house of using Maven Ant Tasks - which are essentially a set of ant tasks that call into Maven. With this, we can use Ant to load dependencies from Maven POM files and publish artifacts to Maven.

In CVS the Seam build uses Maven POM files to declare dependencies. These pom files are stored in /build and, using some Ant substitution filters, are copied to /classes/poms. From these poms, we can build path's (to compile Seam), fileset's (using the Maven Ant Tasks) and can use the handy version mapper (which allows you to copy a dependency fileset stripping off the version information e.g. org/jboss/seam/jboss-el/2.0.0.BETA1/jboss-el-2.0.0.BETA1.jar is copied to /jboss-el.jar).

There is more information in /build/readme.txt

Examples and Seam-gen

For now we've stuck with using ant for building and declaring the dependencies in the build.xml. To do this we copy Seam and it's dependencies (resolved using Maven) to a staging area, and then building the deployable artifacts against this directory. This has the advantage of not having to write POM's for every example (non-trivial given the lack of dependency profiles in Maven).

back to top