maven: how to export packed sources with jar in "package" stage - maven

I have a maven export script (that wasn't been written by me) and I would like to add sources coping as well.
the build script generates 2 outputs using the "maven-source-plugin":
.jar and -sources.jar and they are both exist in the same output folder one next to another.
so far only the jar is being copied, I want the script to place the -sources.jar file next to its jar file
the build pom:
<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.mytest</groupId>
<artifactId>my-parent</artifactId>
<version>6.0.00-SNAPSHOT</version>
<packaging>pom</packaging>
<name>my-parent</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<assembly.format>dir</assembly.format>
<my.repository.rootUrl>http://maven.my.com</my.repository.rootUrl>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
.
.
.
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<target>1.6</target>
<source>1.6</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modules>
.
.
.
</modules>
<repositories>
.
.
.
</repositories>
<distributionManagement>
.
.
.
</distributionManagement>
<pluginRepositories>
.
.
.
</pluginRepositories>
<organization>
<name>My</name>
</organization>
<profiles>
<profile>
<id>dist</id>
<modules>
<module>../my-assembly/my-runner</module>
</modules>
</profile>
</profiles>
</project>
the export pom:
<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>
<parent>
<groupId>org.mytest</groupId>
<artifactId>my-parent</artifactId>
<version>6.0.00-SNAPSHOT</version>
<relativePath>../../my-parent</relativePath>
</parent>
<artifactId>my-runner</artifactId>
<dependencies>
.
.
.
</dependencies>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
<id>create-runner</id>
<phase>package</phase>
<configuration>
<finalName>runner</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/runner.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
the runner file (referenced by the export pom):
<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">
<formats>
<format>tar.gz</format>
<format>zip</format>
<format>dir</format>
</formats>
<id>runner</id>
<dependencySets>
.
.
.
<dependencySet>
<outputDirectory>lib</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension} </outputFileNameMapping>
<includes>
<include>org.mytest:*:jar</include>
<include>org.mytest.systemobjects:*:jar</include>
</includes>
<excludes>
<exclude>*:my-services-so:*</exclude>
<exclude>*:my-services-tests:*</exclude>
<exclude>*:my-runner:*</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
.
.
.
</fileSets>
</assembly>
thank you in advance!

From looking at MNG-1994 it seems that in each phase a child's plugins will execute before the parent's.
Your parent POM specifies the source plugin (which generates the sources JAR) in the package phase (this is the source plugin's default phase if not explicitly specified in the execution), but the assembly plugin, which generates the tar.gz, zip and uncompressed finished versions of your project, is run before the source plugin because the assembly plugin is declared in the child and the source plugin is declared in the parent.
A solution can be to change the phase the source plugin runs in to ensure it runs before the assembly plugin, something right before the package phase such as prepare-package will work. (full list of lifecycle phases is here)
In the parent, explicitly setting the phase to prepare-package will make it:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>prepare-package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
This should force the source plugin to execute before the assembly plugin and therefore the assembly plugin should pick up both attached JARs now.

Add another include element with the classifier sources:
<include>org.mytest:*:jar:sources</include>
See the documentation: http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_dependencySet

Related

maven Return code is: 409, ReasonPhrase: Conflict

I have problem to deploy my multi-module python project with following structure
parent pom.xml # common pom for others project
project/
pom.xml # project pom
common_features/
sub-project-1/pom.xml # sub project 1 pom
sub-project-2/pom.xml # sub project 2 pom
For deployment I use maven
Settings.xml
General maven setting use for build
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- others options -->
<servers>
<server>
<id>artifacts-SNAPSHOTS</id>
<username>user</username>
<password>password</password>
</server>
</servers>
<!-- others options -->
</settings>
parent pom.xml
In this case we have the same URL for SNAPSHOT and RELEASE repository
<!-- others options -->
<groupId>com.project.common.group.id</groupId>
<artifactId>project-pom</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<!-- others options -->
<distributionManagement>
<repository>
<id>artifacts-RELEASES</id>
<url>${dist.repository.releases}</url>
</repository>
<snapshotRepository>
<id>artifacts-SNAPSHOTS</id>
<url>${dist.repository.snapshots}</url>
</snapshotRepository>
</distributionManagement>
<!-- others sections-->
<properties>
<dist.repository.releases>${artifacts.repository.url}</dist.repository.releases>
<dist.repository.snapshots>${artifacts.repository.url}</dist.repository.snapshots>
<artifacts.repository.url>https://domain/artifactory/mvn-repo-dev</artifacts.repository.url>
</properties>
project pom.xml
There you can see that project consists two modules
sub-project-1
sub-project-2
Parent is general parent.
Also I sue maven assembly plugin in order to deploy project into artifactory
<!-- anothers options -->
<parent>
<groupId>com.project.common.group.id</groupId>
<artifactId>project-pom</artifactId>
<version>0.0.1</version>
</parent>
<groupId>com.project.group.id</groupId>
<artifactId>project-pom</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>common_features/sub-project-1</module>
<module>common_features/sub-project-2</module>
</modules>
build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>deploy/artifact-description.xml</descriptor>
</descriptors>
<tarLongFileMode>posix</tarLongFileMode>
</configuration>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<publisher>
<contextUrl>https://domain/artifactory</contextUrl>
<repoKey>mvn-repo-dev</repoKey>
<snapshotRepoKey>mvn-repo-dev</snapshotRepoKey>
<publishArtifacts>true</publishArtifacts>
<publishBuildInfo>true</publishBuildInfo>
<username>deployUser</username>
<password>deployPwd</password>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
artifact-description.xml
I want to deploy only some section therefore I define the following deployment file. With this I ensure that into package will be deploy only common features and project specific scripts/codes
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly- plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>${distributionId}</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>project/${subProjectName}/</outputDirectory>
<directory>${basedir}/..</directory>
<fileMode>0755</fileMode>
<lineEnding>unix</lineEnding>
<includes>
<include>/*.*</include>
<include>/sub-${subProjectName}/*</include>
</includes>
<excludes>
<exclude>**/*.pyc</exclude>
<exclude>**/*.xls</exclude>
<exclude>**/*.xlsx</exclude>
<exclude>**/pom.xml</exclude>
<exclude>**/target</exclude>
<exclude>**/deploy</exclude>
<exclude>**/.venv</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
sub-project-1 pom.xml
This is only simple pom without others plugins and build options
<parent>
<groupId>com.project.group.id</groupId>
<artifactId>project-pom</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
<groupId>com.project.group.id</groupId>
<artifactId>sub-project-1</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<subProjectName>project-1</subProjectName>
</properties>
sub-project-2 pom.xml
The same pom.xml as for sub-project-1
<parent>
<groupId>com.project.group.id</groupId>
<artifactId>project-pom</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
<groupId>com.project.group.id</groupId>
<artifactId>sub-project-2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<subProjectName>project-2</subProjectName>
</properties>
Now I want to build and upload only sub-project-1 it into artifactory and therefore I will use the following maven command:
mvn -e -B -U -X clean deploy --projects :sub-project-1 -DskipIntegrationTests=false -DskipCoverageReport=false
But then following error occur:
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: https://domain/artifactory/mvn-repo-dev/com/project/group/id/project/project-1/1.0.0-SNAPSHOT/sub-project-1-1.0.0-20190723.081454-1.pom. Return code is: 409, ReasonPhrase: Conflict.
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:627)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:541)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:523)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:517)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:497)
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)
... 32 more
Now I am not sure what is wrong and I spend a lot of hours of investigation this issue but nothing found. Please do you have some suggestions what is wrong here? Thanks a lot
I found where is the problem. Within parent pom.xml there was the following plugin which change artifactId. I do not know why I got error 409 but finally this was a reason:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<phase>pre-clean</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
project.getModel().setArtifactId(project.properties["someProperty"].replaceAll('_',
'-'))
project.getArtifact().setArtifactId(project.properties["someProperty"].replaceAll('_',
'-'))
</source>
</configuration>
</execution>
</executions>
</plugin>

maven build ear - how I can build just a .ear file and not the exploded ear dir?

I just need a myEar.ear file as output of my maven build.
I don't want the dir myEar (the exploded ear version).
To be clear, this is my build output:
20/02/2017 11:37 <DIR> myEar
20/02/2017 11:37 7.985.535 myEar.ear
I just want the myEar.ear.
Thanks.
Here my pom.xml of the ear:
<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>
<name>myEar</name>
<description>myEar</description>
<groupId>com.foo</groupId>
<artifactId>myEar</artifactId>
<version>1.0</version>
<packaging>ear</packaging>
<parent>
</parent>
<properties>
</properties>
<dependencies>
(...)
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<generatedDescriptorLocation>${basedir}/src/main/application/META-INF</generatedDescriptorLocation>
<modules>
<webModule>
<groupId>com.foo</groupId>
<artifactId>myWeb</artifactId>
<contextRoot>/myWeb</contextRoot>
</webModule>
<webModule>
<groupId>com.foo</groupId>
<artifactId>myWS</artifactId>
<contextRoot>/</contextRoot>
</webModule>
</modules>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
</plugins>
<directory>${basedir}/../target/diraliases/EARHOMEDIR1036</directory>
<finalName>myEar</finalName>
</build>
</project>
I fixed with th maven-antrun-plugin... an ant call inside maven... very dirty... someone has a better idea?
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>deleteDir</id>
<phase>package</phase>
<configuration>
<tasks>
<delete dir="${basedir}/../target/diraliases/EARHOMEDIR1036/myEar"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

How to share a filtered resource at generate-sources phase in a multi module project?

I have a parent project with 3 child projects:
parent
project-1
/src/main/resources/config.xml
project-2
/src/main/resources/config.xml
project-3
/src/main/resources/config.xml
The configuration config.xml is used during the generate-sources phase. For the three projects, the config.xml is exactly the same. However, the usage of this config.xml is different for each project.
In project-X, I am referring to config.xml as following:
<build>
<plugins>
<plugin>
<groupId>some-group</groupId>
<artifactId>some-artifact</artifactId>
<executions>
<execution>
<goals>
<goal>some-goal</goal>
</goals>
<configuration>
<input>src/main/resources/config.xml</input>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
What is the best way to share this common config.xml between all 3 projects?
You can use the build-helper-maven-plugin here.
PROJECT STRUCTURE
shared-resources-project
+-src
+-main
+-resources
`config.xml
+-project-A
`pom.xml
+-project-B
`pom.xml
+-project-C
`pom.xml
`pom.xml
shared-resources-project/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>my</groupId>
<artifactId>shared-resources-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>project-A</module>
<module>project-B</module>
<module>project-C</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-sources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<filtering>true</filtering>
<directory>${project.parent.basedir}/src/main/resources</directory>
<includes>
<include>config.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>some-group</groupId>
<artifactId>some-artifact</artifactId>
<executions>
<execution>
<id>some-plugin-job</id>
<phase>generate-sources</phase>
<goals>
<goal>some-goal</goal>
</goals>
<configuration>
<input>${project.build.outputDirectory}/config.xml</input>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
shared-resources-project/src/main/resources/config.xml
<config>
<parameter>${custom-value}</parameter>
</config>
project-X/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>
<parent>
<groupId>my</groupId>
<artifactId>shared-resources-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>project-X</artifactId>
<properties>
<custom-value>Project-X Value</custom-value>
</properties>
</project>
Now, let's build the project:
D:\workspaces> cd shared-resources-project
D:\workspaces\java\shared-resources-project> mvn clean install
Some notes:
The build-helper-maven-plugin will add the common config.xml file as a resource to Project-X.
Then the Maven resources plugin (MRP) will copy config.xml to the project output directory (target directory by default). During the copy, MRP will also replace ${custom-value} with the specific value provided by Project-X.
The final config.xml will be available to another plugin as long as the other plugin is bound to the generate-source phase AND its declaration appears AFTER the build-helper-maven-plugin declaration. Maven (3.0.4+ at least) calls the plugins in their order of apparition in the pom.xml.

Can't bind maven-remote-resources-plugin to both bundle and process goals

I use the maven-remote-resources-plugin to get some resources from an artifact and also need to bundle some resources for use in another project.
I bind the maven-remote-resources-plugin to the bundle goal in the default section (not in a profile). And I bind the maven-remote-resources-plugin to the process goal in a profile.
My problem is that I don't get the shared resources when using the profile (I don't get the target\maven-shared-archive-resources folder).
If I remove the maven-remote-resources-plugin in the default section (the bundle binding) it works fine.
Any suggestions?
Below is my pom:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<dependencies>
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app-common</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
<resourcesDirectory>${basedir}/src/test/resources</resourcesDirectory>
<includes>
<include>**/*.sql</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>create-test-data</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<testResources>
<testResource>
<directory>${basedir}/src/test/resources</directory>
</testResource>
<testResource>
<directory>${project.build.directory}/maven-shared-archive-resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.5</version>
<configuration>
<resourceBundles>
<resourceBundle>com.mycompany.app:my-app-common:1.0-SNAPSHOT:test-jar</resourceBundle>
</resourceBundles>
<attachToMain>false</attachToMain>
</configuration>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
The problem was that the property outputDirectory is defined for both the process and bundle goals and I redefined it in the bundle goal.

How to deploy only zip artifacts in maven

I have done some zip packaging in maven using the below descriptor and pom file. But in maven by default it created both jar and zip in target folder. Now i want to deploy only zip contents where i am using deploy:deploy-file plugin. but it is not deploying instead it is showing error. Not sure what is wrong with tag and how it should be resolved.
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>
Command Executed:
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
First you have to fix you error in distributionManagement area like this:
<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 simple deploy the files to your nexus via:
mvn clean deploy
If you don't like having a jar deployed as well you need to change the packing type in your pom 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>
Furthermore i recommend to define the versions of your used plugins like this:
<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>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>some file</file>
<type>extension of your file </type>
<classifier>optional</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
You made a mistake: the <file/> element is not a part of <snapshotRepository/>, it's an config item of deploy plugin! you should deploy your zip file as following:
mvn -X clean package deploy:deploy-file -Dfile=/path/to/your-artifact-1.0.zip

Resources