Robot framework and it's library how to put in POM to install on docker - maven

Hi experts my use case is that I have to install robotframework and it's libraries on docker using POM.xml in maven style. because there are some limitations in my organization where we can not run chef on docker.
Here is I have created sample pom.xml. I need to do "pip install robotframework", pip install robotframework-databaselibrary" many more.
Can someone please help me out
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>robotframework</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${project.build.directory}/Library" />
<untar src="${project.build.directory}/Library/${robotframework.version}.tar.gz" compression="gzip" dest="${project.build.directory}/robotframework" />
</target>
</configuration>
</execution>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>0.0.2</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>pip install robotframework</executable>
</configuration>
</execution>
</executions>
</plugin>

Related

How to create docker image in Spring Boot project

I have tried using spotify/docker-maven-plugin without any success .
Below is part of my pom.xml file
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${dockerfile-maven-version}</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>myrepo/maven-docker-spotify</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}-jar-with-dependencies.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
The spotify/docker-maven-plugin you are using is currently inactive. It's recommended using spotify/dockerfile-maven-plugin instead.
So change the plugin section of your pom.xml file to resemble below
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${dockerfile-maven-version}</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>spotify/foobar</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
Note: You can also try using JIB maven plugin that doesnt require you to have docker installed and works with minimal configuration. With JIB, Running below command in is enough to do the jo
mvn compile com.google.cloud.tools:jib-maven-plugin:0.9.2:dockerBuild

exec-maven-plugin with npm install

I try to use exec-maven-plugin in my project.
Here is the code
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.6.0</version>
<executions>
<execution>
<id>npm install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>${node.directory}/${npm.executable}</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>src/main/angular2/tourism</workingDirectory>
<target>
<echo message="Npm install" />
</target>
</configuration>
</execution>
</executions>
</plugin>
Here is my directory structure
And the mentioned error is
/Users/admin/Application-Marwen/workspace/Tourism/Tourism-Web/node/npm: line 34: node: command not found
Could you please help me
I use know frontend-maven-plugin
Here is the code
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
<!-- where to install npm -->
<installDirectory>src/main/angular5/tourisml</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>${project.artifactId}-${project.version}.zip</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>cfg-main-resources</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/angular5/tourism/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
And the assembly.xml file
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>statics</outputDirectory>
<directory>dist</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
The objective is to prepare a zip file containing the compiled code to deploy it on server
Here is the obtained directory structure
1) I don't understand why the dist folder does not contain the compiled code (I wonder furthermore what it must contain exactly)
2) node and npm are installed in the directory tourisml/node, why
3) there is an error stating that
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (cfg-main-resources) on project tourism-web: Failed to create assembly: Error creating assembly archive distribution: You must set at least one file. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (cfg-main-resources) on project tourism-web: Failed to create assembly: Error creating assembly archive distribution: You must set at least one file.
Normally I should obtaine one zip file (${project.artifactId}-${project.version}.zip) and I suppose it failed because there is no files in. Is that correct ?
Instead of using exec-maven-plugin, I suggest you to take a look at the frontend-maven-plugin to build your Node sources using npm install.
Using that plugin, you don't need to have npm or node installed on your machine : the plugin manages all by itself, so you should not encounter issues like command not found. Configuration like the following should work :
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
<!-- where to install npm -->
<installDirectory>${project.build.directory}/install</installDirectory>
</configuration>
<executions>
<execution>
<id>install-node-and-npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v${node.version}</nodeVersion>
<npmVersion>${npm.version}</npmVersion>
</configuration>
</execution>
<execution>
<id>npm-install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
</executions>
</plugin>
I have installed node and moved the installed folder under ${project.baseUri}/node/.
That error got resolved now and I can able to do npm install using below command in Command Prompt.
c:\main\prjt\apphost_prjt>mvn frontend:npm
Finally, I used frontend-maven-plugin
Here is an extract of the pom.xml
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
<!-- where to install npm -->
<installDirectory>temp</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
Thank you for your answers

Not able to get it test coverage in sonarqube

[enter image description here][1][enter image description here][2]I know many people got such similar problem. i show many answars, tried the sample code given on sonar site. that sample is working fine. Also i show following link
How to configure multi-module Maven + Sonar + JaCoCo to give merged coverage report?
But nothing seems working in my case. Its not showing IT Test Coverage in sonarqube though mvn clean intsall is making jacoco folder in site where index.html is having coverage report.
i tried almost every thing on net but not able to resolve issue.
its a multi module project
I am using
java8.
sonarqube 4.5.6 with java plugin 2.5.1.
maven 3.0.5
please help me resolve this.
Below is parent module pom file
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.basedir}/target/jacoco.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/../target/jacoco.exec</dataFile>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
<propertyName>failsafe.argLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.basedir}/../target/jacoco-it.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<argLine>${failsafe.argLine}</argLine>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- automatic label creation -->
</plugins>
</build>
<!-- Plugin to generate unit test coverage in SonarQube 4.5.x report. -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<use>false</use>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-report-plugin.version}</version>
<configuration>
<alwaysGenerateFailsafeReport>true</alwaysGenerateFailsafeReport>
<alwaysGenerateSurefireReport>true</alwaysGenerateSurefireReport>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*.mar</exclude>
<exclude>${jacoco.excludePattern}</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</reporting>
Properties in same pom file
<sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath> <!-- This is the default, put here to be explicit -->
<sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.language>java</sonar.language>
<sonar.java.binaries>${project.basedir}/../target/classes</sonar.java.binaries>
<jacoco-maven-plugin.version>0.7.4.201502262128</jacoco-maven-plugin.version>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<maven-surefire-report-plugin.version>2.19.1</maven-surefire-report-plugin.version>
<maven-surefire-plugin.version>2.16</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.16</maven-failsafe-plugin.version>
mvn clean install is creating jacoco folder with index.html for test coverage but mvn sonar:sonar is not showing it in sonarqube
what mistake i am making.
in mvn sonar:sonar, it builds successfully and one of the line is JaCoCoSensor: JaCoCo report not found.
what could be the reason
i seriously feel this a bug with jacoco or sonarqube. May be it would not be compatible with java 8 or something. I tried almost every thing. Many things are deprecated with sonar java plugin 2.5.1. Please help me, i need the solution desperately
Just tried it, and the sample project works perfectly. Please make sure you do the following:
git clone https://github.com/SonarSource/sonar-examples.git
cd projects/languages/java/code-coverage/combined ut-it/combined-ut-it-multimodule-maven-jacoco
mvn clean package
mvn sonar:sonar
Also - not sure if this is related, but you're using a very old version of the SQ Java plugin (2.5.1). I can only advise you to update it to latest version.
Well, i am not sure why the above code is not working but i tried same thing bit differently and miracle happened. Let me give the solution what it worked for me.
I removed the below code from parent pom and put it in all child pom. Also since i was using it in child module i used target/jacoco.exec instead of ${project.basedir}/../target/jacoco.exec and same for jacoco-it.exec.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>target/jacoco.exec</destFile>
<propertyName>surefireArgLine</propertyName>
<append>true</append>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>target/jacoco.exec</dataFile>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>target/jacoco-it.exec</destFile>
<propertyName>failsafe.argLine</propertyName>
<append>true</append>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>target/jacoco-it.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
Additional information. following plugin which i mentioned in my question is not required if Test coverage is required only in sonar report. If there is requirement for code report separately then its required
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*.mar</exclude>
<exclude>${jacoco.excludePattern}</exclude>
</excludes>
</configuration>
</plugin>

Maven rename a file after everything else finishes

I have a project which I need to rename the final output file generated by the Maven Assembly Plugin after everything else finishes (in the compiling/building/assembly process).
The Maven Assembly Plugin is generating a final .zip file, based on the project's name, and I need to rename this completely to final-version.oxt. I'm trying to use the maven-antrun-plugin to rename it, as pointed by other similar questions here, but no luck (I've never used Maven or Ant before, so maybe I'm missing something).
This is the <build> section of the project's pom.xml. The rename part seems to be completely ignored, since no file is generated in my home folder.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
<descriptors>
<descriptor>src/main/assembly/ooo-jar.xml</descriptor>
<descriptor>src/main/assembly/ooo.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<configuration>
<tasks>
<copy file="${project.build.directory}/target/libreofficeplugin-ooo.zip"
tofile="/home/brunofinger/final-version.oxt" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
A few modifications made it work, probably the phase was wrong, but using <phase>install</phase> seems to make it work:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<copy file="${project.build.directory}/libreofficeplugin-ooo.zip" tofile="${project.build.directory}/final-version.oxt" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
This question is nearly an year old, but in case anyone else is facing similar issue, here is an alternate solution.
If you are looking for a more mavenish way of doing it,you can use
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>rename-file</id>
<phase>install</phase>
<goals>
<goal>rename</goal>
</goals>
<configuration>
<sourceFile>${project.build.outputDirectory}/libreofficeplugin-ooo.zip</sourceFile>
<destinationFile>${project.build.outputDirectory}/final-version.oxt</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
and in case you want to copy instead of rename, use the copy goal instead of the rename goal.
You don't need to use antrun to rename the output file. Just use the tag finalName of the assembly plugin to rename the output file.
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
<descriptors>
<descriptor>src/main/assembly/ooo-jar.xml</descriptor>
<descriptor>src/main/assembly/ooo.xml</descriptor>
</descriptors>
<finalName>final-version.oxt</finalName>
</configuration>
</execution>
</executions>
</plugin>

Install Maven itself from Maven Central

I have a maven plugin I would like to test against different Maven versions (Ex.: 2.2.1 & 3.0.4). Ideally I don't want users running the build to have to install these exact versions manually.
Is it possible to install specific versions of Maven itself from Maven Central or some other source that would then cache them in the local Maven repo for subsequent builds?
Maven distributions are stored in Maven Central Repository, as you can see here:
http://mvnrepository.com/artifact/org.apache.maven/apache-maven
https://repository.sonatype.org/index.html#nexus-search;gav~org.apache.maven~apache-maven~~~~kw,versionexpand
Therefore, it can be used as a normal dependency with following coordinates:
tar.gz variant:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>apache-maven</artifactId>
<version>3.0.4</version>
<classifier>bin</classifier>
<type>tar.gz</type>
</dependency>
zip variant:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>apache-maven</artifactId>
<version>3.0.4</version>
<classifier>bin</classifier>
<type>zip</type>
</dependency>
The rest is quite standard - you will probably use it in integration test poms, and call them with maven-invoker-plugin as recommended by #khmarbaise.
Why don't you simply just install a Continuous Integration (CI) server such as Jenkins / Hudson / TeamCity / etc? CI servers allow you to run your build against different versions of an SDK.
If your plugin is OSS (and on GitHub), I believe you can get free Jenkins hosting from Cloudbees.
Downloading Maven itself from Maven Central is not possible. You can only download it from their site.
You could do a thing like the following:
<profile>
<id>run-its</id>
<build>
<!-- Download the different Maven versions -->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>download-maven-2.0.11</id>
<phase>prepare-package</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>http://archive.apache.org/dist/maven/binaries/</url>
<fromFile>apache-maven-2.0.11-bin.tar.gz</fromFile>
<toDir>${project.build.directory}/maven/download/</toDir>
</configuration>
</execution>
<execution>
<id>download-maven-2.2.1</id>
<phase>prepare-package</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>http://archive.apache.org/dist/maven/binaries/</url>
<fromFile>apache-maven-2.2.1-bin.tar.gz</fromFile>
<toDir>${project.build.directory}/maven/download/</toDir>
</configuration>
</execution>
<execution>
<id>download-maven-3.0.3</id>
<phase>prepare-package</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>http://archive.apache.org/dist/maven/binaries/</url>
<fromFile>apache-maven-3.0.3-bin.tar.gz</fromFile>
<toDir>${project.build.directory}/maven/download/</toDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<executions>
<execution>
<id>extract-maven-2.0.11</id>
<goals>
<goal>copy</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<fileset>
<directory>${project.build.directory}/maven/download/apache-maven-2.0.11-bin.tar.gz</directory>
<outputDirectory>${project.build.directory}/maven/tools/</outputDirectory>
</fileset>
</configuration>
</execution>
<execution>
<id>extract-maven-2.2.1</id>
<goals>
<goal>copy</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<fileset>
<directory>${project.build.directory}/maven/download/apache-maven-2.2.1-bin.tar.gz</directory>
<outputDirectory>${project.build.directory}/maven/tools/</outputDirectory>
</fileset>
</configuration>
</execution>
<execution>
<id>extract-maven-3.0.3</id>
<goals>
<goal>copy</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<fileset>
<directory>${project.build.directory}/maven/download/apache-maven-3.0.3-bin.tar.gz</directory>
<outputDirectory>${project.build.directory}/maven/tools/</outputDirectory>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
<!--
This is currently needed due to a bug of the truezip-plugin cause it unpacks without permission!
see http://jira.codehaus.org/browse/MOJO-1796
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>chmod-files</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<chmod file="${project.build.directory}/maven/tools/apache-maven-2.0.11/bin/mvn" perm="+x"/>
<chmod file="${project.build.directory}/maven/tools/apache-maven-2.2.1/bin/mvn" perm="+x"/>
<chmod file="${project.build.directory}/maven/tools/apache-maven-3.0.3/bin/mvn" perm="+x"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>1.8.4</version>
</dependency>
</dependencies>
<configuration>
<debug>false</debug>
<!-- src/it-ip as for integration tests invoker plugin for the time of transition to maven-invoker-plugin -->
<projectsDirectory>src/it</projectsDirectory>
<showVersion>true</showVersion>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<preBuildHookScript>setup</preBuildHookScript>
<postBuildHookScript>verify</postBuildHookScript>
<settingsFile>src/it/settings.xml</settingsFile>
</configuration>
<executions>
<execution>
<id>integration-test-maven-2.0.11</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<reportsDirectory>${project.build.directory}/invoker-reports-2.0.11</reportsDirectory>
<localRepositoryPath>${project.build.directory}/local-repo-2.0.11</localRepositoryPath>
<cloneProjectsTo>${project.build.directory}/it-2.0.11</cloneProjectsTo>
<mavenHome>${project.build.directory}/maven/tools/apache-maven-2.0.11</mavenHome>
<goals>
<goal>clean</goal>
<goal>test</goal>
</goals>
</configuration>
</execution>
<execution>
<id>integration-test-maven-2.2.1</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<reportsDirectory>${project.build.directory}/invoker-reports-2.2.1</reportsDirectory>
<localRepositoryPath>${project.build.directory}/local-repo-2.2.1</localRepositoryPath>
<cloneProjectsTo>${project.build.directory}/it-2.2.1</cloneProjectsTo>
<mavenHome>${project.build.directory}/maven/tools/apache-maven-2.2.1</mavenHome>
<goals>
<goal>clean</goal>
<goal>test</goal>
</goals>
</configuration>
</execution>
<execution>
<id>integration-test-maven-3.0.3</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<reportsDirectory>${project.build.directory}/invoker-reports-3.0.3</reportsDirectory>
<localRepositoryPath>${project.build.directory}/local-repo-3.0.3</localRepositoryPath>
<cloneProjectsTo>${project.build.directory}/it-3.0.3</cloneProjectsTo>
<mavenHome>${project.build.directory}/maven/tools/apache-maven-3.0.3</mavenHome>
<goals>
<goal>clean</goal>
<goal>test</goal>
</goals>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
This will download the different Maven version unpack the .tar.gz archives and make mvn executable and use maven-invoker-plugin to run all integration test with these different maven versions.
BUT i can't recommend that. The better way is to use a CI solution (as already mentioned) which contains the different installations of Maven. Than you can run the integration tests for each Maven version separately.

Resources