I have the following plugins for creating a -sources.jar
and deploying a specific named jar to a repository.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<configuration>
<version>${project.version}-r${buildNumber}</version>
<classifier>${env}</classifier>
<packaging>jar</packaging>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
<url>${artifactory.url}/libs-release-local</url>
<repositoryId>artifactory.digiterre.com</repositoryId>
<pomFile>${project.basedir}/pom.xml</pomFile>
</configuration>
</plugin>
I wish to deploy the *-sources.jar
at the same time. I have tried adding a second file entry and even a second deploy plugin. I seem to get one or other file deployed.
Is it possible to deploy both in one pass using deploy:deploy-file
or will I have to set up a second team city build just to deploy the sources?
To deploy a 3rd party JAR use the deploy:deploy-file goal under maven-deploy-plugin. First, the wagon-provider(wagon-ftp, wagon-file, etc..) must be placed to your ${maven. home}/lib .
To run a jar: java -jar server. jar. You have to copy the jar file to the server and run it. In case it's a web application you have to publish the war or ear.
When you use maven-source-plugin
, the generated jar will automatically attach to project artifact (default setting for this parameter is 'true') and if you execute deploy
it will be deployed along with it. Alas, no need for separate configuration of deploy plugin.
Unfortunately, you cannot add classifier (${env}
in your case) to sources jar. That is why I'd use the following configuration:
...
<artifactId>com.pie.mash.repo.mince-${env}</artifactId>
<version>1.18-r${buildNumber}</version>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Also, I've found this question on SO. You can use the workaround suggested there.
We can use deploy:deploy-file
to upload multiple JARs (sources, tests, docs) along side main JAR artifact. We just need to supply that additional piece of information to deploy:deploy-file
plugin call. The additions are indicated in bold in below command:
mvn deploy:deploy-file
-Dfile=helloWorld.jar
-Durl=https://localhost/nexus/content/repositories/snapshots/
-DrepositoryId=snapshot
-Dfiles=helloWorld-6.4.1.3.SNAPSHOT-sources.jar,helloWorld-6.4.1.3.SNAPSHOT-tests.jar
-Dtypes=jar,jar -Dclassifiers=sources,tests
-DgroupId=com
-DartifactId=helloWorld
-Dversion=6.4.1.3.SNAPSHOT
-Dpackaging=jar
-Dpomfile=pom.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With