- Wicket's Date & Time Components and Client-Server Timezones
- Some useful Java System Properties while starting JVM.
- Jbossws 2.0.1 with JDK 1.6
- Date & Time selection made simple in Wicket
- New Features in Vim 7
- Maven best practices: Use dependency management for multi module projects.
- Prototyping LAMP with WAMP
- Bash shell tricks
Do you struggle to maintain a common configuration for dependencies (version #, type etc.), between various modules of your multi-module maven 2.x project ? There is a very easy way to control all your dependency related configurations from the parent 'pom' project. What ever configurations are done in the 'dependencyManagement' section of the parent pom.xml,
are automatically inherited by the child projects. Just think about it for a second, a clear simple way to have the same version of log4j jars in all your sub modules, Here's a code sniplet of 'dependencyManagement' block in one of my parent pom.xml <project....>
......
<packaging>pom</packaging>
............
<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons.logging.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>logkit</groupId>
<artifactId>logkit</artifactId>
</exclusion>
<exclusion>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
..........
</dependencies>
</dependencyManagement>
<properties>
<commons.logging.version>1.1</commons.logging.version>
</properties>
</project>As you can see, I have 2 things here, I have specified a default version that all subsequent children projects will inherit, and I have also specified a bunch of transitive dependencies that I want to exclude from this dependency. Now all a child project needs to do is <project ....>
···<packaging>pom</packaging>
···<dependencies>
··· <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
······</dependency>
···.....
···</dependencies>
</project>Everything else is inherited from the parent, and when commons-logging is out with a new version, that I need to use I need to change the version # in just one place.<?P> WARNING Beware that any dependency specified in 'dependencyManagement' section is not an
actual dependency on either the parent project nor the child project, unless it is explicitly specified as one, in the regular
'dependencies' block. Another thing to keep in mind, is that many IDEs that have the ability to work with maven projects (Eclipse, Netbeans etc),
might not give you this functionality of managing dependencies from 'dependencyManagement' block
, so you may have to do this part by hand. Hope you have found this little piece of information helpful. |
|||
Good information
Very well described. Any more tips???