Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy zip file to Nexus repository via Maven

Tags:

xml

maven

nexus

I have a zip file which I want to deploy to a Nexus repository. So I created a pom.xml file and a settings.xml file to do this. I was able to successfully upload to nexus but it seems it was deployed as a jar file

When I put in <packaging>zip</packaging> element, maven doesn't recognize it. How can I accomplish my goal of deploying my zip file to nexus? Any help will be greatly appreciated.

Contents of directory: 1. content.zip 2. pom file 3. settings file

pom.xml:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company.ct.ty16.archive</groupId>
    <artifactId>contentzip</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Deploy-zip-file</name>
    <description>Deploy zipped content file on Jenkins to Nexus</description>
    ...
    ...
    ...
    </project>

Note: I am not using maven to build the content.zip file, just upload it

like image 712
barthelonafan Avatar asked Sep 15 '25 10:09

barthelonafan


1 Answers

Define your server in the settings.xml

<servers>
  ...
  <server>
    <id>server-snapshots</id>
    <username>server-snapshots-username</username>
    <password>server-snapshots-password</password>
  </server>
  ...
</servers>

Define deploy-file configuration for deploy phase

<plugin>
  <artifactId>maven-deploy-plugin</artifactId>
  <executions>
    <execution>
      <id>deploy-file</id>
      <phase>deploy</phase>
      <goals>
        <goal>deploy-file</goal>
      </goals>
      <configuration>
        <file>${project.build.directory}/${project.artifactId}-${project.version}.zip</file>
        <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
        <url>${project.distributionManagement.snapshotRepository.url}</url>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <packaging>zip</packaging>
      </configuration>
    </execution>
  </executions>
</plugin>

Define the snapshotRepository

<distributionManagement>
  <snapshotRepository>
    <id>server-snapshots</id>
    <name>Snapshots repository (snapshots)</name>
    <url>http://repository.com/repo/server-snapshots</url>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </snapshotRepository>
</distributionManagement>

Execute mvn deploy

like image 62
Romain DEQUIDT Avatar answered Sep 17 '25 09:09

Romain DEQUIDT