Tag Archives: How-To

Maven code: How to detect if you have a SNAPSHOT version


May 29, 2008 By Brian Fox

I answer this question often enough that I decided to burn it to a blog so I don’t have to dig it out of the source anymore…and maybe save someone else the time along the way.

Here is the relevant code that Maven uses to determine if an artifact is a snapshot or not: Continue reading

Adding additional source folders to your Maven build


May 22, 2008 By Brian Fox

Occasionally you have a need to add additional source folders to your Maven build, usually when you are generating source via some external method or AntTask. Maven plugins that generate sources are expected to add the source folder automatically, but that’s of little consequence if your generation method is not supported by an existing Maven plugin. Fortunately, there is the build-helper-maven-plugin to assist you. The usage page gives plenty of examples. Adding an additional source folder is as simple as: Continue reading

How to override a plugin's dependency in Maven


April 23, 2008 By Brian Fox

Maven 2.0.9 introduced the ability to override a dependency used by a plugin. This is handy when you want to use a newer checkstyle, pmd, etc jar than is included by default in the plugin.

How you go about doing this actually depends on your use case because of an oversight in the Maven 4.0.0 model used by the Maven 2.0.x versions.

If you are using a plugin as a normal build plugin (as opposed to a report) then you will have it bound similar to this: Continue reading