Description
I would like to automatically generate and deploy to nexus the javadocs of my projects at the same time of the library itself by a mvn clean deploy.
First try
The example i've found, generate the javadoc during the default phase (package) with this POM extract :
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
This isn't perfect for me because it consume time even for a simple mvn clean install.
Current status
My idea was to specify the deploy phase en the execution :
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>deploy</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
But the matter is that the deploy is done before the javadocs generation, so nexus receive only the library...
And if I force the deploy:deploy phase to be executed after the javadoc phase, I have 2 deploy phase , the first one that send only lib and the second one that can send lib+javadoc because lib is already sent.
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>deploy</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- explicitly define maven-deploy-plugin after other to force exec order -->
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Extract of the builds (SNAPSHOT Vs RELEASE) :
(...)
--- maven-deploy-plugin:2.7:deploy (default-deploy) # lib ---
Downloading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Downloaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (758 B at 5.2 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.jar
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.jar (4 KB at 24.0 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.pom
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.pom (10 KB at 135.3 KB/sec)
Downloading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml
Downloaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml (482 B at 27.7 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (758 B at 13.2 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml (482 B at 10.0 KB/sec)
(...)
--- maven-javadoc-plugin:2.9.1:jar (attach-javadocs) # lib ---
Loading source files for package lib...
(...)
SNAPSHOT : No problem of uploading 2 times a snapshot
--- maven-deploy-plugin:2.7:deploy (deploy) # lib ---
Downloading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Downloaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (758 B at 37.0 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.jar
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.jar (4 KB at 68.6 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.pom
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3.pom (10 KB at 177.1 KB/sec)
Downloading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml
Downloaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml (482 B at 33.6 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (758 B at 11.2 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/maven-metadata.xml (482 B at 13.8 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3-javadoc.jar
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/lib-1.4-20140804.085407-3-javadoc.jar (35 KB at 581.3 KB/sec)
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml
Uploaded: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4-SNAPSHOT/maven-metadata.xml (2 KB at 28.9 KB/sec)
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 7.342 s
Finished at: 2014-08-04T10:54:10+01:00
Final Memory: 36M/449M
------------------------------------------------------------------------
RELEASE : redeploy not allowed
--- maven-deploy-plugin:2.7:deploy (deploy) # lib ---
Uploading: Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4/lib-1.4.jar
Uploading: http://poc-nexus/content/repositories/poc-repo/poc/release/lib/1.4/lib-1.4.pom
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 4.403 s
Finished at: 2014-08-01T15:25:11+01:00
Final Memory: 24M/437M
------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (deploy) on project lib: Failed to deploy artifacts: Could not transfer artifact poc.release:lib:jar:1.4 from/to poc-repo (http://poc-nexus/content/repositories/poc-repo/): Failed to transfer file: http://poc-nexus/1.4/lib-1.4.jar. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
How can I do this without having to create a specific build profile ?
Thks.
I couldn't manage to reorder the default execution of the deploy plugin after the javadoc plugin. But, you can skip the default execution, wich is useful because the non default execution respects the order in the POM.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<id>release</id>
<phase>deploy</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
<id>release</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
Extract of the build:
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) # AutoridadCertificanteHiba ---
[INFO] Skipping artifact deployment
[INFO]
[INFO] --- maven-javadoc-plugin:2.10.3:jar (release) # AutoridadCertificanteHiba ---
[INFO]
[INFO] Building jar: /home/daniel/svnroot/firmaDigitalChrome/AutoridadCertificanteHiba/target/checkout/target/AutoridadCertificanteHiba-1.0.2-javadoc.jar
[INFO]
[INFO] --- maven-deploy-plugin:2.8.2:deploy (release) # AutoridadCertificanteHiba ---
Uploading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2.jar
Uploaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2.jar (45 KB at 27.8 KB/sec)
Uploading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2.pom
Uploaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2.pom (13 KB at 18.4 KB/sec)
Downloading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/maven-metadata.xml
Downloaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/maven-metadata.xml (379 B at 2.3 KB/sec)
Uploading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/maven-metadata.xml
Uploaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/maven-metadata.xml (409 B at 1.2 KB/sec)
Uploading: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2-javadoc.jar
Uploaded: http://svn.hospitalitaliano.net:8080/archiva/repository/discomun-lib-releases/ar/org/hiba/dis/AutoridadCertificanteHiba/1.0.2/AutoridadCertificanteHiba-1.0.2-javadoc.jar (46 KB at 36.1 KB/sec)
Related
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
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>
Context:
I am trying to do a simple build (not through a pipeline job) on a maven project through Jenkins which is installed in an offline environment (no internet connection). The build happens successfully and I see the HelloMaven.jar successfully deployed to JFrog artifactory which is again installed offline.
Problem:
But the overall Jenkins build fails with the reason
"Build Step:Deploy artifacts to Maven Repository changed build result to FAILURE"
The Jenkins build console output is mentioned as below:
Started by user admin
Building in workspace C:\Users\dipakrai\.jenkins\workspace\HelloMaven
Updating https://myownlaptop/svn/HelloMavenDemo/HelloMaven at revision '2017-07-13T11:51:44.844 +0530'
Using sole credentials admin/****** (SVN) in realm <https://myownlaptop.com:443> VisualSVN Server
At revision 6
No changes for https://myownlaptop.com/svn/HelloMavenDemo/HelloMaven since the previous build
Parsing POMs
Established TCP socket on 62532
[HelloMaven] $ "C:\Program Files\Java\jdk1.8.0_65/bin/java" -cp "C:\Users\dipakrai\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-agent-1.11.jar;C:\Program Files\Apache Software Foundation\apache-maven-3.0.3\boot\plexus-classworlds-2.4.jar" org.jvnet.hudson.maven3.agent.Maven3Main "C:\Program Files\Apache Software Foundation\apache-maven-3.0.3" C:\Users\dipakrai\.jenkins\war\WEB-INF\lib\remoting-3.7.jar C:\Users\dipakrai\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-1.11.jar C:\Users\dipakrai\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.11.jar 62532
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\Users\dipakrai\.jenkins\workspace\HelloMaven\pom.xml deploy
[INFO] Scanning for projects...
[HUDSON] Collecting dependencies info
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloMaven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- buildnumber-maven-plugin:1.3:create (default) # HelloMaven ---
[INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
[INFO] Working directory: C:\Users\dipakrai\.jenkins\workspace\HelloMaven
[INFO] Storing buildNumber: null at timestamp: 1499926911471
[INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
[INFO] Working directory: C:\Users\dipakrai\.jenkins\workspace\HelloMaven
[INFO] Storing buildScmBranch: UNKNOWN_BRANCH
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # HelloMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # HelloMaven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) # HelloMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\dipakrai\.jenkins\workspace\HelloMaven\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # HelloMaven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) # HelloMaven ---
[INFO] No tests to run.
[INFO] Surefire report directory: C:\Users\dipakrai\.jenkins\workspace\HelloMaven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) # HelloMaven ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) # HelloMaven ---
[INFO] Installing C:\Users\dipakrai\.jenkins\workspace\HelloMaven\target\HelloMaven.jar to C:\Users\dipakrai\.m2\repository\net\roseindia\maven\quickstart\HelloMaven\1.0-SNAPSHOT\HelloMaven-1.0-SNAPSHOT.jar
[INFO] Installing C:\Users\dipakrai\.jenkins\workspace\HelloMaven\pom.xml to C:\Users\dipakrai\.m2\repository\net\roseindia\maven\quickstart\HelloMaven\1.0-SNAPSHOT\HelloMaven-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # HelloMaven ---
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar (4 KB at 18.4 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.pom
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.pom (4 KB at 8.6 KB/sec)
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml (784 B at 16.3 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml (298 B at 1.5 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.064s
[INFO] Finished at: Thu Jul 13 11:51:55 IST 2017
[INFO] Final Memory: 15M/247M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving C:\Users\dipakrai\.jenkins\workspace\HelloMaven\pom.xml to net.roseindia.maven.quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-SNAPSHOT.pom
[JENKINS] Archiving C:\Users\dipakrai\.jenkins\workspace\HelloMaven\target\HelloMaven.jar to net.roseindia.maven.quickstart/HelloMaven/1.0-20170713.062154-1/HelloMaven-1.0-20170713.062154-1.jar
Used promoter class: org.jenkinsci.plugins.artifactpromotion.NexusOSSPromotor
channel stopped
Local repository path: [C:\Users\dipakrai\.jenkins\workspace\HelloMaven\target\local-repo]
Started with promotion
Get Artifact and corresponding POM
Checking if POM already exists in releaserepo
POM doesn't exist in release repo, it will be deployed
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
##################################################]
Downloaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml ( at 31.9 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.055434-15.jar
##################################################]
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.055434-15.jar ( at 17.5 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.055434-15.pom
##################################################]
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.055434-15.pom ( at 9.3 KB/sec)
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml
##################################################]
Downloaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml ( at 7.3 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
##################################################]
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml ( at 10.5 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml
##################################################]
Uploaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/maven-metadata.xml ( at 2.1 KB/sec)
Skipping deletion of artifact from source repo as requested by user
Maven RedeployPublisher use remote maven settings from : C:\Users\dipakrai/.m2/settings.xml
[INFO] Deployment in http://localhost:8081/artifactory/repo1 (id=ArtifactID,uniqueVersion=true)
Deploying the main artifact HelloMaven-1.0-20170713.062154-1.jar
Downloading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/maven-metadata.xml (787 B at 1.9 KB/sec)
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar
Uploading: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.pom
ERROR: Failed to deploy artifacts: Could not transfer artifact net.roseindia.maven.quickstart:HelloMaven:jar:1.0-20170713.062154-1 from/to ArtifactID (http://localhost:8081/artifactory/repo1): Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact net.roseindia.maven.quickstart:HelloMaven:jar:1.0-20170713.062154-1 from/to ArtifactID (http://localhost:8081/artifactory/repo1): Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:193)
at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:176)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1072)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:621)
at hudson.model.Run.execute(Run.java:1760)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact net.roseindia.maven.quickstart:HelloMaven:jar:1.0-20170713.062154-1 from/to ArtifactID (http://localhost:8081/artifactory/repo1): Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:317)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:245)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:420)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
... 11 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact net.roseindia.maven.quickstart:HelloMaven:jar:1.0-20170713.062154-1 from/to ArtifactID (http://localhost:8081/artifactory/repo1): Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.put(BasicRepositoryConnector.java:274)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:311)
... 14 more
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://localhost:8081/artifactory/repo1/net/roseindia/maven/quickstart/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-20170713.062154-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:631)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:553)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:535)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:529)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:509)
at org.eclipse.aether.transport.wagon.WagonTransporter$PutTaskRunner.run(WagonTransporter.java:644)
at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
at org.eclipse.aether.transport.wagon.WagonTransporter.put(WagonTransporter.java:410)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PutTaskRunner.runTask(BasicRepositoryConnector.java:510)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
... 16 more
[INFO] Deployment failed after 0.55 sec
Build step 'Deploy artifacts to Maven repository' changed build result to FAILURE
Finished: FAILURE
The pom.xml file entry for my HelloMaven project is as 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.roseindia.maven.quickstart</groupId>
<artifactId>HelloMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>HelloMaven</name>
<scm>
<connection>scm:svn:https://mylaptop/svn/myRepo/</connection>
</scm>
<build>
<finalName>HelloMaven</finalName>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<outputDirectory>${project.basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<archive>
<manifestEntries>
<SCM-Revision>${buildNumber}</SCM-Revision>
</manifestEntries>
</archive>
<webResources>
<resource>
<directory>${project.build.directory}/${project.build.finalName}</directory>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>-->
<distributionManagement>
<repository>
<id>artifactory</id>
<name>HelloMaven-release</name>
<url>http://localhost:8081/artifactory/repo1</url>
</repository>
</distributionManagement>
</project>
The settings.xml file for MAVEN m2 folder is as below:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--<localRepository>C:\Users\dipakrai\.m2\repository</localRepository>-->
<pluginGroups>
<!-- Nothing is present now-->
</pluginGroups>
<proxies>
<!-- Nothing is present now-->
</proxies>
<servers>
<server>
<username>admin</username>
<password>{v2akWC7LO8QHuoPFXESAScpHLzTFzcIKG054oyvz/nc=}</password>
<id>central</id>
</server>
<server>
<username>admin</username>
<password>{v2akWC7LO8QHuoPFXESAScpHLzTFzcIKG054oyvz/nc=}</password>
<id>snapshots</id>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<url>http://localhost:8081/artifactory/repo1</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>artifadeploymentRepoctory</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>HelloMaven-release</name>
<url>http://localhost:8081/artifactory/repo1</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>HelloMaven-snapshot</name>
<url>http://localhost:8081/artifactory/repo1</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
For the last four days I have taken trying to fix the issue and went through a number of posts as this Infrastructure with maven, Jenkins, Nexus. I am not sure where I am going wrong.
Any clue would be extremely grateful.
The answer above by #VonC helped me to fix the issue. The server id I have entered in the settings.xml file and the Jenkins artifactory configuration is a mismatch.
I made the following changes as listed below.
First, I updated my Jenkins artifactory configuration as shown below. The REPOSITORY ID musty exactly match the server id mentioned in the settings.xml file:
<server>
<username>admin</username>
<password>AP447H6DXXJW6WW54BvNBorau5s</password>
<id>artifactory</id>
</server>
And also the repository id entry further below in the settings.xml file must be the same as server id above:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>artifactory</id>
<name>myproject-release</name>
<url>http://localhost:8081/artifactory/repo2</url>
</repository>
Secondly, though I haven't tested this explicitly but it must be that way:
The entry in the project pom.xml file should also be having the same id for repository where the distribution binary has to be released (in this case, the artifactory).
<distributionManagement>
<repository>
<id>artifactory</id>
<name>HelloMaven-release</name>
<url>http://localhost:8081/artifactory/repo1</url>
</repository>
</distributionManagement>
Alternatively, since you would have integrated the JFrog artifactory with Jenkins you need not configure the "Deploy artifacts to Maven repository". Instead the below configuration as shown in the screen-shot would deploy your project artifact to the artifactory.
"Deploy artifact to artifactory"
Check what mvn help:effective-settings returns in order to double-check your user/password is indeed used.
Double check the username/password match the ones displayed here, where Atifactory generates the encrypted password.
Finally, following this post, avoid "central" as an id.
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.
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.