Maven 3.0.3 package is not working - maven-3

Hi I have a mvn sub module whose sole purpose is to collect jar's from various other module and create a zip file with all dependencies and configurations.
<parent>
<artifactId>foo</artifactId>
<groupId>com.foo</groupId>
<version>0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dist</artifactId>
<packaging>pom</packaging>
<name>dist</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>generate zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Now if I use mvn assembly:assembly it creates the desired zip file. But if I use mvn package it doesn't do any thing i.e. its not creating the zip file. Just gives below output and finishes.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building dist 0.1
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.120s
[INFO] Finished at: Mon Jul 15 16:34:09 IST 2013
[INFO] Final Memory: 5M/92M
[INFO] ------------------------------------------------------------------------
Any idea on why this is not working. What is that I am missing here.
Thanks for all the help in advance.

As Robert mentioned you have to move out your plugin from plugin-management. Try something like this
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>generate zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Hope this helps

That's not how pluginManagement works. You should define at least as a standard build-plugin.
During a lifecycle, Maven will use its default and it goes through the build-plugins to see if there's a plugin bound to a phase. If it finds a plugin, it will look at the pluginManagement for the same plugin to see if there are some additional configurations.

Related

How to generate both jacoco and scoverage reports with maven in a single jenkins job

I have a multi-module project with java and scala. Both jacoco and scoverage plugins are installed in Jenkins and I want to generate jacoco and scoverage reports (both) in a single build job in Jenkins but only one report is getting generated, either jacoco or scoverage.
Below mvn commands tried so far -
mvn -B -s $MVN_SETTINGS jacoco:prepare-agent install scoverage:report jacoco:report
and
mvn -B -s $MVN_SETTINGS jacoco:prepare-agent install jacoco:report scoverage:report
The snippet of my pom file -
Plugins section -
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<destFile>./target/jacoco.exec</destFile>
<append>true</append>
</configuration>
<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>
</executions>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<scalaVersion>2.10.4</scalaVersion>
<highlighting>true</highlighting>
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
Reporting section -
<reporting>
<outputDirectory>${project.build.directory}/site</outputDirectory>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
</plugins>
</reporting>
When I use -
mvn -B -s $MVN_SETTINGS jacoco:prepare-agent install scoverage:report jacoco:report
jacoco report gets generated
Build log -
05:30:51 [Compile] [INFO] --- scoverage-maven-plugin:1.3.0:report
(default-cli) # ABC --- 05:30:51 [Compile] [INFO] Reading scoverage
instrumentation
[/workspace/Build-Pipeline/ABC/target/scoverage-data/scoverage.coverage.xml]...
05:30:51 [Compile] [INFO] Reading scoverage measurements
[/workspace/Build-Pipeline/ABC/target/scoverage-data/scoverage.measurements.*]...
05:30:51 [Compile] [INFO] Generating coverage reports... 05:30:51
[Compile] [INFO] Written Cobertura XML report
[/workspace/Build-Pipeline/ABC/target/cobertura.xml] 05:30:52
[Compile] [INFO] Written XML coverage report
[/workspace/Build-Pipeline/ABC/target/scoverage.xml] 05:30:53
[Compile] [INFO] Written HTML coverage report
[/workspace/Build-Pipeline/ABC/target/site/scoverage/index.html]
05:30:53 [Compile] [INFO] Statement coverage.: 0.00% 05:30:53
[Compile] [INFO] Branch coverage....: 0.00% 05:30:53 [Compile] [INFO]
Coverage reports completed.
When I use -
mvn -B -s $MVN_SETTINGS jacoco:prepare-agent install jacoco:report scoverage:report
scoverage report gets generated
Build log -
05:15:07 [Compile] [INFO] --- scoverage-maven-plugin:1.3.0:report
(default-cli) # ABC --- 05:15:07 [Compile] [INFO] Reading scoverage
instrumentation
[/workspace/Build-Pipeline/ABC/target/scoverage-data/scoverage.coverage.xml]...
05:15:07 [Compile] [INFO] Reading scoverage measurements
[/workspace/Build-Pipeline/ABC/target/scoverage-data/scoverage.measurements.*]...
05:15:07 [Compile] [INFO] Generating coverage reports... 05:15:07
[Compile] [INFO] Written Cobertura XML report
[/workspace/Build-Pipeline/ABC/target/cobertura.xml] 05:15:08
[Compile] [INFO] Written XML coverage report
[/workspace/Build-Pipeline/ABC/target/scoverage.xml] 05:15:08
[Compile] [INFO] Written HTML coverage report
[/workspace/Build-Pipeline/ABC/target/site/scoverage/index.html]
05:15:08 [Compile] [INFO] Statement coverage.: 0.00% 05:15:08
[Compile] [INFO] Branch coverage....: 0.00% 05:15:08 [Compile] [INFO]
Coverage reports completed.
Can someone please point me what is going wrong?
Many thanks
Given src/main/java/HelloJava.java
class HelloJava {
public static String msg() {
return "Hello";
}
}
src/main/scala/HelloScala.scala
object HelloScala {
def msg = {
"Hello"
}
}
src/test/java/HelloTest.java
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class HelloTest {
#Test
public void test() {
assertEquals("Hello", HelloJava.msg());
assertEquals("Hello", HelloScala.msg());
}
}
and pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<highlighting>true</highlighting>
</configuration>
</plugin>
</plugins>
</build>
</project>
execution of mvn clean test jacoco:report scoverage:report
will produce target/site/jacoco/index.html
and target/site/scoverage/index.html

Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build Exception caught: basedir src/main/docker does not exist

Deploy Spring Cloud project with docker, some code in the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::plugin[] -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- end::plugin[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
when i run the command: mvn package docker:build, it throws the error:
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.2.RELEASE:repackage (default) # eureka-server ---
[INFO]
[INFO] --- docker-maven-plugin:1.0.0:build (default-cli) # eureka-server ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] Copying /Users/eureka-server/target/eureka-server-0.0.1-SNAPSHOT.jar -> /Users/eureka-server/target/docker/eureka-server-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.728 s
[INFO] Finished at: 2017-11-15T20:51:07+08:00
[INFO] Final Memory: 41M/361M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project eureka-server: Exception caught: basedir src/main/docker does not exist -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
my project has this file src/main/docker, how to solve it?
To add project path to the dockerDirectory:
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::plugin[] -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- end::plugin[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>

Execution order of maven-assembly-plugin and maven-jar-plugin

I have a question regarding the execution order of maven-assembly-plugin and maven-jar-plugin. What I am trying to do is to put together an uberjar file for the pf4j framework (plugin framework for java). For this to be able to do I need to first assemble all the code with dependencies and then package the jar with the manifest file which has some specific entries needed by the pf4j framework.
In the issue "Changing the order of maven plugin execution"
I read in the answer that order of plugins which are bound to the same phase is defined by the order declared in the pom.xml file. Now I have the following pom.xml 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.assembly.test</groupId>
<artifactId>assembly-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<plugin.id>some-plugin</plugin.id>
<plugin.class>org.assembly.test.Main</plugin.class>
<plugin.version>0.0.1</plugin.version>
<plugin.provider>Developers</plugin.provider>
<plugin.dependencies />
</properties>
<build>
<plugins>
<!-- Compiler 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>
</configuration>
</plugin>
<!-- Assembly Plugin -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filters>
<filter>src/main/assembly/filter.properties</filter>
</filters>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classesDirectory>${project.build.directory}/${project.artifactId}-${project.version}-distro</classesDirectory>
<archive>
<manifestEntries>
<Plugin-Id>${plugin.id}</Plugin-Id>
<Plugin-Class>${plugin.class}</Plugin-Class>
<Plugin-Version>${plugin.version}</Plugin-Version>
<Plugin-Provider>${plugin.provider}</Plugin-Provider>
<Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
From the pom.xml file it should be clear that I want to run the maven-jar-plugin after maven-assembly-plugin. But instead I get the following maven output:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.assembly.test:assembly-test:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. # line 82, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building assembly-test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # assembly-test ---
[INFO] Deleting D:\JavaTools\project_btc\projects\assembly-test\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # assembly-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # assembly-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to D:\JavaTools\project_btc\projects\assembly-test\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # assembly-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # assembly-test ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # assembly-test ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # assembly-test ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: D:\JavaTools\project_btc\projects\assembly-test\target\assembly-test-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-assembly-plugin:3.0.0:single (make-assembly) # assembly-test ---
[INFO] Reading assembly descriptor: src/main/assembly/assembly.xml
[ERROR] OS=Windows and the assembly descriptor contains a *nix-specific root-relative-reference (starting with slash) /
[INFO] Copying files to D:\JavaTools\project_btc\projects\assembly-test\target\assembly-test-1.0-SNAPSHOT-distro
[WARNING] Assembly file: D:\JavaTools\project_btc\projects\assembly-test\target\assembly-test-1.0-SNAPSHOT-distro is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # assembly-test ---
[INFO] Installing D:\JavaTools\project_btc\projects\assembly-test\target\assembly-test-1.0-SNAPSHOT.jar to D:\JavaTools\maven_repository\org\assembly\test\assembly-test\1.0-SNAPSHOT\assembly-test-1.0-SNAPSHOT.jar
[INFO] Installing D:\JavaTools\project_btc\projects\assembly-test\pom.xml to D:\JavaTools\maven_repository\org\assembly\test\assembly-test\1.0-SNAPSHOT\assembly-test-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.376 s
[INFO] Finished at: 2017-04-04T06:04:11+02:00
[INFO] Final Memory: 21M/168M
[INFO] ------------------------------------------------------------------------
Now from the output it can be seen that maven-jar-plugin is executed before the maven-assembly-plugin, which is not what I wanted. The effect of such an order is a jar file with only MANIFEST_INF content.
Can somebody explain me what am I doing wrong here?
One possible solution is to make pom file in such a way:
<?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>org.assembly.test</groupId>
<artifactId>assembly-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<plugin.id>some-plugin</plugin.id>
<plugin.class>org.assembly.test.Main</plugin.class>
<plugin.version>0.0.1</plugin.version>
<plugin.provider>Developers</plugin.provider>
<plugin.dependencies />
</properties>
<build>
<plugins>
<!-- Compiler 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>
</configuration>
</plugin>
<!-- Assembly Plugin -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filters>
<filter>src/main/assembly/filter.properties</filter>
</filters>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classesDirectory>${project.build.directory}/${project.artifactId}-${project.version}-distro</classesDirectory>
<archive>
<manifest>
<mainClass>org.assembly.test.Main</mainClass>
</manifest>
<manifestEntries>
<Plugin-Id>${plugin.id}</Plugin-Id>
<Plugin-Class>${plugin.class}</Plugin-Class>
<Plugin-Version>${plugin.version}</Plugin-Version>
<Plugin-Provider>${plugin.provider}</Plugin-Provider>
<Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>default-jar</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Here I added execution section to maven-jar-plugin to:
<executions>
<execution>
<id>default-jar</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
It is important to set the id to default-jar, because in this case the default execution is overridden and set the phase to verify for maven-jar-plugin to be executed after maven-assembly-plugin. In case the phase was set to package then maven-jar-plugin was executed before maven-assembly-plugin.

maven-dependency-plugin:unpack Error

I'm trying to extract some .exe files from a dependency jar file and put them under ${project.build.directory}/classes/.
But when I execute:
mvn clean compile dependency:unpack
I get:
Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:unpack (default-cli) on project simple: Either artifact or artifactItems is required -> [Help 1
I have verified that the dependencies are available in my local repository.
In my example pom below I've used junit as an example, but no matter which dependency I list, I get the same error.
pom.xml:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes/externaltools</outputDirectory>
<includes>**/*.txt</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
The issue is due to you cannot use mvn clean compile dependency:unpack and <executions> tags together.
In documentation Maven Depdendency Plugin at the bottom part of the page you can read:
If you intend to configure this mojo for execution on the command line using: mvn dependency:unpack you must not put the configuration inside the executions tag. Your configuration should look like this:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<configuration>
<artifactItems>
<artifactItem>
<groupId>[ groupId ]</groupId>
<artifactId>[ artifactId ]</artifactId>
<version>[ version ]</version>
<type>[ packaging ]</type>
<classifier> [classifier - optional] </classifier>
<overWrite>[ true or false ]</overWrite>
<outputDirectory>[ output directory ]</outputDirectory>
<destFileName>[ filename ]</destFileName>
<includes>[ comma separated list of file filters ]</includes>
<excludes>[ comma separated list of file filters ]</excludes>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
I have tried removing the <execution> tags and works perfectly!

Issues during Soapui and Jenkins integration

I am trying to integrate Soapui open source version 4.5.1 with Maven & then finally trying to make it run from CI.
But unfortunately the test classes are executing fine both from eclipse and command line in local system but fails in CI with this message:
16:58:34 16:58:34,323 INFO [WsdlProject] Loaded project from [file:/var/lib/jenkins/jobs/rps_deals30_unittests_automation_priya/workspace/RPService/src/test/resources/serviceautomation/GService-Deals-Test-soapui-project.xml]
16:58:36 java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
16:58:36 at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:240)
16:58:36 at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:193)
16:58:36 at java.util.jar.JarVerifier.processEntry(JarVerifier.java:262)
16:58:36 at java.util.jar.JarVerifier.update(JarVerifier.java:216)
16:58:36 at java.util.jar.JarFile.initializeVerifier(JarFile.java:411)
16:58:36 at java.util.jar.JarFile.getInputStream(JarFile.java:478)
16:58:36 at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:1003)
...
...
This is the relevant snippet from my pom.xml file:
<plugins>
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>4.5.1</version>
<executions>
<execution>
<phase>verify</phase>
<id>soapui-tests</id>
<configuration>
<projectFile>${project.basedir}/src/test/resources/serviceautomation/GService-Deals-Test-soapui-project.xml</projectFile>
<outputFolder>${basedir}/target/soapui</outputFolder>
<junitReport>true</junitReport>
<exportwAll>true</exportwAll>
<printReport>true</printReport>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration></configuration>
</plugin>
</plugins>
</build>
Not sure where you got that pom configuration from, or what you are trying to do. Using the recommended pom from the the official documentation, you should just have:
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>4.5.1</version>
<configuration>
<projectFile>src/test/resources/serviceautomation/GService-Deals-Test-soapui-project.xml</projectFile>
<outputFolder>target/soapui</outputFolder>
<junitReport>true</junitReport>
<exportwAll>true</exportwAll>
<printReport>true</printReport>
</configuration>
</plugin>
Skip all the executions specific things, that is what causing your problems.

Resources