I have a module which is supposed to produce two artifacts (war's). The only difference between the two WAR's is the web.xml being used.
I did this with the help of Maven Profiles...
<parent>
<artifactId>com</artifactId>
<groupId>myProj</groupId>
<version>1.0</version>
</parent>
<groupId>myProj.module1</groupId>
<artifactId>module1</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<profiles>
<profile>
<id>module1</id>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>module1</warName>
<webXml>src\main\webapp\WEB-INF\web_module1.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>module2</id>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>module2</warName>
<webXml>src\main\webapp\WEB-INF\web_module2.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Q1: How can I call this POM from super POM so that both the Profiles are activated?
Q2: Is it possible to install both the generated artifacts in Local repository?
Thanks!
When you want to activate several profiles at the same time, you simply have to run mvn ... -Pprofile1,profile2 command.
However, in your case, this is against one main Maven convention, which states that one project = one artifact. This means that you can't create 2 WAR at the same time. If you activate both profiles, one configuration of the maven-war-plugin will be overriden by the second profile, and then, you will finally get 1 WAR, with one web.xml.
If you want to get 2 WARs, the solution are to use WAR overlay (i.e. the second war is another project that depends on war #1), or run two separate Maven commands, one per profile.
Related
All our builds add the parameter ''-DgenerateBackupPoms=false'' to the command line while releasing, which I think is kind of stupid and I want to add it to the shared parent pom.xml. But I can't figure out which plug-in it is that generates the backup poms.
I searched the Maven Release Plugin, but no luck.
Then I tried the ''versions-maven-plugin'' (that at least has the parameter), but changing it to false does not help:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
The backup poms are still generated. So how do I turn them off?
Simply add it to the properties of pom.xml:
<project>
<properties>
<generateBackupPoms>false</generateBackupPoms>
</properties>
</project>
Maven is able to generate the application.xml file for an EAR and puts the context root in it that has been defined in the EAR's pom.xml.
Is it possible to have an application.xmlgenerated that has multiple context roots?
Or is the only possible way to achieve this to write the application.xml myself and use this rather than the generated one?
Sure, use applicationXml option in goal ear of Maven ear plugin. For more information on how to use it take a look at its usage page.
Regards.
I assume you mean different context roots for different WARs inside your ear (since each web module can have exactly one context-root). In that case, you can explicilty configure your war modules inside the ear's pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9</version>
<configuration>
<modules>
<webModule>
<groupId>artifactGroupId</groupId>
<artifactId>module1</artifactId>
<contextRoot>/context-root-module1</contextRoot>
</webModule>
<webModule>
<groupId>artifactGroupId</groupId>
<artifactId>module2</artifactId>
<contextRoot>/context-root-module2</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
With Intellij < 13.1.2 we were able to locally have a exploded artifact with exploded subartifacts for development, the actual version 13.1.2 is putting out *.jar and *.war files instead of directories.
I found this workaround in their bugtracker: http://youtrack.jetbrains.com/issue/IDEA-124353
but was wondering how to achieve this for all modules, instead of having to list all of them?
Ok, I found my workaround by adding a maven profile for intellij and enabling it:
<profiles>
<profile>
<id>intellij</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<unpackTypes>war,ejb</unpackTypes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I'm trying to use the mvn scm plugin to check out the daily tag, and create an assembly from that version of the code. I configured the scm plugin and everythhing is working well, except that I can not seem to tell it to not run the unittests.
I tried:
Passing the -Dmaven.test.skip=true command line parameter
Creating a profile where the surefire plugin skips test, and list that profile in the scm configuration "profiles" section
setting the "maven.test.skip=true" as an environment variable
In all cases, when the scm plugin starts running the goals I told it to run in the configuration (see below), it also runs the unittests.
Below is the example I used to skip tests by using a profile:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.0</version>
<configuration>
<goals>install,assembly:assembly</goals>
<profiles>skiptest</profiles>
</configuration>
</plugin>
And this is the profile (I defined this in the pom.xml of the project):
<profiles>
<profile>
<id>skiptest</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
The command I use to do the checkout and bootstrap is:
mvn scm:bootstrap -DscmVersion=daily-20110427-421 -DscmVersionType=tag
I'm running mvn 2.2.1 on a Linux machine, and doing a checkout from a CVS repository. It's an existing project, I have continuous integration and tagging all up and running, I just want to check out a daily tag and create an assembly from that.
Any tips are much appreciated.
Edit: Got it to work with the answer below, but only after I upgraded to maven-scm-plugin version 1.1. Apparently, 1.0 did not propagate profiles.
Try this in the profile:
<profiles>
<profile>
<id>skiptest</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>
I have in a web application's pom file, a build profile, which does some necessary things (in my code) for qa testing.
I have this code on svn and this code is compiled in Hudson, which deploys artifacts in nexus..
Hudson has two jobs, one for qa profile (-P qa) and one for customers.
What i need is that i change in my qa profile the artifact's name during deploy phase, so that nexus has two different war files, one for qa and one for customer.
I use (after Google search) the following which looks like it does nothing in hudshon!
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<configuration>
<classifier>qa</classifier>
</configuration>
</plugin>
</plugins>
</build>
</profile>
any ideas someone?
You actually need to set the "classifier" configuration option on the plugin that's building the package that's being deployed: maven-(ear|ejb|jar|rar|war|shade)-plugin:
For instance, to build a WAR with a qa classifier, you would do the following:
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<classifier>qa</classifier>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Also, instead of setting the classifier you could set any of the following (most default to project.build.finalName, so setting that property updates many of these):
General
project.build.finalName
War Plugin
warName
Ear|Jar|Rar|Shade Plugin
finalName
EJB Plugin
jarName
One final note: I never realized this before, but looking over the documentation, it looks like the RAR plugin doesn't support the "classification" option. Shade does support the classifier concept, but does it via the "shadedClassifierName" property.