Free various configurations with Maven

I am currently migrating our build process to Maven from Ant. Our application is deployed for different clients, each of which has a unique set of dependencies and configurations. I can implement various profiles to simulate them and build the necessary wars from them. However, this is a process that occurs at compile time.

Each release is tagged under SVN and is also uploaded to our internal Nexus repository. I want to be able to accept a specific release and restore it based on my profile. Is there a way to do something like this? Is there anything else besides the profiles that I should use?

+1
java maven-2 build
Oct 05 2018-10-10
source share
4 answers

In the end, I did something a little different. We do not store releases in our internal repository. Instead, we build a Hudson and a project with several configurations (one configuration / profile for each client). Thus, when the release is released, Hudsonโ€™s mission is to create different wars for all customers. They are then stored on the Hudson server instead of Nexus. Creates for specific versions, and clients can be created at any time from releases in Nexus. - samblake Mar 16 '11 at 12:32

0
Oct 10
source share

"declare multiple executions for a military plug-in to create multiple artifacts (and install / deploy them)." It looks like it could be the way forward. How can i do this?

This is slightly contrary to the Maven golden rule (one main artifact per module rule), but can be done. One artifact with several configurations on the Maven blog describes one way to implement this approach:

I decided to put the whole environment of a specific configuration in a special source tree with the following structure:

+-src/ +-env/ +-dev/ +-test/ +-prod/ 

Then I set up the maven-war-plugin to have three different executions (default plus two extra), one for each environment, producing three different military files: beer-1.0-dev.war, beer-1.0-test.war and beer- 1,0-prod.war. Each of these configurations used standard output files from the project, and then copied the content from the corresponding src/env/ on directory to the output files, override the file that will be placed in the corresponding src/env/ directory. It is also supported by copying the full structure tree to the output directory. Thus, if, for example, you wanted to replace web.xml in the test, you simply created the following Directory:

 src/env/test/WEB-INF/ 

and placed your web.xml test in this directory, and if you wanted to override the db.property file, the directory of the test environment in which you created the following directory was placed in the root directory:

 src/env/test/WEB-INF/classes 

and placed your db.property test in this directory.

I saved the src/main directory configured for the Development Environment. The reason for this was to be able to use the maven-jetty-plugin without any additional configuration. Configuration

Below you will find the maven-war configuration plugin that I used to do the following:

 <plugin> <artifactId>maven-war-plugin</artifactId> <configuration> <classifier>prod</classifier> <webappDirectory>${project.build.directory}/${project.build.finalName}-prod</webappDirectory> <webResources> <resource> <directory>src/env/prod</directory> </resource> </webResources> </configuration> <executions> <execution> <id>package-test</id> <phase>package</phase> <configuration> <classifier>test</classifier> <webappDirectory>${project.build.directory}/${project.build.finalName}-test</webappDirectory> <webResources> <resource> <directory>src/env/test</directory> </resource> </webResources> </configuration> <goals> <goal>war</goal> </goals> </execution> <execution> <id>package-dev</id> <phase>package</phase> <configuration> <classifier>dev</classifier> <webappDirectory>${project.build.directory}/${project.build.finalName}-dev</webappDirectory> <webResources> <resource> <directory>src/env/dev</directory> </resource> </webResources> </configuration> <goals> <goal>war</goal> </goals> </execution> </executions> </plugin> 



(...) I can define each client project with profiles, but I do not know if there is a way to release them to the repository.

You have several options:

  • use profiles and run the assembly several times (create artifacts using the classifier and install / deploy them).
  • declare multiple executions for a military plug-in to create multiple artifacts (and install / deploy them)
  • use different modules (and possibly military overlays to combine a common part with a specific one)

Or at least a way in Maven to automatically build an artifact with a specified profile, for example, using the SVN tag.

Well, thatโ€™s doable. But, in no more detail about a particular problem, it is difficult to be more precise.

+2
Oct 06 '10 at 7:08
source share

I would take a look at your architecture and see if there is a way to split a project into several projects. One of them will be the main code base. Other projects will depend on the JAR file created by the main project and add dependencies, etc. to their own configuration. To create your final artifact.

This will allow you to use client-specific code independently of each other, as well as maintain common code in one place and separate from the clientโ€™s specific things.

+1
05 Oct 2018-10-10
source share

Have you looked at the Maven build plugin ?

This plugin allows you to customize how your distribution is built, i.e. what format ( .tar.gz , .zip , etc.), directory structure, etc. I think you should be able to associate several instances of the plugin with package in order to collect several options for your output (for example, packaging for client 1, customer2, etc. separately).

The deployment plugin should automatically handle the deployment of each of the collected packages in the target directory in the repository.

0
05 Oct '10 at 19:53
source share



All Articles