How to deploy only zip artifacts in maven

I did some zip packaging in maven using the following descriptor and pom file. But in maven by default, he created jar and zip in the target folder. Now I want to deploy only zip content, where I use deploy: deploy-file plugin. but it does not deploy, but shows an error. Not sure what is wrong with the tag and how to resolve it.

Pom File:

<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.wyndhamvo.prototype.dbscripts</groupId> <artifactId>DB_SCRIPTS</artifactId> <version>2.0.0.1</version> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptor>src/assembly/descriptor.xml</descriptor> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <distributionManagement> <snapshotRepository> <id>wvoNexus</id> <file>${project.artifactId}-${project.version}.zip</file> <url>http://nexus.corproot.com/nexus/content/repositories/snapshots/</url> </snapshotRepository> <repository> <id>wvoNexus</id> <file>${project.artifactId}-${project.version}.zip</file> <url>http://nexus.corproot.com/nexus/content/repositories/releases/</url> </repository> </distributionManagement> </project> 

assembly plugin descriptor file:

 <assembly> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <directory>src/main/resources</directory> <includes> <include>**/*</include> </includes> <outputDirectory>DB_Files</outputDirectory> </fileSet> </fileSets> </assembly> 

The executed command:

 mvn -X clean package deploy:deploy-file 

Error:

 [ERROR] Malformed POM C:\Divakar\MavenPrototype\DB_Maven_Test\dev\pom.xml: Unrecognised tag: 'file' (position: START_TAG seen ...<id>wvoNexus</id>\r\n\t\t\t<file>... @37:10) @ C:\Divakar\MavenPrototype\DB_Maven_Test\dev\pom.xml, line 37, column 10 
+6
source share
2 answers

You must first resolve the error in the distribution of control as follows:

  <distributionManagement> <snapshotRepository> <id>wvoNexus</id> <url>http://nexus.corproot.com/nexus/content/repositories/snapshots/</url> </snapshotRepository> <repository> <id>wvoNexus</id> <url>http://nexus.corproot.com/nexus/content/repositories/releases/</url> </repository> </distributionManagement> 

If you fixed that you can simply deploy the files to your link via:

 mvn clean deploy 

If you don’t like having an expanded can, you need to change the type of packaging in your pump, like this:

 <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.wyndhamvo.prototype.dbscripts</groupId> <artifactId>DB_SCRIPTS</artifactId> <version>2.0.0.1</version> <packaging>pom</packaging> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptor>src/assembly/descriptor.xml</descriptor> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 

In addition, I recommend defining the versions of your used plugins as follows:

  <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.4.1</version> <configuration> <descriptor>src/assembly/descriptor.xml</descriptor> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 
+5
source

You made a mistake: the <file/> element is not part of <snapshotRepository/> , it’s a configuration element to deploy the plugin! you should deploy your zip file as follows:

 mvn -X clean package deploy:deploy-file -Dfile=/path/to/your-artifact-1.0.zip 
0
source

Source: https://habr.com/ru/post/974199/


All Articles