Maven - pom file - Artifact not being created - maven

I have a pom file that is triggered by jenkins and is being used twice, every time on a different machine(docker container) with different compilers(to be built for different linux distributions).
In order to get those 2 different builds as artifacts, and with different names, I'm trying to use profiles and set the classifier of the artifact with different values.
It seems though that the artifacts are not being created for some reason, and I don't know why.
I'm not sure I configured the profiles correctly and I also have the 'attach-to-artifact' in an execution block of its own and I don't know if it's right.
Any help would be much appreciated.
my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>XXXX</groupId>
<artifactId>XXXXX</artifactId>
<version>1-SNAPSHOT</version>
</parent>
<groupId>XXXXX</groupId>
<artifactId>XXXXXXX</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<scm>
<developerConnection>scm:git:ssh://XXXXXX</developerConnection>
</scm>
<properties>
<revision>1.0.0-1-SNAPSHOT</revision>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>build</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec executable="sh" failonerror="true">
<arg line="build.sh"/>
</exec>
</target>
</configuration>
</execution>
<execution>
<id>prepare-test-package</id>
<phase>prepare-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${env.ESX_COMPILATION}</skip>
<target>
<exec executable="sh" failonerror="true">
<arg line="tests.sh"/>
</exec>
<attachartifact file="${project.build.directory}/archive.tar.gz" type="tar.gz"/>
</target>
</configuration>
</execution>
<execution>
<id>attach-to-artifact</id>
<phase>attach-artifact</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<classifier>${envClassifier}</classifier>
<target>
<attachartifact file="${project.build.directory}/archive.tar.gz" type="tar.gz"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>esx</id>
<activation>
<property>
<name>env.ESX_COMPILATION</name>
<value>true</value>
</property>
</activation>
<properties>
<envClassifier>esx</envClassifier>
</properties>
</profile>
<profile>
<id>linux</id>
<activation>
<property>
<name>env.ESX_COMPILATION</name>
<value>false</value>
</property>
</activation>
<properties>
<envClassifier>linux</envClassifier>
</properties>
</profile>
</profiles>
As can be seen I'm using the 'env.ESX_COMPILATION' variable to set the profile choice which sets the 'envClassifier' variable and in the final execution block, under and before i set the 'classifier'. and inside target i call 'attachtoartifact'
What am I doing wrong here?
Any help is much appreciated!
Thanks!

Related

maven - build once to generate separate war files for separate environment

My pom.xml -
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test-application</artifactId>
<packaging>war</packaging>
<version>0.2.0</version>
<profiles>
<profile>
<id>local</id>
<activation>
<property>
<name>envType</name>
<value>local</value>
</property>
</activation>
<properties>
<envType>local</envType>
</properties>
</profile>
<profile>
<id>local2</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<envType>local2</envType>
</properties>
</profile>
<profile>
<id>dev</id>
<activation>
<property>
<name>envType</name>
<value>dev</value>
</property>
</activation>
<properties>
<envType>dev</envType>
</properties>
</profile>
<profile>
<id>sit</id>
<activation>
<property>
<name>envType</name>
<value>sit</value>
</property>
</activation>
<properties>
<envType>sit</envType>
</properties>
</profile>
<profile>
<id>uat</id>
<activation>
<property>
<name>envType</name>
<value>uat</value>
</property>
</activation>
<properties>
<envType>uat</envType>
</properties>
</profile>
</profiles>
<build>
<finalName>my-application</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v6.10.0</nodeVersion>
<npmVersion>3.10.10</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>gulp build</id>
<goals>
<goal>gulp</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>optimize --env ${envType}</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Front end maven plugin installs node, all required npm and bower packages and initiates the gulp task for optimizing all the front end code. Gulp places all the front end code into the below -
/src/main/webapp/index.html
/src/main/webapp/js/
etc
web.xml is at -
/src/main/webapp/WEB-INF/web.xml
Command to build the war package for local,SIT,DEV, etc environment -
mvn clean install -DenvType=local
mvn clean install -DenvType=sit
mvn clean install -DenvType=uat
This builds the war file - my-application.war in /target directory.
I need to run the maven command separately each time in order to build the war package for each environment. (because the front-end code uses separate environment variables for each environment).
How can I change the build process so that I need to build only once and maven takes care of running the gulp tasks for each environment (gulp optimize --env ${envType}) one after the other and produces separate war files in the target directory -
my-application-local.war
my-application-sit.war
my-application-uat.war
etc
I need maven to run the gulp task in sequence. I can make each run of gulp to output the front-end code to separate directories. The maven should pick from these separate directories and create separate war files. Not sure whether this is the right approach. Please let me know on this.

Integrate create-react-app into maven build process

I am trying to integrate a recently created ReactJs application into the build process of the rest of my larger maven based application. I have done this in the past for an AngularJs application using npm, Gulp, and Bower. The difference this time around is that I am using Yarn but also the create-react-app base application from Facebook which relies on the 'react-scripts' development dependencies.
Previously my pom.xml for the maven project that built the AngularJs app looked as so:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<name>MyApp Service</name>
<description>MyApp Service</description>
<parent>
...
</parent>
<profiles>
<profile>
<id>exec-unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<npmexec>npm</npmexec>
<gulpexec>gulp</gulpexec>
<bowerexec>bower</bowerexec>
</properties>
</profile>
</profiles>
<properties>
<frontendDir>src/main/myappui</frontendDir>
</properties>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>npm install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>${npmexec}</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>${frontendDir}</workingDirectory>
</configuration>
</execution>
<execution>
<id>bower install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>${bowerexec}</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>${frontendDir}</workingDirectory>
</configuration>
</execution>
<execution>
<id>gulp build</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>${gulpexec}</executable>
<arguments>
<argument>prepare-for-maven-war</argument>
</arguments>
<workingDirectory>${frontendDir}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I am not particularly sure what to do about the 'react-scripts' part. I tried adding <yarnexec>yarn</yarnexec> with an execution for yarn install and yarn build but it didn't provide desired results.

optimizing maven build performance

I have a Maven web application. This is taking too much time to build(30-40 mins).I would like to reduce it to less than 10 mins. My pom.xml is as below.
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>se.mysite.etc.settings</groupId>
<artifactId>projects</artifactId>
<version>1.5</version>
</parent>
<groupId>se.myweb.portal</groupId>
<artifactId>myweb-se-main</artifactId>
<name>myweb-se-main</name>
<version>3.1.81-B2_forv-SNAPSHOT</version>
<packaging>pom</packaging>
<inceptionYear>2009</inceptionYear>
<properties>
<release.version>${project.version}</release.version>
<acc.version>2.3.42-TEST-MAINT-SNAPSHOT</acc.version>
<cxf.version>2.5.3</cxf.version>
<spring.version>3.0.3.RELEASE</spring.version>
<spring.security.version>2.0.4</spring.security.version>
<spring.webflow.version>2.1.1.RELEASE</spring.webflow.version>
<commonportal.version>1.9.9-SPRING3</commonportal.version>
<junit.version>4.5</junit.version>
<java.source.version>1.6</java.source.version>
<cobertura.maxmem>1024M</cobertura.maxmem>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<scm>
<connection>scm:hg:http://test1/myweb</connection>
<developerConnection>scm:hg:http://test1/myweb</developerConnection>
<tag/>
<url>http://test1/myweb</url>
</scm>
<profiles>
<profile>
<id>dev</id>
<dependencies>
<!--some dependencies-->
</dependencies>
<modules>
<module>../project1</module>
<module>../project2</module>
<module>../project3</module>
<module>../project4</module>
</modules>
</profile>
<profile>
<id>dist</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<!--some dependencies-->
</dependencies>
<modules>
<module>../project1</module>
<module>../project2</module>
<module>../project3</module>
<module>../project4</module>
<module>../project5</module>
<module>../project6</module>
</modules>
</profile>
<profile>
<id>backend</id>
<dependencies>
<!--some dependencies-->
<modules>
<module>../project3</module>
<module>../project1</module>
<module>../project2</module>
<module>../project4</module>
<module>../project9</module>
</modules>
</profile>
<profile>
<id>frontend</id>
<!--some dependencies-->
<modules>
<module>../project10</module>
<module>../project11</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<forkMode>always</forkMode>
<argLine>-Xms512m -Xmx2048m -XX:MaxPermSize=2048m</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>webtest</id>
<build>
<finalName>myweb-web-test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-XX:MaxPermSize=512m</argLine>
</configuration>
</plugin>
</plugins>
</build>
<!--some dependencies-->
<modules>
<module>../myweb-web-test</module>
</modules>
</profile>
<profile>
<id>redeploy_web_app</id>
<activation>
<property>
<name>redeployWebApp</name>
</property>
</activation>
<properties>
<user.tomcat.home>${env.DEST_DIR}</user.tomcat.home>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<dependencies>
<!--some dependencies-->
</dependencies>
<executions>
<execution>
<id>delete_project_artifact</id>
<phase>prepare-package</phase>
<configuration>
<tasks>
<taskdef classpathref="maven.plugin.classpath" resource="net/sf/antcontrib/antcontrib.properties"/>
<if>
<equals arg1="${project.packaging}" arg2="war"/>
<then>
<echo message="Removing ${project.artifactId}.${project.packaging} from ${user.tomcat.home}/webapps"/>
<delete dir="${user.tomcat.home}/webapps/${project.artifactId}"/>
<delete file="${user.tomcat.home}/webapps/${project.artifactId}.${project.packaging}"/>
</then>
</if>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>copy_project_artifact</id>
<phase>package</phase>
<configuration>
<tasks>
<taskdef classpathref="maven.plugin.classpath" resource="net/sf/antcontrib/antcontrib.properties"/>
<if>
<equals arg1="${project.packaging}" arg2="war"/>
<then>
<echo message="Copying ${project.build.finalName}.${project.packaging}"/>
<copy file="${project.build.directory}/${project.build.finalName}.${project.packaging}" overwrite="true" tofile="${user.tomcat.home}/webapps/${project.artifactId}.${project.packaging}"/>
</then>
</if>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<!-- General dependencies -->
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<instrumentation>
<excludes>
<exclude>se.mysite/**/Test*.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- TODO: Use UTF-8 here or not??? -->
<encoding>UTF-8</encoding>
<!-- encoding>ISO-8859-1</encoding-->
<source>${java.source.version}</source>
<target>${java.source.version}</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<scmCommentPrefix>II Release:</scmCommentPrefix>
</configuration>
</plugin>
</plugins>
</build>
<organization>
<name>mysite AB</name>
<url>http://www.mysite.se</url>
</organization>
</project>
My compile command is below.
mvn -U -DartifactsTarget=$DEST_DIR/lib/tpp -P dev -Dmaven.test.failure.ignore=true -Dtesting.testsToExclude=**/Test*.java -f pom.xml $* -DredeployWebApp install
It is taking almost 30 mins to build.
I am using maven 3.0.4. I explored that using the following options we can optimize the build time.
Using maven parallel processing
Using plexus compiler plugin
Using maven power shell
Please let me know if I need to any other changes to my pom.xml or any other techniques that would optimize the performance.
Optimizing the Maven build of a Java project comes down to 3 factors:
Compilation and Tests
Complexity of the Maven build
Optimizing the Maven (binary) performance
Compilation and Tests
If, for example, you have GWT in your application and you're compiling for 20 different permutations then this will be a problem if you're doing this the whole time.
There are ways to get around this by maybe only doing the full build when you need to, and otherwise limiting the build by using the draftCompile or optimizationLevel options.
The same thing applies to your tests: if you have hundreds of tests, the length of time that each test takes starts to become significant. Common ways to increase performance in tests are:
Don't use Thread.sleep(..), use mutex's and locks.
Share configuration (persistence units, mocks) across multiple tests instead of doing the setup per test.
Make it a unit test instead of an integration test, unless you really need to. Too many integration tests is a bad code smell, in any case.
Complexity of the Maven Build
If you have 10's or hundreds of modules, with a complex dependency tree, maven will need time to calculate the dependency tree. Use `dependency:analyze' to figure out whether or not there are unused dependencies and remove them.
Also, the number of plugins used in each module's build will increase the build time.
Optimizing Maven (binary) performance
I use the following options:
export MAVEN_OPTS="-Dmaven.wagon.provider.http=httpclient -Dmaven.artifact.threads=12 -Dhttp.tcp.nodelay=false -Xmx2048M -Xss256M -XX:+CMSClassUnloadingEnabled -XX:-UseGCOverheadLimit -XX:MaxPermSize=256M -T2C"
-Dmaven.wagon.provider.http=httpclient:
Changes the http connection mechanism, my theory is that the Apache HttpClient library is faster and better than the default Java HttpURLConnection class
-Dmaven.artifact.threads=12:
The number of threads used to download artifacts.
-Dhttp.tcp.nodelay=false:
Turns off Nagle's algorithm increasing performance (but also bandwidth used). This is a Wagon property.
-T2C: This was an expiremental build introduced in maven 3: the number of threads per build. See Parallel builds in Maven 3
Please feel to edit this post if you have other tips!

Maven profile not activated, though property has correct value

I am trying to set-up conditional plugin execution via profiles. The idea is to have a compress/no compress HTML files:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net</groupId>
<artifactId>mavenconditionalexecution</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Maven Conditional Execution</name>
<properties>
<DoCompress>true</DoCompress>
</properties>
<build>
<plugins>
<!-- Clean-up -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>clean</phase>
<configuration>
<target>
<echo message="DoCompress: ${DoCompress}"/>
<delete includeemptydirs="true">
<fileset dir="${basedir}/src/main/webapp/result/" includes="**/*"/>
</delete>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/src/main/webapp/html</directory>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>With Compression</id>
<activation>
<property>
<name>DoCompress</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.tunyk.mvn.plugins.htmlcompressor</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>html</goal>
</goals>
</execution>
</executions>
<configuration>
<goalPrefix>htmlcompressor</goalPrefix>
<srcFolder>${basedir}/src/main/webapp/html</srcFolder>
<targetFolder>${basedir}/src/main/webapp/result/html</targetFolder>
<removeIntertagSpaces>true</removeIntertagSpaces>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Without Compression</id>
<activation>
<property>
<name>DoCompress</name>
<value>false</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<echo message="Copying file"/>
<copy todir="${basedir}/src/main/webapp/result/">
<fileset dir="${basedir}/src/main/webapp/html/" >
<include name="angle.html"/>
</fileset>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.tunyk.mvn.plugins.htmlcompressor</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
It does not matter what value I assign to the DoCompress property, the corresponding profile are not executed. I check the value of the property with an echo. Why? What am I doing wrong?
Is it allowed to activate multiple profiles in a pom.xml using property values?
UPDATE
I have created an incident: I have created an incident: https://jira.codehaus.org/browse/MNG-5235.
If anyone has an operational example of maven profile activation by properties, I am interested. Moreover, does anyone know whether multiple profiles can be activated in the same run via properties? The documentation is not clear about it.
After opening an issue, it turns out this is not a bug, because properties in the section can only be system properties, not properties defined in the pom.xml itself.

Maven Wagon plugin: Can wagon:upload upload to multiple locations?

I'm looking into the Maven Wagon Plugin to attempt uploading some artifacts to remote UNC Server shares (\\servername\share\directory\to\put\to), and I have gotten it configured to work like so in the POM:
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-jar-to-folder</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
</execution>
</executions>
<configuration>
<fromDir>${project.build.directory}</fromDir>
<includes>*</includes>
<url>file://localhost///${servername}/${sharename}</url>
<toDir>directory/to/put/artifact</toDir>
</configuration>
</plugin>
...
</build>
This works great for one server when I pass in -Dservername=x -Dsharename=y, but how can I scale it out so I can run a deploy for QA or Prod where I have multiple servers to deploy to?
I've considered (and written) a script to run mvn wagon:upload -Penvironment# multiple times--once for each server--but this seems flawed to me. If I'm shelling out to a script to handle this process, I could just as well script out the entire deploy, too. However, this takes away from the usefulness of Wagon (and Maven)...
Is there a way to run multiple <executions> for one goal? For instance, running multiple profile configured wagon:upload tasks when I just run mvn deploy -Pqa?
If you want to use multiple profiles you could just use: mvn deploy -Denv=qa and trigger some profiles on this property and define the configuration for your severs in the profiles. For this kind of profile activation look at
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
and search for
-Denvironment=test
Here's an example POM which does two executions of the maven-antrun-plugin in one build:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.stackoverflow</groupId>
<artifactId>q5328617</artifactId>
<version>0.0.1-SNAPSHOT</version>
<profiles>
<profile>
<activation>
<property>
<name>env</name>
<value>qa</value>
</property>
</activation>
<id>qa1</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>qa1</id>
<phase>test</phase>
<configuration>
<tasks>
<echo level="info">Executing qa1</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<activation>
<property>
<name>env</name>
<value>qa</value>
</property>
</activation>
<id>qa2</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>qa2</id>
<phase>test</phase>
<configuration>
<tasks>
<echo level="info">Executing qa2</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

Resources