Quick tip: Expressions in Maven dependency declarations

| 1 Comment

As the canonical Maven book suggests, you should use $[foo.bar.version} property expressions when you have multiple, related artifacts with the same version. Then you are able to upgrade all the dependencies consistently with minimal effort.

The NetBeans IDE 6.7 supports this pattern in the Add Dependency dialog. You can invoke that dialog from the Add Dependency action on project's Libraries node in Projects view, or from the pom.xml editor via Insert Code (Alt-Insert) editor action.
The Version field completion includes all *.version properties defined in the project (or any of the parent) and offers them as expressions in form ${*.properties}

That way you can keep your dependencies in sync right from the NetBeans UI.

In future 6.8, we also replace the GroupId and Version values with ${project.groupId} and ${project.version} if both the groupid and version match those of the current project. Again, a practise suggested by the Maven book.

1 Comment

Great tip! It is great to see tighter integration between NetBeans and Maven. Keep up the good work.

About this Entry

This page contains a single entry by mkleint published on July 10, 2009 10:21 AM.

Maven, NetBeans platform, JavaRebel was the previous entry in this blog.

Few notes on using maven projects at kenai.com is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.