I have some third party jars that I want to upload to my nexus maven repo, and so far I have found two ways to do it.
- Use the Nexus GUI
- Use the instructions at http://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html
mvn deploy:deploy-file -DgroupId=<group-id> \
-DartifactId=<artifact-id> \
-Dversion=<version> \
-Dpackaging=<type-of-packaging> \
-Dfile=<path-to-file> \
-DrepositoryId=<id-to-map-on-server-section-of-settings.xml> \
-Durl=<url-of-the-repository-to-deploy>
I am expecting the 3rd party libraries to updated frequently say about once a quarter possibly more whenver there are security updates / releases.
Both of the two approaches above are manual you have to type a longish command or click around to make it happen. I would prefer a simple solution that is not product specific or requires lengthy command line options.
Is it possible to write a maven pom.xml that publishes a 3rd party .tar.gz just by doing mvn deploy
I am using maven 3.0.5
UPDATE Sample pom.xml that worked for me based on radai answer below.
we have a similar need here with keeping tabs of non-maven artifacts and updating them in our nexus.
the way we did it is to have a "thirdparty" project in version control which stores the non-maven artifacts, each with its own pom file.
when you upgrade any 3rd party you overwrite the old one in the thirdparty project, bunp the version in the associated pom file and run "mvn deploy"
to put it into our repository.
a pom file for a "build" that results in a *.tar.gz will have a pom like this:
<?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>
<artifactId>myArtifact</artifactId>
<packaging>pom</packaging> <!-- so it wont auto-create any *.jars or anything -->
<build>
<resources>
<resource>
<!-- put a configuration here to copy your artifact to /target -->
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy static resource files</id>
<goals>
<goal>resources</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
<plugin>
<!-- this creates your *.tar.gz -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>Create final ZIP package</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>platform-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
with an seembly descriptor alongside it:
this one packages a bunch of stuff as *.tar.gz, retaining executable flags for *.sh files. you will need to edit to fit your needs
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>${envClassifier}</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>yourTargetDir</directory>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>**/*.sh</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>yourTargetDir</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/*.sh</include>
</includes>
<fileMode>755</fileMode>
</fileSet>
</fileSets>
</assembly>
EDIT:
if you dont need to extract/mess-with/ the *.tar.gz artifact that you have a much simpler option - use the build helper maven plugin's attach artifact goal to simply attach your *.tar.gz to be included in deployments/installs
you obviously then need to update all of the paces that depend on this new artifact version.
Here is the pom.xml I used to solve my problem based on radai suggestion to use the build helper plugin
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.thirdparty</groupId>
<artifactId>server-jre</artifactId>
<version>7.25</version>
<packaging>pom</packaging>
<distributionManagement>
<repository>
<id>thirdparty</id>
<url>http://localhost:8082/nexus/content/repositories/thirdparty/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>files/server-jre-7u25-linux-x64.tar.gz</file>
<type>tar.gz</type>
<classifier>linux-x64</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>