将Maven程序集ZIP部署到nexus
我正在使用汇编插件构建一个具有依赖性的jar,然后压缩项目。然后应该将zip文件上载到nexus。clean安装可以正常工作并按预期生成zip文件。部署命令失败:将Maven程序集ZIP部署到nexus,maven,wget,nexus,maven-assembly-plugin,maven-deploy-plugin,Maven,Wget,Nexus,Maven Assembly Plugin,Maven Deploy Plugin,我正在使用汇编插件构建一个具有依赖性的jar,然后压缩项目。然后应该将zip文件上载到nexus。clean安装可以正常工作并按预期生成zip文件。部署命令失败: [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Analytics Feed Auditor [INFO] task-se
[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] ------------------------------------------------------------------------
我这里有几个问题。首先,我想要一个自定义的ZIP文件名,而不是默认的。其次,只有ZIP文件应该部署到Nexus,而不是jar。第三,为什么部署不能在当前状态下工作?最后,你能告诉我如何使用wget自动下载nexus的最新版本吗
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>
4.0.0
com.dec.gbm.gb.gcf.amg.fo
分析专家
1
分析源审计员
分析源审计员
罐子
释放
内部释放
...
快照
内部快照
...
释放
Nexus存储库
...
真的
真的
释放
Nexus存储库
...
真的
真的
Cp1252
牧师
牧师
3.6
系统
${project.basedir}/lib/vicar-3.6.jar
...
org.apache.maven.plugins
maven编译器插件
2.3.2
1.6
1.6
maven汇编插件
带有依赖项的jar
包裹
单一的
带有依赖项的jar
真的
解放党/
com.dec.gbm.gb.gcf.amg.fo.AnalyticsAuditor
释放
包裹
单一的
dist.xml
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>
释放
拉链
target/${project.artifactId}-${project.version}-jar-with-dependencies.jar
解放党
${project.basedir}/bin/AnalyticsAudit.cmd
${project.basedir}/resources/analytics\u audit.properties
资源
${project.basedir}/lib/vicar-3.6.jar
解放党
我在这上面花了太长时间,尝试了太多。我非常感谢您的帮助。基本上,您无法使用maven assembly插件部署zip。组装部件是打包的一部分,而部署将在稍后进行。检查此链接是否有用 或
您可以使用此插件部署zip或tar文件maven build helper插件当Nexus返回400状态时,这意味着您正在上载不允许上载到特定存储库的工件,例如,您正在尝试将快照上载到发布存储库 我猜您正在尝试使用“mvn部署”将其部署为快照。尝试使用“mvn发布:准备发布:执行”,将其作为稳定版本发布到“发布”存储库中。您不应该再收到400状态响应。
<!--Make it a fat jar-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!--this is used for inheritance merges-->
<phase>package</phase> <!--bind to the packaging phase-->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
maven汇编插件
带有依赖项的jar
组装
包裹
单一的
为了将*.zip文件部署到Nexus,您需要有适当的pom.xml
和assembly.xml
文件
这是您需要的pom.xml:
<project>
<groupId>a.b</groupId>
<artifactId>deploy-to-nexus</artifactId>
<version>1.0-SNAPSHOT</version>
<!--
it needs to be 'pom', otherwise maven will
generate an <artifactId>-<version>.jar file as well
-->
<packaging>pom</packaging>
<!-- nexus repositories -->
<distributionManagement>
<repository>
<id>deploy-to-nexus-releases</id>
<url>http://...</url>
</repository>
<snapshotRepository>
<id>deploy-to-nexus-snapshots</id>
<url>http://...</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<!-- assembly plugin will be activated by 'mvn package' -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<assembly>
<id>bundle</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<!-- add some files -->
<fileSet>
<directory>...</directory>
<outputDirectory>...</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
</fileSets>
</assembly>
然后
命令将创建*.zip文件mvn clean package
命令将您的zip上传到Nexusmvn clean deploy
版本库中两次。如果尝试执行此操作,您将返回状态代码400
:
Failed to deploy artifacts: Could not transfer artifact a.b:deploy-to-nexus:pom:1.0 from/to ..... (http://.....-releases): Failed to transfer file http://..../deploy-to-nexus/1.0/deploy-to-nexus-1.0.pom with status code 400
希望它能帮助您。没有答案吗?以前没人试过这么做?