Get svn revision number trough Maven as a variable for later use in Java code - maven

How can I do this?
I want to get the build number from the checked out branch and build it with Maven. Later in my java application I want to use the buildNumber variable as a Revision ID so i'll have more specific details on each project build.
I am currently using this code for getting the buildNumber and use resource filtering on it in a build.properties file but the ${buildNumber} from the file doesn't get updated with the revision number.
<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.company</groupId>
<artifactId>myProject</artifactId>
<version>2.5</version>
<packaging>pom</packaging>
<name>myProject</name>
<description>myProject Modules</description>
<!-- Module list must match directory name (Camel Case) -->
<modules>
....
<!-- Contains modules -->
</modules>
<properties>
<myProject.version>${project.version}</myProject.version>
<java-version>1.7</java-version>
<svn.root>http://SVNmyCompanyURL/Project/myProject/trunk</svn.root>
<apsf.groupId>com.myCompany.aps</apsf.groupId>
<aji.version>13.22</aji.version>
<pim.version>1.8</pim.version>
<apsf.version>1.5.0.0</apsf.version>
<springframework.version>4.2.3.RELEASE</springframework.version>
<apsf.service.groupId>com.myCompany.aps.adf</apsf.service.groupId>
<apsf.service.version>1.5.0.0</apsf.service.version>
<apsf.codegen.groupId>com.myCompany.aps.adf</apsf.codegen.groupId>
<apsf.codegen.version>1.5.0.0</apsf.codegen.version>
<apsf.module.scope>compile</apsf.module.scope>
<myProject.buildNumber>${project.version}.{buildNumber}</myProject.buildNumber>
</properties>
<scm>
<url>${svn.root}</url>
<connection>scm:svn:${svn.root}</connection>
<developerConnection>scm:svn:${svn.root}</developerConnection>
<tag>HEAD</tag>
</scm>
<issueManagement>
<!-- Jira stuff -->
</issueManagement>
<organization>
<!-- Company stuff -->
</organization>
<dependencyManagement>
<dependencies>
<!--Lots of dependencies-->
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>dev</id>
<properties>
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
</profile>
<profile>
<id>skipTests</id>
<properties>
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
</profile>
<profile>
<id>integration-test</id>
<properties>
<build.profile.id>integration-test</build.profile.id>
<skip.integration.tests>false</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<timestampFormat>{0,date,dd-MM-yyyy HH:mm:ss}</timestampFormat>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.8.5</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<compilerArgument>-Xlint:none</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<skipTests>${skip.unit.tests}</skipTests>
<argLine>-XX:-UseSplitVerifier</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Implementation-Build>${buildNumber}</Implementation-Build>
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Vendor>ENTERPRISE</Implementation-Vendor>
<Implementation-Version>${project.version}</Implementation-Version>
<Built-By>${user.name}</Built-By>
<Built-OS>${os.name}</Built-OS>
<Build-Date>${timestamp}</Build-Date>
<SCM-Revision>${buildNumber}</SCM-Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-6</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.4</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.1,)</versionRange>
<goals>
<goal>copy</goal>
<goal>unpack</goal>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<versionRange>[1.7,)</versionRange>
<goals>
<goal>add-test-source</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.3,)</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<versionRange>[1.2.3,)</versionRange>
<goals>
<goal>bind</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

You should use the following to configure it correctly as aalready mentioned not defining executions in pluginManagement.
<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.company</groupId>
<artifactId>myProject</artifactId>
<version>2.5</version>
<packaging>pom</packaging>
<name>myProject</name>
<description>myProject Modules</description>
<!-- Module list must match directory name (Camel Case) -->
<modules>
<!-- Contains modules -->
</modules>
<properties>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<svn.root>http://SVNmyCompanyURL/Project/myProject/trunk</svn.root>
<apsf.groupId>com.myCompany.aps</apsf.groupId>
<aji.version>13.22</aji.version>
<pim.version>1.8</pim.version>
<apsf.version>1.5.0.0</apsf.version>
<springframework.version>4.2.3.RELEASE</springframework.version>
<apsf.service.groupId>com.myCompany.aps.adf</apsf.service.groupId>
<apsf.service.version>1.5.0.0</apsf.service.version>
<apsf.codegen.groupId>com.myCompany.aps.adf</apsf.codegen.groupId>
<apsf.codegen.version>1.5.0.0</apsf.codegen.version>
<apsf.module.scope>compile</apsf.module.scope>
</properties>
<scm>
<url>${svn.root}</url>
<connection>scm:svn:${svn.root}</connection>
<developerConnection>scm:svn:${svn.root}</developerConnection>
<tag>HEAD</tag>
</scm>
<issueManagement>
<!-- Jira stuff -->
</issueManagement>
<organization>
<!-- Company stuff -->
</organization>
<dependencyManagement>
<dependencies>
<!--Lots of dependencies -->
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>dev</id>
<properties>
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
</profile>
<profile>
<id>skipTests</id>
<properties>
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
</profile>
<profile>
<id>integration-test</id>
<properties>
<build.profile.id>integration-test</build.profile.id>
<skip.integration.tests>false</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<timestampFormat>{0,date,dd-MM-yyyy HH:mm:ss}</timestampFormat>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.8.5</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<compilerArgument>-Xlint:none</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<skipTests>${skip.unit.tests}</skipTests>
<argLine>-XX:-UseSplitVerifier</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Implementation-Build>${buildNumber}</Implementation-Build>
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Vendor>ENTERPRISE</Implementation-Vendor>
<Implementation-Version>${project.version}</Implementation-Version>
<Built-By>${user.name}</Built-By>
<Built-OS>${os.name}</Built-OS>
<Build-Date>${timestamp}</Build-Date>
<SCM-Revision>${buildNumber}</SCM-Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-6</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.1</version>
</plugin>
<!--
! Wrong plugin.
!
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.4</version>
</plugin>
<!--
! This is the correct one!
-->
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.2</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.1,)
</versionRange>
<goals>
<goal>copy</goal>
<goal>unpack</goal>
<goal>
copy-dependencies
</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
build-helper-maven-plugin
</artifactId>
<versionRange>
[1.7,)
</versionRange>
<goals>
<goal>add-test-source</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-antrun-plugin
</artifactId>
<versionRange>
[1.3,)
</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jibx</groupId>
<artifactId>
jibx-maven-plugin
</artifactId>
<versionRange>
[1.2.3,)
</versionRange>
<goals>
<goal>bind</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

I had to create a separate <plugins> tag </plugins> outside the <pluginManagement> tag and insert the plugin there and now it works.

Related

SonarCould Error: org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar

I have a project managed with maven, and after successful mvn test I was running the analysis with sonarcloud.
I ran the mvn verify sonar:sonar command, but as you can see in the image the build failed.
the plugin in the pom file:
<build>
<plugins>
<!-- Maven Release Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven.release.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.release</groupId>
<artifactId>maven-release-oddeven-policy</artifactId>
<version>${maven.release.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
<configuration>
<goals>deploy</goals>
<localCheckout>true</localCheckout>
<releaseProfiles>release</releaseProfiles>
<useReleaseProfile>false</useReleaseProfile>
<projectVersionPolicyId>OddEvenVersionPolicy</projectVersionPolicyId>
</configuration>
</plugin>
<!-- Maven Source Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Maven Enforcer Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.3.9,)</version>
</requireMavenVersion>
<requireJavaVersion>
<message>Project must be compiled
with Java 8 or higher
</message>
<version>1.8.0</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- Maven Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<nodeVersion>v10.13.0</nodeVersion>
<npmVersion>6.9.0</npmVersion>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Maven Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<!-- Maven Clean Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- BND Maven Plugin -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>${bnd.version}</version>
</plugin>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-baseline-maven-plugin</artifactId>
<version>${bnd.version}</version>
</plugin>
<!-- Maven Resources Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<!-- Maven Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
</plugin>
<!-- Maven Installer Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<!-- Maven Surefire Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<!-- Maven Failsafe Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<!-- Maven Deploy Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- Apache Sling Plugin -->
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>sling-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<slingUrl>http://${aem.host}:${aem.port}/system/console</slingUrl>
<deploymentMethod>WebConsole</deploymentMethod>
</configuration>
</plugin>
<!-- HTL Maven Plugin -->
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>htl-maven-plugin</artifactId>
<version>1.0.6</version>
<configuration>
<failOnWarnings>true</failOnWarnings>
</configuration>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Jackrabbit FileVault Package Plugin -->
<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<filterSource>src/main/content/META-INF/vault/filter.xml</filterSource>
</configuration>
</plugin>
<!-- Content Package Plugin -->
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<version>1.0.2</version>
<configuration>
<targetURL>http://${aem.host}:${aem.port}/crx/packmgr/service.jsp</targetURL>
<failOnError>true</failOnError>
<userId>${vault.user}</userId>
<password>${vault.password}</password>
</configuration>
</plugin>
<!-- Maven Enforcer Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
</plugin>
<!-- Maven Dependency Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- Build Helper Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse
m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>enforce</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.2,)
</versionRange>
<goals>
<goal>copy-dependencies</goal>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
build-helper-maven-plugin
</artifactId>
<versionRange>
[1.5,)
</versionRange>
<goals>
<goal>
reserve-network-port
</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Can anyone tell me how to fix this?

Using maven release plugin on multi-module project

I have a multi-module project with two modules: war and ear module. I'm trying to use Maven release plugin to manage releases.
My config so far...
parent pom:
<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</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>Test-WAR</module>
<module>Test-EAR</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- some other properties -->
</properties>
<dependencyManagement>
<dependencies>
<!-- some dependencies -->
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>nexus-snapshots</id>
<name>nexus</name>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
</repository>
<repository>
<id>nexus-releases</id>
<name>nexus</name>
<url>http://nexus.example.com:8081/repository/maven-releases</url>
</repository>
</repositories>
<distributionManagement>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>nexus</name>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
</snapshotRepository>
<repository>
<id>nexus-releases</id>
<name>nexus</name>
<url>http://nexus.example.com:8081/repository/maven-releases</url>
</repository>
</distributionManagement>
<scm>
<connection>scm:git:http://gitlab.example.com/test/Test.git</connection>
<developerConnection>scm:git:http://gitlab.example.com/test/Test.git</developerConnection>
<url>http://gitlab.example.com/test/Test</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v#{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>1.1.8</version>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-parent</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
war module pom:
<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>com.example</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Test-WAR</artifactId>
<packaging>war</packaging>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<!-- some dependencies -->
</dependencies>
<profiles>
<!-- dev -->
<profile>
<id>dev</id>
<properties>
<CREATE_EJB_STUBS_SCRIPT_FILE>createEJBStubs.bat</CREATE_EJB_STUBS_SCRIPT_FILE>
<APP_CLASSES_DIR>${basedir}/target/classes</APP_CLASSES_DIR>
<EJB_LOCATION>src/test/resources/build/${project.parent.artifactId}.jar</EJB_LOCATION>
<EJB_CLIENT_LOCATION>src/test/resources/build/${project.parent.artifactId}-${project.parent.version}.jar</EJB_CLIENT_LOCATION>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-ejb-client</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-snapshots</repositoryId>
<file>${EJB_CLIENT_LOCATION}</file>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-EJB-CLIENT</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>deploy-ejb</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-snapshots</repositoryId>
<file>${EJB_LOCATION}</file>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-EJB</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- release -->
<profile>
<id>release</id>
<properties>
<CREATE_EJB_STUBS_SCRIPT_FILE>createEJBStubs.bat</CREATE_EJB_STUBS_SCRIPT_FILE>
<APP_CLASSES_DIR>../../../Test-WAR/target/classes</APP_CLASSES_DIR>
<EJB_LOCATION>../../../Test-WAR/src/test/resources/build/${project.parent.artifactId}.jar</EJB_LOCATION>
<EJB_CLIENT_LOCATION>../../../Test-WAR/src/test/resources/build/${project.parent.artifactId}-${project.parent.version}.jar</EJB_CLIENT_LOCATION>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ant-build</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="server.dir" value="${SERVER_DIR}" />
<property name="createEjbStubsScriptFile" value="${CREATE_EJB_STUBS_SCRIPT_FILE}" />
<property name="appClassesDir" value="${APP_CLASSES_DIR}" />
<property name="author" value="${project.organization.name}" />
<property name="maven.root" value="${project.parent.artifactId}" />
<property name="maven.war.artifactId" value="${project.artifactId}" />
<property name="maven.war.version" value="${project.parent.version}" />
<ant antfile="${basedir}/src/test/resources/ant/build.xml">
<target name="run" />
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-ejb-client</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-releases</repositoryId>
<file>${EJB_CLIENT_LOCATION}</file>
<url>http://nexus.example.com:8081/repository/maven-releases</url>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-EJB-CLIENT</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>deploy-ejb</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-releases</repositoryId>
<file>${EJB_LOCATION}</file>
<url>http://nexus.example.com:8081/repository/maven-releases</url>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-EJB</artifactId>
<version>${project.parent.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<packagingExcludes>WEB-INF/classes/rebel.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>package</phase>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/test/resources</directory>
<includes>
<include>log4j2.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ant-build</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="server.dir" value="${SERVER_DIR}" />
<property name="createEjbStubsScriptFile" value="${CREATE_EJB_STUBS_SCRIPT_FILE}" />
<property name="appClassesDir" value="${APP_CLASSES_DIR}" />
<property name="author" value="${project.organization.name}" />
<property name="maven.root" value="${project.parent.artifactId}" />
<property name="maven.war.artifactId" value="${project.artifactId}" />
<property name="maven.war.version" value="${project.parent.version}" />
<ant antfile="${basedir}/src/test/resources/ant/build.xml">
<target name="run" />
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<verbose>true</verbose>
<fork>true</fork>
<executable>${IBM_JDK_1_8}/bin/javac</executable>
<compilerVersion>1.6</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase>
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- some config -->
</configuration>
</plugin>
</plugins>
</build>
</project>
ear module pom:
<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>com.example</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Test-EAR</artifactId>
<packaging>ear</packaging>
<dependencies>
<!-- WAR -->
<dependency>
<groupId>com.example</groupId>
<artifactId>Test-WAR</artifactId>
<version>${project.parent.version}</version>
<type>war</type>
</dependency>
<!-- some other dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9</version>
<configuration>
<modules>
<!-- some jar modules -->
<webModule>
<groupId>com.example</groupId>
<artifactId>Test-WAR</artifactId>
<contextRoot>/Test</contextRoot>
</webModule>
</modules>
<version>6</version>
<finalName>${project.parent.artifactId}-${project.parent.version}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-ear</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>nexus-snapshots</repositoryId>
<file>target/${project.parent.artifactId}-${project.parent.version}.ear</file>
<url>http://nexus.example.com:8081/repository/maven-snapshots</url>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>ear</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have two profiles - dev (which is active by default) and release (which is activated by release plugin). First, I had some problems with ant run (file paths) when releasing version, so I've used two profiles with some properties defined, that are used in ant run. Ant script is now executed properly, but I have another problem: plugin attempts to upload some release files twice which causes error:
executing mvn release:prepare "-Darguments=-Dmaven.test.skip=true": log
executing mvn release:perform "-Darguments=-Dmaven.test.skip=true": log
As you can see form logs, Test-WAR-0.0.1-sources.jar is uploading twice. Why is that? How can I edit my configuration to upload it only once?
It is quite possible that you suffer from the same bug as I did some years ago:
Maven deploy-file goal: Why does the first execution interfere with the second one?
Try to update the Maven deploy plugin to version 3.0.0-M1.

Maven release failing : A zip file cannot include itself

I am facing an issue while releasing a Maven project to nexus repository. I am doing this by Jenkins job. I am getting the error:
Failed to execute goal org.apache.maven.plugins:maven-source-plugin:3.0.1:jar (attach-sources) on project xyz: Error creating source archive: A zip file cannot include itself -> [Help 1]
I am using maven assembly plugin and external.atlassian.jgitflow:jgitflow-maven-plugin.
I have followed below article on StackOveflow : A zip file cannot include itself - Maven-assembly plugin
But this did not solve the problem. Below is how I am using the plugin
<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>
<groupId>com.x</groupId>
<artifactId>y</artifactId>
<packaging>jar</packaging>
<version>2.0.0</version>
<name>myArtifact</name>
<url>http://maven.apache.org</url>
<distributionManagement>
<repository>
<id>myRepoId</id>
<url>http://my/repo/location/releases/</url>
</repository>
<snapshotRepository>
<id>mySnapshotRepoId</id>
<url>http://my/repo/location/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>myRepoId</id>
<url>http://my/repo/location/releases/</url>
</repository>
<repository>
<id>mySnapshotRepoId</id>
<url>http://my/snapshot/repo/location/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!-- http://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<profiles>
<profile>
<id>local</id>
<properties>
<build.profile.id>local</build.profile.id>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>pre_prod</id>
<properties>
<build.profile.id>pre_prod</build.profile.id>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<build.profile.id>prod</build.profile.id>
</properties>
</profile>
</profiles>
<build>
<testResources>
<testResource>
<directory>${project.build.directory}</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>external.atlassian.jgitflow</groupId>
<artifactId>jgitflow-maven-plugin</artifactId>
<version>1.0-m5.1</version>
<configuration>
<enableSshAgent>true</enableSshAgent>
<allowUntracked>true</allowUntracked>
<allowSnapshots>true</allowSnapshots>
<autoVersionSubmodules>true</autoVersionSubmodules>
<pushFeatures>true</pushFeatures>
<pushReleases>true</pushReleases>
<pushHotfixes>true</pushHotfixes>
<noDeploy>false</noDeploy>
<scmCommentPrefix>TC-61</scmCommentPrefix>
<flowInitContext>
<developBranchName>development</developBranchName>
<versionTagPrefix>My-APP-</versionTagPrefix>
</flowInitContext>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-scm-plugin</artifactId>
<version>1.8.1</version>
<configuration>
<tag>Release-${project.artifactId}-${project.version}</tag>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<mainClass>com.mains.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<encoding>UTF-8</encoding>
<resources>
<resource>
<directory>src/main/resources/config/${build.profile.id}</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/velocities/html</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.2</version>
</plugin>
<!-- START: Maven Jacoco Plugin -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<!-- Prepares the property pointing to the JaCoCo runtime agent which
is passed as VM argument when Maven the Surefire plugin is executed. -->
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>jacoco-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<!-- Ensures that the code coverage report for unit tests is created
after unit tests have been run. -->
<execution>
<id>jacoco-report</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
Can someone point me where I am making the mistake.
Thanks.

maven pom - define a profile to customize plugin configuration

I have the following plugin in pom:
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<configuration>
<version>${phantomjs.version}</version>
<checkSystemPath>false</checkSystemPath>
<skip>${skipTests}</skip>
</configuration>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
I'd like to define a new profile to customize the plugin configuration:
<profile>
<id>enduserTest</id>
<properties>
<tomcat.version>8.0.39</tomcat.version>
<skipTests>true</skipTests>
</properties>
<build>
<defaultGoal>clean verify cargo:run</defaultGoal>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<configuration>
<version>${phantomjs.version}</version>
<checkSystemPath>false</checkSystemPath>
</configuration>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
Where the only difference is that <skip>${skipTests}</skip>
line.
Now I'd like to run mvn -PenduserTest but the configuration doesn't get overriden.
Any advice? is there a better solution to do this? is it the correct strategy?
If the desired behavior is that tests get skipped when running the profile, so your logic is not wrong. to verify i test this code and this is work as expected (it skip tests with -PenduserTest) :
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.7</version>
<configuration>
<version>2.1.1</version>
<checkSystemPath>false</checkSystemPath>
<skip>${skipTests}</skip>
</configuration>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source />
<target />
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>enduserTest</id>
<properties>
<tomcat.version>8.0.39</tomcat.version>
<skipTests>true</skipTests>
</properties>
<build>
<defaultGoal>clean verify cargo:run</defaultGoal>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.7</version>
<configuration>
<version>0.7</version>
<checkSystemPath>false</checkSystemPath>
</configuration>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

Maven site not link to Jacoco report

I can generate Jacoco report from profile 'test' and is save inside site folder. But when I execute profile 'documentacion' which contains site generation description, I get all reports link in site, except link to Jacoco report, but this report still appears inside site folder.
This is part of my POM (I cut down part which is not important):
<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">
<dependencies>
<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- Dependencia para el informe de traducción -->
<dependency>
<groupId>com.googlecode.l10n-maven-plugin</groupId>
<artifactId>l10n-maven-plugin</artifactId>
<version>1.8</version>
</dependency>
....
</dependencies>
<!-- Configuración común a todas las fases -->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.fxml</include>
</includes>
<excludes>
<exclude>package-info.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.css</include>
<include>**/*.png</include>
<include>**/*.fxml</include>
<include>**/*.ttf</include>
<include>*.properties</include>
<include>version.prop</include>
</includes>
</resource>
</resources>
</build>
<!-- Perfiles -->
<profiles>
......
<profile>
<id>documentacion</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<defaultGoal>site:site</defaultGoal>
<plugins>
<!-- Site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.4</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
</plugin>
</plugins>
</build>
<reporting>
<excludeDefaults>true</excludeDefaults>
<outputDirectory>${project.build.directory}/site</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>summary</report>
<report>index</report>
<report>dependencies</report>
<report>project-team</report>
<report>license</report>
<report>scm</report>
<report>cim</report>
<report>mailing-list</report>
<report>issue-tracking</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.13</version>
<configuration>
<configLocation>config/sun_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>l10n-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<configuration>
<locales>
<locale>es</locale>
</locales>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>2.11</version>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<useStandardDocletOptions>false</useStandardDocletOptions>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
</plugin>
</plugins>
</reporting>
</profile>
<profile>
<id>test</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<defaultGoal>validate test</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<additionalClasspathElements>
<additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
</additionalClasspathElements>
<argLine>-Dfile.encoding=UTF-8</argLine>
<skipTests>${skip.unit.tests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
So, How can I get site link to Jacoco report?
Finally, I can fix my POM so I get links to Jacoco and Surefire reports from maven site.
<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>
...
<dependencies>
<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
...
</dependencies>
<profiles>
<profile>
<id>desarrollo</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.***.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>documentacion</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<defaultGoal>site:site</defaultGoal>
<plugins>
<!-- Site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.4</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
</plugin>
</plugins>
</build>
<reporting>
<excludeDefaults>true</excludeDefaults>
<outputDirectory>${project.build.directory}/site</outputDirectory>
<plugins>
<!-- Plugin para generar el site con los reports -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>summary</report>
<report>index</report>
<report>dependencies</report>
<report>project-team</report>
<report>license</report>
<report>scm</report>
<report>cim</report>
<report>mailing-list</report>
<report>issue-tracking</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<!-- Reporte tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
</plugin>
<!-- More report plugins place here (PMD, checkstyle...) -->
</plugins>
</reporting>
</profile>
<profile>
<id>test</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<defaultGoal>validate test</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<outputDirectory>${project.build.directory}/site</outputDirectory>
<reportsDirectories>
<reportsDirectories>${project.build.directory}/site/surefire-reports</reportsDirectories>
</reportsDirectories>
<testFailureIgnore>true</testFailureIgnore>
<additionalClasspathElements>
<additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
</additionalClasspathElements>
<argLine>${argLine} -Dfile.encoding=UTF-8</argLine>
</configuration>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Test report -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

Resources