Search code examples
javaweb-applicationsmaven-2build-processpom.xml

Maven - Include Different Files at Build Time


I have ten WAR files, all of which have nearly identical code and markup. The only differences lie in the images, CSS and Messages. I hit on the concept of Profiles but I haven't quite groked it yet and I'm not sure if this can handle what I need it to do.

Basically, I want a base project with different profiles for the 10 different WARs. Whenever a build is started with a given profile, it goes to a repository (either local or my organization's) and retrieves the CSS, images and messages files and places them in the correct spot before finishing out the process. I can't imagine this is much different than going out and retrieving a JAR file and putting it in WEB-INF lib.

I'm sure this isn't TOO far out in left field and I want to stick to Maven's sweet spot as much as possible. Any help would be appreciated!


Solution

  • If you want to keep each of the projects separate, you can give each project its own pom.xml. In each child project pom, add a dependency for the parent project. This will cause the build to do an "overlay" in which files from the child project are added to (or overwrite files in the) parent project. Example dependency for child project:

    <dependency>
       <groupId>com.example.app</groupId>
       <artifactId>example</artifactId>
       <version>1.0.0</version>
       <type>war</type>
    </dependency>