Deploying Maven assembly ZIP to nexus

user1323670 picture user1323670 · Aug 9, 2013 · Viewed 12.7k times · Source

I am using the assembly plugin to build a jar with dependancies and then zip the project. The zip should then be uploaded to nexus. The clean install works and generates the zip file as expected. The deploy command fails:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Analytics Feed Auditor
[INFO]    task-segment: [deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [surefire:test]
[INFO] No tests to run.
[INFO] [jar:jar]
[INFO] [assembly:single {execution: jar-with-dependencies}]
[INFO] Processing DependencySet (output=)
[INFO] Building jar: C:\code\imt workspaces\uat-trunk\AnalyticsAudit\target\AnalyticsAudit-1
.0-jar-with-dependencies.jar
[INFO] [assembly:single {execution: RELEASE}]
[INFO] Reading assembly descriptor: dist.xml
[INFO] Building zip: C:\code\imt workspaces\uat-trunk\AnalyticsAudit\target\AnalyticsAudit-1
.0-RELEASE.zip
[INFO] [install:install]
[INFO] Installing C:\code\imt workspaces\uat-trunk\AnalyticsAudit\target\AnalyticsAudit-1.0.
jar to C:\SVNRepository\com\dec\gbm\gb\gcf\amg\fo\AnalyticsAudit\1.0\AnalyticsAudit-1.0.jar
[INFO] Installing C:\code\imt workspaces\uat-trunk\AnalyticsAudit\target\AnalyticsAudit-1.0-
jar-with-dependencies.jar to C:\SVNRepository\com\dec\gbm\gb\gcf\amg\fo\AnalyticsAudit\1.0\Analytic
sAudit-1.0-jar-with-dependencies.jar
[INFO] Installing C:\code\imt workspaces\uat-trunk\AnalyticsAudit\target\AnalyticsAudit-1.0-
RELEASE.zip to C:\SVNRepository\com\dec\gbm\gb\gcf\amg\fo\AnalyticsAudit\1.0\AnalyticsAudit-1.0-REL
EASE.zip
[INFO] [deploy:deploy]
altDeploymentRepository = null
Uploading: https://dsnexus.uk.hibm.dec:8081/nexus/content/repositories/releases/com/dec/gbm/gb/gcf
/amg/fo/AnalyticsAudit/1.0/AnalyticsAudit-1.0.jar
6K uploaded
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error deploying artifact: Failed to transfer file: https://dsnexus.uk.hibm.dec:8081/nexus/co
ntent/repositories/releases/com/dec/gbm/gb/gcf/amg/fo/AnalyticsAudit/1.0/AnalyticsAudit-1.0.jar. Re
turn code is: 400

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Fri Aug 09 15:58:22 BST 2013
[INFO] Final Memory: 14M/35M
[INFO] ------------------------------------------------------------------------

I have a few issues here. Firstly, I want to have a custom ZIP filename rather than the default one. Secondly, only the ZIP file should be deployed to Nexus and not the jars. Thirdly, why isn't the deploy working in it's current state? And lastly, can you please tell me how I can automatically download the last release from nexus using wget maybe?

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project ....>
<modelVersion>4.0.0</modelVersion>
<groupId>com.dec.gbm.gb.gcf.amg.fo</groupId>
<artifactId>AnalyticsAudit</artifactId>
<version>1.0</version>
<name>Analytics Feed Auditor</name>
<description>Analytics Feed Auditor</description>
<packaging>jar</packaging>

<distributionManagement>
    <repository>
        <id>releases</id>
        <name>Internal Releases</name>
        <url>...</url>
    </repository>

    <snapshotRepository>
        <id>snapshots</id>
        <name>Internal Snapshots</name>
        <url>...</url>
    </snapshotRepository>

</distributionManagement>
<repositories>
    <repository>
        <id>releases</id>
        <name>Nexus Repository</name>
        <url>...</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>releases</id>
        <name>Nexus Repository</name>
        <url>...</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
<properties>
    <project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.vicar</groupId>
        <artifactId>vicar</artifactId>
        <version>3.6</version>
        <scope>system</scope>
        <systemPath>
            ${project.basedir}/lib/vicar-3.6.jar
        </systemPath>
    </dependency>
    <dependency>...
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <id>jar-with-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>
                                jar-with-dependencies
                            </descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <classpathPrefix>
                                    lib/
                                </classpathPrefix>
                                <mainClass>
                                    com.dec.gbm.gb.gcf.amg.fo.AnalyticsAuditor
                                </mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </execution>
                <execution>
                    <id>RELEASE</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptors>
                            <descriptor>dist.xml</descriptor>
                        </descriptors>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

dist.xml

<assembly>
<id>RELEASE</id>
<formats>
    <format>zip</format>
</formats>
<files>
    <file>
        <source>
            target/${project.artifactId}-${project.version}-jar-with-dependencies.jar
        </source>
        <outputDirectory>lib</outputDirectory>
    </file>
    <file>
        <source>${project.basedir}/bin/AnalyticsAudit.cmd</source>
        <outputDirectory />
    </file>
    <file>
        <source>
            ${project.basedir}/resources/analytics_audit.properties
        </source>
        <outputDirectory>resources</outputDirectory>
    </file>
    <file>
        <source>${project.basedir}/lib/vicar-3.6.jar</source>
        <outputDirectory>lib</outputDirectory>
    </file>
</files>

I've spent too long on this and tried too much. I'd be very grateful for any help.

Answer

Ashay Batwal picture Ashay Batwal · Sep 30, 2013

Basically you cannot deploy a zip using a maven-assembly plugin. Assembly part is a part of packaging, while deployment happens later. Check if this link is useful

Deploying assembly package with maven-release-plugin

OR

You can use this plugin to deploy the zip or tar file maven-build-helper-plugin