This is a project that uses both TestNG and JUnit4. I am not able to run the TestNG test suite for any reason. The error stack trace is given below.
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Exception in thread "ThreadedStreamConsumer" java.lang.NoSuchMethodError: org.ap
ache.maven.surefire.report.StackTraceWriter.getThrowable()Ljava/lang/Throwable;
at org.apache.maven.surefire.report.XMLReporter.writeTestProblems(XMLRep
orter.java:272)
at org.apache.maven.surefire.report.XMLReporter.testFailed(XMLReporter.j
ava:249)
at org.apache.maven.surefire.report.MulticastingReporter.testFailed(Mult
icastingReporter.java:80)
at org.apache.maven.surefire.report.TestSetRunListener.testFailed(TestSe
tRunListener.java:157)
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consu
meLine(ForkClient.java:106)
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamCo
nsumer$Pumper.run(ThreadedStreamConsumer.java:67)
at java.lang.Thread.run(Thread.java:722)
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
My pom set up is given below
<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>
<prerequisites>
<maven>3.0.4</maven>
</prerequisites>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<surefire.version>2.13</surefire.version>
</properties>
<parent>
<groupId>com.google</groupId>
<artifactId>google</artifactId>
<version>1</version>
</parent>
<groupId>com.google.testing</groupId>
<artifactId>test-libraries-for-java</artifactId>
<version>1.2</version>
<profiles>
<profile>
<id>junit4-only</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>junit4-only-${project.version}</classifier>
<includes>
<include>**/junit4/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>agnostic</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>agnostic-${project.version}</classifier>
<includes>
<include>**/common/testing/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>junit4</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>junit4-${project.version}</classifier>
<includes>
<include>**/common/testing/*.class</include>
<include>**/junit4/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>testng</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>testng-${project.version}</classifier>
<includes>
<include>**/common/testing/*.class</include>
<include>**/testng/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>testng-only</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>testng-${project.version}</classifier>
<includes>
<include>**/testng/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
<build>
<!-- <finalName>tl4j</finalName> -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<outputDirectory>${basedir}/target-eclipse/classes</outputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<configuration>
<tasks>
<echo
message="Please follow directions at doc/HOW_TO_RELEASE.txt to make the release" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>${surefire.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
</plugin>
</plugins>
</reporting>
My unit test
import org.testng.Assert;
import org.testng.annotations.Test;
public class TearDownTestCaseTest {
#Test
public void assertTrue() {
Assert.assertTrue(true);
}
}
Funny thing is that if I configure this test to run as JUnit 3 test case, it works, but not JUnit 4.x or Testng.
Related
attempting to build [RedFX-Quantum/Strange][1]. When running mvn package, I get "Fatal error compiling: invalid flag: --release". the pom.xml file is below:
<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>org.redfx</groupId>
<artifactId>strange</artifactId>
<packaging>jar</packaging>
<version>0.1.3</version>
<name>Strange</name>
<description>Strange Quantum Simulator</description>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<javadoc.plugin.version>3.2.0</javadoc.plugin.version>
<gpg.plugin.version>1.6</gpg.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
</dependency>
<!--
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native</artifactId>
<version>1.0.0-beta7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.26</version>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<release>10</release>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.1.1</version> <!-- Use newer version of ASM -->
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.redfx.strange.demo.Demo</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</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-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-no-snapshots</id>
<phase>install</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireReleaseDeps>
<message>Snapshot dependencies are not allowed for release project version!</message>
<onlyWhenRelease>true</onlyWhenRelease>
</requireReleaseDeps>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<organizationName>Johan Vos</organizationName>
<inceptionYear>2020</inceptionYear>
<licenseName>bsd_3</licenseName>
<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
</configuration>
</plugin>
</plugins>
</build>
<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>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<configuration>
<detectJavaApiLink>false</detectJavaApiLink>
<source>8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${gpg.plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<!-- This is necessary for gpg to not try to use the pinentry programs -->
<!-- Only required for GPG >= 2.2 -->
<!--
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
-->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<scm>
<connection>scm:git:git://github.com/redfx-quantum/strange.git</connection>
<developerConnection>scm:git:git#github.com:redfx-quantum/strange.git</developerConnection>
<url>https://github.com/redfx-quantum/strange</url>
<tag>HEAD</tag>
</scm>
</project>
running mvn package -e didn't give any noticeably different output and mvn package -X didn't give me anything I could understand. How would I go about fixing it? Looking in the pom.xml file, the only release related thing I could see was the <release>10<\release> but idk what to change that to if that is the problem. I'm assuming I have to change things in the file to fit what versions of java and maven I have but I'm pretty new to the both of them and don't really know what I'm looking for.
[1]https://github.com/redfx-quantum/strange
as always, excuse me if I make a silly query or one that is easily resolved. In a project I'm working on I was asked to find out if it's possible to build two wars from one webapp. This I could solve in the following way:
WebProject
<artifactId>FacturaElectronica</artifactId>
<packaging>war</packaging>
<name>factElectronica - web</name>
<description>This is the web POM file</description>
<groupId>factElectronica-web</groupId>
<version>1.0-SNAPSHOT</version>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
<execution>
<id>facturaelectronicafija</id>
<phase>install</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<classifier>facturaelectronicafija</classifier>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**</include>
</includes>
</resource>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>org.apache.santuario.xmlsec,org.apache.commons.codec,javax.ws.rs.api</Dependencies>
</manifestEntries>
</archive>
</configuration>
</execution>
<execution>
<id>facturaelectronicamovil</id>
<phase>install</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<classifier>facturaelectronicamovil</classifier>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**</include>
</includes>
</resource>
<resource>
<directory>src/main/webappFant</directory>
</resource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>org.apache.santuario.xmlsec,org.apache.commons.codec,javax.ws.rs.api</Dependencies>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java/resources</directory>
</resource>
</resources>
</build>
Each of these war has the same classes but differs in the xhtml files. One points to mobile phone components and the other points to landline phone components.
After doing this, I realized that it was necessary to build an ear for each one of them, each one with its root context and perform the deploy in wildfly. But I can't find the way to do it. On the one hand I don't know how to point to the wars that are built in the execution in the webapp, and on the other hand I don't know if the way is only with one ear for both or it is necessary to build two. I would be very grateful if someone could give me a hand with this. Thank you very much!
Update
Taking the example I found in this link: Maven ear plugin multiple artifacts content
I made the following changes:
WebProject
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>package-facturaelectronicafija</id>
<phase>package</phase>
<configuration>
<classifier>facturaelectronicafija</classifier>
<webappDirectory>${project.build.directory}/${project.build.finalName}-facturaelectronicafija</webappDirectory>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
<execution>
<id>package-facturaelectronicamovil</id>
<phase>package</phase>
<configuration>
<classifier>facturaelectronicamovil</classifier>
<webappDirectory>${project.build.directory}/${project.build.finalName}-facturaelectronicamovil</webappDirectory>
<webResources>
<resource>
<directory>src/main/webappFant</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<finalName>FacturaElectronica</finalName>
</build>
</project>
EarProject
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>factElectronicaWeb-ear</groupId>
<artifactId>factElectronicaWeb-ear</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>facturaelectronicafija</classifier>
<scope>provided</scope>
<type>war</type>
</dependency>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>package-facturaelectronicafija</id>
<phase>package</phase>
<configuration>
<workDirectory>target/facturaelectronicafija</workDirectory>
<classifier>facturaelectronicafija</classifier>
<version>8</version>
<modules>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicafija</classifier>
<contextRoot>/FacturaElectronica</contextRoot>
<bundleFileName>/FacturaElectronica.war</bundleFileName>
</webModule>
</modules>
</configuration>
<goals>
<goal>ear</goal>
</goals>
</execution>
<execution>
<id>package-facturaelectronicamovil</id>
<phase>package</phase>
<configuration>
<workDirectory>target/facturaelectronicamovil</workDirectory>
<classifier>facturaelectronicamovil</classifier>
<version>8</version>
<modules>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<contextRoot>/FacturaElectronica</contextRoot>
<bundleFileName>/FacturaElectronica.war</bundleFileName>
</webModule>
</modules>
</configuration>
<goals>
<goal>ear</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>FacturaElectronica</finalName>
</build>
</project>
Now the executions are done and maven creates three ears, the first one, which is called "FacturaElectronica" I created it to test that it actually works. The problem is that the three ears have exactly the same content as "FacturaElectronica". I think it is because maven does not find the dependence towards "facturaelectronicafija" and "facturaelectronicafija". Maybe because when I create these WARs in executions I can't add a version to them. Somebody could clarify me this please? Thank you very much!
I would create a multi-module project where each WAR and each EAR are separate modules.
The classes would be a JAR module that is used in the two WAR modules
I had to make some corrections, but I managed to leave it working as expected.
WebProject
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
<execution>
<id>package-facturaelectronicafija</id>
<phase>package</phase>
<configuration>
<classifier>facturaelectronicafija</classifier>
<webappDirectory>${project.build.directory}/${project.build.finalName}-facturaelectronicafija</webappDirectory>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
<execution>
<id>package-facturaelectronicamovil</id>
<phase>package</phase>
<configuration>
<classifier>facturaelectronicamovil</classifier>
<webappDirectory>${project.build.directory}/${project.build.finalName}-facturaelectronicamovil</webappDirectory>
<webResources>
<resource>
<directory>src/main/webappFant</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<finalName>FacturaElectronica</finalName>
</build>
The default install run is there so that the default war base is not created.
EarProject
<modelVersion>4.0.0</modelVersion>
<groupId>factElectronicaWeb-ear</groupId>
<artifactId>factElectronicaWeb-ear</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>facturaelectronicafija</classifier>
<scope>compile</scope>
<type>war</type>
</dependency>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>default-ear</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
<execution>
<id>package-facturaelectronicafija</id>
<phase>package</phase>
<configuration>
<workDirectory>target/facturaelectronicafija</workDirectory>
<classifier>facturaelectronicafija</classifier>
<version>8</version>
<modules>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicafija</classifier>
<contextRoot>/FacturaElectronica</contextRoot>
<bundleFileName>/FacturaElectronica-facturaelectronicafija.war</bundleFileName>
</webModule>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<excluded>true</excluded>
</webModule>
</modules>
</configuration>
<goals>
<goal>ear</goal>
</goals>
</execution>
<execution>
<id>package-facturaelectronicamovil</id>
<phase>package</phase>
<configuration>
<workDirectory>target/facturaelectronicamovil</workDirectory>
<classifier>facturaelectronicamovil</classifier>
<version>8</version>
<modules>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<contextRoot>/DetalleFactura</contextRoot>
<bundleFileName>/FacturaElectronica-facturaelectronicamovil.war</bundleFileName>
</webModule>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicafija</classifier>
<excluded>true</excluded>
</webModule>
</modules>
</configuration>
<goals>
<goal>ear</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>FacturaElectronica</finalName>
</build>
Previously the dependencies generated only a meta inf file, this was because they were with a scope provided, when you switch to compile it works correctly.
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
<type>war</type>
</dependency>
I am trying to get sonar report for one of my project.
I have run mvn clean install
Running blah.blah.BlahTest1
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running blah.blah.BlahTest2
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.078 sec
When I run mvn sonar:sonar I get the bellow error.
[INFO] ------------------------------------------------------------------------
[INFO] Building Component name
[INFO] task-segment: [org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test]
[INFO] ------------------------------------------------------------------------
[INFO] [surefire:test {execution: default-cli}]
[INFO] Surefire report directory: D:\CodeBase\Project\module\target\surefire-reports
java.lang.NoClassDefFoundError: null
Caused by: java.lang.ClassNotFoundException: null
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: null. Program will exit.
Exception in thread "main"
[ERROR] There are test failures.
I am not sure where to start looking to. I tried searching in google couldn't find anything similar to my issue.
Please help me in understanding which can be a possible cause to look for.
Thanks.
Adding pom file : Removed few details to shorten the file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--============================================================= -->
<!--The Basics -->
<!--============================================================= -->
<groupId>###</groupId>
<artifactId>###</artifactId>
<packaging>pom</packaging>
<version>###</version>
<url>###</url>
<!--============================================================= -->
<!--Project Information -->
<!--============================================================= -->
<!--============================================================= -->
<!--Properties -->
<!--============================================================= -->
<properties>
<!--general properties -->
<svn-base-url>###</svn-base-url>
<!--versions of 3rd party libraries -->
<!--plug in versions -->
<version.jacoco.plugin>0.7.4.201502262128</version.jacoco.plugin>
</properties>
<scm>
</scm>
<!--============================================================= -->
<!--Modules -->
<!--============================================================= -->
<modules>
</modules>
<!--============================================================= -->
<!--Distribution Management -->
<!--============================================================= -->
<distributionManagement>
</distributionManagement>
<!--============================================================= -->
<!--Plugin Repository -->
<!--============================================================= -->
<pluginRepositories>
</pluginRepositories>
<!--============================================================= -->
<!--Dependency Management -->
<!--============================================================= -->
<dependencyManagement>
<!--3rd part libraries -->
</dependencyManagement>
<!--============================================================= -->
<!--Dependencies -->
<!--============================================================= -->
<dependencies>
</dependencies>
<!--============================================================= -->
<!--Build Information -->
<!--============================================================= -->
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*</exclude>
</excludes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${version.clean.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<compilerArgument>-Xlint:-serial -Xmaxwarns 9999 -Xmaxerrs 9999</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${version.jacoco.plugin}</version>
<configuration>
<append>true</append>
<destFile>target/coverage-reports/jacoco-unit.exec</destFile>
<dataFile>target/coverage-reports/jacoco-unit.exec</dataFile>
<includes>
<include>path</include>
</includes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${version.enforcer.plugin}</version>
<configuration>
<rules>
<requireJavaVersion>
<version>1.6</version>
</requireJavaVersion>
<requireMavenVersion>
<version>2.2.0</version>
</requireMavenVersion>
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>${version.versions.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${version.assembly.plugin}</version>
<configuration>
<descriptors>
<!-- descriptors -->
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${version.release.plugin}</version>
<configuration>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${version.resources.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${version.install.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${version.site.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>${version.jxr.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${version.cobertura.plugin}</version>
<configuration>
<formats>
<format>xml</format>
</formats>
<instrumentation>
<!--Include and exclude -->
</instrumentation>
<maxmem>512M</maxmem>
</configuration>
<executions>
<execution>
<id>clean</id>
<phase>pre-site</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>instrument</id>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${version.pmd.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${version.findbugs.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${version.checkstyle.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dashboard-maven-plugin</artifactId>
<version>${version.dashboard.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${version.buildhelper.plugin}</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>${version.jaxb2.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<version>${version.taglist.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changelog-plugin</artifactId>
<version>${version.changelog.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.2</version>
<configuration>
<connectionType>developerConnection</connectionType>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${version.jar.plugin}</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${version.exec-maven.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${version.antrun.plugin}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>remove-project-artifact</id>
<phase>clean</phase>
<goals>
<goal>remove-project-artifact</goal>
</goals>
<configuration>
<removeAll>false</removeAll>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<!-- Need the argLine in the configuration here otherwise jacoco hook into surefire correctly for unit test coverage -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>${argLine} -XX:MaxPermSize=256M -Xmx892M -client</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm not a Maven expert, though but, I have implementation wherein, during the maven lifecycle, I execute some of the JUnits to find the Code Coverage and Sonar, of course. I'm attaching my pom. Maybe this helps.
<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>
<!-- Project Parent POM -->
<parent>
<groupId>XXX</groupId>
<artifactId>XXX</artifactId>
<version>2.0</version>
</parent>
<!-- Artifacts for the WAR -->
<groupId>XXX</groupId>
<artifactId>XXX</artifactId>
<packaging>war</packaging>
<version>0.1</version>
<name>XXX</name>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.5.3.201107060350</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
...
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<destFile>${sonar.jacoco.itReportPath}</destFile>
</configuration>
<executions>
<execution>
<id>pre-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
<configuration>
<argLine>
${argLine} -DAdditional Arguments
</argLine>
<includes>
<include>**/TestSuite.java</include>
</includes>
<skipTests>false</skipTests>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--Dependencies -->
</dependencies>
<!-- Properties of the dependencies defined above -->
<properties>
<!-- Versions -->
<!-- Sonar Properties -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.itReportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.language>java</sonar.language>
</properties>
I'm using some plugins to build my maven project.
During the "install" phase, maven create plugin directories inside my target folder, but I don't need them.
There's an option to avoid the creation of this directories that allows me to continue to use those plugins?
In my case are 'maven-archiver' and 'surefire' (that is also empty after the building).
`
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.hopom</groupId>
<artifactId>mytools</artifactId>
<version>1.0</version>
</parent>
<groupId>com.hopom.mytools</groupId>
<artifactId>MyParser</artifactId>
<version>1.0</version>
<name>MyParser</name>
<url>http://maven.apache.org/MyParser</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>zxing</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>zxing-javase</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>1.7.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>jempbox</artifactId>
<version>1.7.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
<version>1.7.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle.bcprov</groupId>
<artifactId>bcprov</artifactId>
<version>jdk15on-147</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>/home/michele/workspace/Migration/mytools/MyParser/src/main/java</sourceDirectory>
<scriptSourceDirectory>/home/michele/workspace/Migration/mytools/MyParser/src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>/home/michele/workspace/Migration/mytools/MyParser/src/test/java</testSourceDirectory>
<outputDirectory>/home/michele/workspace/Migration/mytools/MyParser/target/classes</outputDirectory>
<testOutputDirectory>/home/michele/workspace/Migration/mytools/MyParser/target/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>/home/michele/workspace/Migration/mytools/MyParser/src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>/home/michele/workspace/Migration/mytools/MyParser/src/test/resources</directory>
</testResource>
</testResources>
<directory>/home/michele/workspace/Migration/mytools/MyParser/target</directory>
<finalName>MyParser-1.0</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
<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.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>parser.MyParser</mainClass>
</manifest>
</archive>
<finalName>MyParser</finalName>
</configuration>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>parser.MyParser</mainClass>
</manifest>
</archive>
<finalName>MyParser</finalName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>/home/michele/workspace/Migration/mytools/MyParser/target/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>/home/michele/workspace/Migration/mytools/MyParser/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>/home/michele/workspace/Migration/mytools/MyParser/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>/home/michele/workspace/Migration/mytools/MyParser/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>/home/michele/workspace/Migration/mytools/MyParser/target/site</outputDirectory>
</reporting>
</project>`
those directories (surefire & maven-archiver) gets generated by surefire and archiver plugin respectively
when you do mvn clean install it goes through following phases
validate, clean, compile, test, package, install
these two plugin are by default tied to
phases surefire - > test
and
archiver -> package
so those plugins gets executed and that generates these directories, if you don't want their execution you can skip sure-fire's execution that will stop running any test cases by configuring your pom.xml following way
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
to stop export of test result you can either set it to output to some other directory by setting reportsDirectory property or you can stop generating xml reports using disableXmlReports property
Mention exclude directories inside pom.xml file
Inside exclude tags mention your files which you dont want.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>default-clean</id>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>target</directory>
<excludes>
<exclude></exclude>
</excludes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
I have tried to add a goal to my maven lifecycle with the following pom part. I defined a new plugin and configured it with phase and execute information.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<includes>**/entity/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<connectionDriverName>com.ibm.db2.jcc.DB2Driver</connectionDriverName>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<sqlFile>${project.build.directory}/database.sql</sqlFile>
</configuration>
<executions>
<execution>
<id>sql</id>
<phase>generate-resources</phase>
<goals>
<goal>sql</goal>
</goals>
</execution>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
Then I run maven with mvn:install But the plugin is not run?
Make sure that there is a dependency on the plugin and that the plugin is in build/plugin not build/pluginmanagement/plugin.
Try with something like this:
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<includes>**/entity/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<connectionDriverName>com.ibm.db2.jcc.DB2Driver</connectionDriverName>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<sqlFile>${project.build.directory}/database.sql</sqlFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<executions>
<execution>
<id>sql</id>
<phase>generate-resources</phase>
<goals>
<goal>sql</goal>
</goals>
</execution>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
pluginManagement is supposed to configure plugin, which is invoked at command line.
If you want to bind plugin to some execution phase - simply move it into build->plugins section of your pom.xml