Building a XPages App with Maven and running Junit Tests - maven

I have an Domino XPages Application which is already built from an OnDiskProject into an .nsf by maven.
The pom.xml for that step is ok and running.
Now, I wanted to include the maven-surefire-plugin (or any other) to execute the Junit Tests. But maven told me, that there are no tests found.
I use the Packaging Type domino-nsf from frostillic.us, which works fine for compiling and deploying.
The plugin definition is as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.8</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
We use the https://www.openntf.org/main.nsf/project.xsp?r=project/org.openntf.junit.xsp plugin to develop tests. The tests are running in the browser with no problem (calling an Xpage with Junit tests).
May be I have to create a separate module for testing, but I did not have success with that approach. Any help or hints are appreciated and welcome.
I tried it with the maven-surefire-plugin and also with tycho-surefire-plugin. But both didn't work. The tycho-surefire-plugin don't work with the domino-nsf packaging type.
Update:
Here is the complete 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/maven-v4_0_0.xsd">
<groupId>TMS</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>xxx</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>domino-nsf</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<bazaar-version>2.0.9</bazaar-version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>artifactory.openntf.org</id>
<name>artifactory.openntf.org</name>
<url>https://artifactory.openntf.org/openntf</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>artifactory.openntf.org</id>
<name>artifactory.openntf.org</name>
<url>https://artifactory.openntf.org/openntf</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.openntf.maven</groupId>
<artifactId>nsfodp-maven-plugin</artifactId>
<version>3.10.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>compiletests</id>
<phase>test-compile-plugin</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<updateSites>
<updateSite>C:\Users\xxx\Documents\junit\org.openntf.junit.xsp.updatesite</updateSite>
</updateSites>
<binaryDxl>true</binaryDxl>
<propertiesEncoding>UTF-8</propertiesEncoding>
<encoding>UTF-8</encoding>
<templateName>TMS</templateName>
<deployDestPath>127.0.0.1!!xxx\xxx.nsf</deployDestPath>
<deployReplaceDesign>true</deployReplaceDesign>
<acl>
<roles>
<role>[_Admins]</role>
</roles>
<entries>
<entry>
<name>-Default-</name>
<defaultEntry>true</defaultEntry>
<level>noaccess</level>
</entry>
<entry>
<name>[OtherDomainServers]</name>
<level>noaccess</level>
</entry>
<entry>
<name>[LocalDomainAdmins]</name>
<level>manager</level>
<deleteDocs>true</deleteDocs>
<noReplicate>false</noReplicate>
</entry>
<entry>
<name>[LocalDomainServers]</name>
<level>manager</level>
<deleteDocs>true</deleteDocs>
<noReplicate>false</noReplicate>
</entry>
<entry>
<name>CN=xxx/O=xxx</name>
<level>manager</level>
<deleteDocs>true</deleteDocs>
<noReplicate>false</noReplicate>
<roles>
<role>[_Admins]</role>
</roles>
</entry>
<entry>
<name>CN=Administrator/O=xxx</name>
<level>manager</level>
<deleteDocs>true</deleteDocs>
<noReplicate>false</noReplicate>
<roles>
<role>[_Admins]</role>
</roles>
</entry>
</entries>
</acl>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.8</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Output Maven Call
Directory Structure 1
ODP Structure

Related

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 release: Developer information missing

Getting this error on mvn release:perform
[ERROR] Repository "comconvertapi-1002" failures
[ERROR] Rule "pom-staging" failures
[ERROR] * Invalid POM: /com/convertapi/client/convertapi/1.7/convertapi-1.7.pom: Developer information missing
Releasing from branch: https://github.com/ConvertAPI/convertapi-java/tree/feature/maven (could this error be related with that?)
This is POM file:
<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.convertapi.client</groupId>
<artifactId>convertapi</artifactId>
<packaging>jar</packaging>
<version>1.8-SNAPSHOT</version>
<name>ConvertAPI Java Client</name>
<description>
The ConvertAPI helps converting various file formats.
Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages or raw HTML codes.
Merge, Encrypt, Split, Repair and Decrypt PDF files.
And many others files manipulations.
In just few minutes you can integrate it into your application and use it easily.
The ConvertAPI client library makes it easier to use the Convert API from your Java 8 projects without having to
build your own API calls.
</description>
<url>https://www.convertapi.com/</url>
<licenses>
<license>
<name>The MIT License</name>
<url>https://raw.githubusercontent.com/ConvertAPI/convertapi-java/master/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>jonas</id>
<name>Jonas Jasas</name>
<email>jonas#baltsoft.com</email>
<organization>Baltsoft</organization>
<organizationUrl>http://www.baltsoft.com/</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+3</timezone>
<properties>
<picUrl>https://avatars3.githubusercontent.com/u/16254748</picUrl>
</properties>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/ConvertAPI/convertapi-java.git</connection>
<developerConnection>scm:git:git://github.com/ConvertAPI/convertapi-java.git</developerConnection>
<url>https://github.com/ConvertAPI/convertapi-java</url>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.10.0</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/examples/*</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<localCheckout>true</localCheckout>
<pushChanges>false</pushChanges>
<mavenExecutorId>forked-path</mavenExecutorId>
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.5</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</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</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!-- GPG Signature on release -->
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
It's seem ok, but sometime maven plugins use cache for some info.
Try to clear cache by this sequence of commands:
mvn clean
mvn release:prepare -Dresume=false
mvn release:perform
If it not helped, try to simplify developer section (excluding sequentially properties, timezone and so on)
Publish Requirement
Please check you have fulfill all your publish requirement.
Supply Javadoc and Sources⚓︎
Sign Files with GPG/PGP
Sufficient Metadata
Correct Coordinates
Project Name, Description and URL
License Information
Developer Information
SCM Information

Pass port number from docker-maven-plugin to spring property

I'm developing Spring Data JPA project that targets a MySQL database, and I want to run end-to-end integration tests from Maven.
So far, I've configured io.fabric8.docker-maven-plugin to spin up a MySQL container during pre-integration-test phase. It will use a random available port, which I need to pass to my application.properties file.
I've tried Automatic property expansion using Maven but I suspect that the mysql.port maven property is only getting resolved after the spring properties are getting updated.
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>example</groupId>
<artifactId>pass-port-number-from-docker-maven-plugin-to-spring-property</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- other jpa dependencies ... -->
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>docker-test</id>
<properties>
<docker-maven.version>0.21.0</docker-maven.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>mysql.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven.version}</version>
<configuration>
<images>
<image>
<alias>mysql</alias>
<name>mysql:5.7</name>
<run>
<env>
<MYSQL_ROOT_PASSWORD>my-secret-pw</MYSQL_ROOT_PASSWORD>
</env>
<ports>
<port>mysql.port:3306</port>
</ports>
<wait>
<log>ready for connections</log>
<!-- <time>20000</time> -->
</wait>
<log>
<prefix>mysql</prefix>
<date>ISO8601</date>
<color>blue</color>
</log>
</run>
</image>
</images>
</configuration>
<!-- Connect start/stop to pre- and
post-integration-test phase, respectively if you want to start
your docker containers during integration tests -->
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
application.properties
mysql.port = #mysql.port#
When I run my test I get a connection error, and when I inspect target/classes/application.properties I see that #mysql.port# hasn't been updated.
Any suggestions would be much appreciated.
# only works if you extend from spring-boot-starter-parent; you didn't show the relevant portions of your pom.xml. Assuming you did that, try attaching reserve-network-port to process-sources phase, before process-resources. It's very possible that when Maven copies the resources, the reserve-network-port hasn't ran yet.
What happens if you hardcode 3306 in application.properties?

Maven deploy multiple wars to embedded server for integration tests

I have had no issue running a maven war project on an embedded server for its own integration tests, but now I need to run multiple wars and test from a different project.
I would like to setup the following scenario...
I have two Maven war projects in my local workspace called War1 and War2. I would like to have a 3rd Maven project, WarIntegration, that contains only integration tests and does the following:
Packages War1
Packages War2
Starts an embedded server
Deploys both wars to same embedded server
Runs integration tests contained within WarIntegration (which will make http calls to War1 and War2)
Stops embedded server
Is this possible? What plugin setup will achieve this? What kind of project should WarIntergration be (packaging)? Should War1 and War2 be modules in WarIntegration or dependencies? Can all of the configuration be aded to the WarIntegration project or would it have to be spread across the projects?
This is similar to this question, except we must use an embedded server that is started and stopped by the project (probably when we run verify) and we need a separate project for integration tests:
I have a multi-module Maven 2 POM that has two WARs, how can I configure it to deploy both wars prior to running tests?
I was able to achieve this using the cargo-maven2-plugin.
Here are the relevant pieces of the pom for anyone who is interested...
...
<groupId>com.test</groupId>
<artifactId>webapp-integration</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
...
<dependencies>
...
<dependency>
<artifactId>webapp1</artifactId>
<groupId>com.test</groupId>
<version>1.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>webapp2</groupId>
<artifactId>com.test</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<container>
<containerId>jetty6x</containerId>
<type>embedded</type>
</container>
<configuration>
<type>standalone</type>
<properties>
<cargo.servlet.port>8085</cargo.servlet.port>
</properties>
<deployables>
<deployable>
<artifactId>webapp1</artifactId>
<groupId>com.test</groupId>
<type>war</type>
<pingURL>http://localhost:8085/testapp/</pingURL>
<properties>
<context>testapp</context>
</properties>
</deployable>
<deployable>
<artifactId>webapp2</artifactId>
<groupId>com.test</groupId>
<type>war</type>
<pingURL>http://localhost:8085/testapp2/</pingURL>
<properties>
<context>testapp2</context>
</properties>
</deployable>
</deployables>
</configuration>
</configuration>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
<configuration>
<groups>com.test.integration.IntegrationTestMarker</groups>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
<skipTests>false</skipTests>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Watch out, the DEPLOYABLES element is a child of plugin/configuration, NOT plugin/configuration/configuration.
The example above should be :
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<container>...</container>
<configuration>
<type>standalone</type>
<properties>
<cargo.servlet.port>8085</cargo.servlet.port>
</properties>
</configuration>
<deployables>
<deployable>
<artifactId>webapp1</artifactId>
<groupId>com.test</groupId>
<type>war</type>
<pingURL>http://localhost:8085/testapp/</pingURL>
<properties>
<context>testapp</context>
</properties>
</deployable>
<deployable>
<artifactId>webapp2</artifactId>
<groupId>com.test</groupId>
<type>war</type>
<pingURL>http://localhost:8085/testapp2/</pingURL>
<properties>
<context>testapp2</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
Hope that helps !

Resources