Maven2 first experiences
I have just started to work with Maven2. I have struggeled a bit to find all the features in this new version compared to Maven1, but I'm getting close. Maven2 is a big step up from Maven. Especially, I like the dependency management which now resolves dependencies transitively. It makes things SO much easier when using projects with lots of dependencies like Hibernate, or our own DAO projects which in turn depends on Hibernate.
The first thing I came accross in M2 that was problematic was getting the maven2 eclipse plugin to automatically add Eclipse dependencies to other projects. I discovered that the new eclipse plugin requires the use of a multiproject for this to work. Since our project structure is flat, not hierarchial like M2 recommends, I just defined a new sibling project that referenced the projects I wanted to reference each other in Eclipse and ran the m2 eclipse:eclipse command from that project. In the pom.xml of the new project;
The next thing I had to look around for was a plugin with equivalent functionality of the javaapp plugin from sourceforge. It looks like the M2 assembly plugin fits the bill quite well and extends quite a bit further. You can define abstract assembly descriptors in XML that can be reused by other projects. An assembly descriptor describes what and how "something" (like a jar, zip) should be assembled. The plugin already includes a jar-with-dependencies descriptor, which is what I need. Invoking
from any project will unpack the project's dependencies and include them in a generated jar. This jar file has the artifact name of that project concatenated with the descriptorId as file name. Neat! :)
The first thing I came accross in M2 that was problematic was getting the maven2 eclipse plugin to automatically add Eclipse dependencies to other projects. I discovered that the new eclipse plugin requires the use of a multiproject for this to work. Since our project structure is flat, not hierarchial like M2 recommends, I just defined a new sibling project that referenced the projects I wanted to reference each other in Eclipse and ran the m2 eclipse:eclipse command from that project. In the pom.xml of the new project;
4.0.0
no.intermedium.papermillqa
1.0-SNAPSHOT
app
pom
../intermedium-domain-dao
../intermedium-domain-model
../intermedium-domain-services
../intermedium-papermill-dao
../intermedium-shadowdomain-dao
../intermedium-shadowdomain-model
../ijcommons-core
../ijcommons-dbunit-ext
The next thing I had to look around for was a plugin with equivalent functionality of the javaapp plugin from sourceforge. It looks like the M2 assembly plugin fits the bill quite well and extends quite a bit further. You can define abstract assembly descriptors in XML that can be reused by other projects. An assembly descriptor describes what and how "something" (like a jar, zip) should be assembled. The plugin already includes a jar-with-dependencies descriptor, which is what I need. Invoking
m2 assembly:assembly -Dmaven.assembly.descriptorId=jar-with-dependencies
from any project will unpack the project's dependencies and include them in a generated jar. This jar file has the artifact name of that project concatenated with the descriptorId as file name. Neat! :)
