I\'m currently migrating our build process to Maven from Ant. Our application is deployed to many different customers, each with a unique set of dependencies and and configu
"declare several execution for the war plugin to produce several artifacts (and install/deploy them)" This sounds like this might be the way forward. How would I go about doing this?
This goes a bit against a Maven golden rule (the one main artifact per module rule) but can be done. The One artifact with multiple configurations in Maven blog post describes one way to implement this approach:
I decided to put all the environment specific configuration in a special source tree, with the following structure:
+-src/ +-env/ +-dev/ +-test/ +-prod/Then I configured the maven-war-plugin to have three different executions (the default plus two extra), one for each environment, producing three different war files: beer-1.0-dev.war, beer-1.0-test.war and beer-1.0-prod.war. Each of these configurations used the standard output files from the project and then copied the content from the corresponding
src/env/directory on to the output files, enabling an override file to be placed in the correspondingsrc/env/directory. It also supported copying a full tree structure into the output directory. Thus if you for instance wanted to replace theweb.xmlin test you simply created the following directory:src/env/test/WEB-INF/and placed your test specific
web.xmlin this directory and if you wanted to override adb.propertyfile placed in the classpath root directory for the test environment you created the following directory:src/env/test/WEB-INF/classesand placed your test specific
db.propertyfile in this directory.I kept the
src/maindirectory configured for development environment. The reason for this was to be able to use the maven-jetty-plugin without any extra configuration. ConfigurationBelow you find the maven-war-plugin configuration that I used to accomplish this:
maven-war-plugin prod ${project.build.directory}/${project.build.finalName}-prod src/env/prod package-test package test ${project.build.directory}/${project.build.finalName}-test src/env/test war package-dev package dev ${project.build.directory}/${project.build.finalName}-dev src/env/dev war
(...) I can define each customer project with profiles but I don't know if there's a way to release them to a repository.
You have several options:
Or at least a way in Maven to automatically build an artifact with a specified profile from say an SVN tag.
Well, this is doable. But without more details about a particular problem, it's hard to be more precise.