我正在使用maven-antrun-plugin与Ant做一堆工作,最终产生一个zip文件.我想将zip文件部署到我们的maven服务器(Artifactory).maven-antrun-part按预期工作并成功创建zip文件; 但部署失败,并显示以下错误消息:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy (default-deploy) on project projectname: The packaging for this project did not assign a file to the build artifact
我的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>com.company.division</groupId>
<artifactId>projectname</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>com.company.product</groupId>
<artifactId>parentproject</artifactId>
<version>1.0.0</version>
</parent>
<distributionManagement>
<snapshotRepository>
<id>artifactory</id>
<name>artifactory-snapshots</name>
<url>http://localartifactoryserver/artifactory/libs-snapshot-local</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
<dependencies>
<!-- Some dependencies... -->
</dependencies>
<build>
<plugins>
<!-- Compiler plugin -->
<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>
<encoding>UTF8</encoding>
<optimize>true</optimize>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>compile</id> …Run Code Online (Sandbox Code Playgroud) 我对Maven很新...
我正在尝试做的是在部署阶段跳过maven-deploy-plugin,同时用我自己的插件替换它(即我正在部署到非存储库位置).
我意识到我可以用其他多种方式做到这一点,但老板希望能够运行:
mvn部署
获取当前解决方法的结果,即禁用maven-deploy-plugin(似乎禁用整个部署阶段),并从命令行手动指定自定义上载目标.
我目前未能成功完成任务:
<executions>
<execution>
<phase>deploy</phase>
</execution>
</executions>
Run Code Online (Sandbox Code Playgroud)
在包含我的插件规范的build/plugins/plugin部分中,因为部署阶段被跳过:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
谢谢!
我使用下面的描述符和pom文件在maven中完成了一些zip包装.但是在默认情况下,它在目标文件夹中创建了jar和zip.现在我想在我使用deploy:deploy-file插件的地方只部署zip内容.但它没有部署而是显示错误.不确定标签有什么问题以及应该如何解决.
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>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>
Run Code Online (Sandbox Code Playgroud)
程序集插件描述符文件:
<assembly>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>DB_Files</outputDirectory>
</fileSet>
</fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)
执行命令:
mvn -X clean package deploy:deploy-file
Run Code Online (Sandbox Code Playgroud)
错误:
[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) @ …Run Code Online (Sandbox Code Playgroud) 我使用swagger在我的项目中生成Web服务客户端.生成的代码生成一个可以用作Maven lib的库.我已经成功将发布版本部署到我的私有sonatype-nexus中.
我想知道altDeploymentRepository和之间的区别是什么altReleaseDeploymentRepository?mvn deploy如果设置了两个参数,如何选择使用哪个存储库?
正如apache-maven部署文档所说:
altDeploymentRepository:指定应该部署项目工件的备用存储库(除了指定的那些).格式:id :: layout :: url
altReleaseDeploymentRepository:项目具有最终版本时使用的备用存储库.
altSnapshotDeploymentRepository:项目具有快照版本时使用的备用存储库.
到底是什么
当项目有最终版本时.
意思?
我正在尝试设置项目以部署到内部nexus存储库时遇到问题.由于我对Maven一般都是新手,所以我希望在构建分发管理方面我真的不会理解.
基本问题是,当我执行"mvn deploy"时,工件已成功部署到快照存储库,但Maven也在尝试将其部署到发布存储库,而这正在失败......应该如此.我对当前配置的理解是它不应该将它部署到发布存储库中.
我已经包含了下面的各种配置元素,但我想知道我是否应该使用配置文件管理该部分,以便快照构建仅定义,并且发布版本仅定义.
对此的任何帮助/澄清将非常感激.
我的POM中有以下内容用于分发管理:
<distributionManagement>
<repository>
<id>internal-releases</id>
<name>Internal Releases</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>internal-snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)
在POM的其他地方,我有以下设置允许使用这些存储库来获取工件:
<repositories>
<repository>
<id>internal-releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>internal-snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<!-- other repos, etc, etc -->
</repositories>
Run Code Online (Sandbox Code Playgroud)
我在settings.xml中有正确的设置,以提供能够发布到我的计算机上运行的此测试nexus实例的凭据,并且它实际上已成功部署快照.
问题是它还尝试将快照部署到发布存储库,该存储库配置为禁止快照.
"mvn deploy"的输出包括以下内容:
[INFO] [deploy:deploy {execution: default-deploy}]
[INFO] Retrieving previous build number from internal-snapshots
Uploading: http://localhost:8081/nexus/content/repositories/snapshots/com/internal/service/1.0.0-SNAPSHOT/service-1.0.0-20101104.170338-8.war
405K uploaded (service-1.0.0-20101104.170338-8.war)
[INFO] Retrieving previous metadata from internal-snapshots
[INFO] Uploading repository metadata for: 'snapshot com.internal:service:1.0.0-SNAPSHOT'
[INFO] Retrieving previous metadata from internal-snapshots
[INFO] Uploading …Run Code Online (Sandbox Code Playgroud) 为了使Maven"部署"到目录,我使用这个:
<distributionManagement>
<downloadUrl>http://code.google.com/p/junitdiff/downloads/list</downloadUrl>
<repository>
<id>local-hack-repo</id>
<name>LocalDir</name>
<url>file://${project.basedir}/dist-maven</url>
</repository>
<snapshotRepository>
<id>jboss-snapshots-repository</id>
<name>JBoss Snapshots Repository</name>
<!--
<url>https://repository.jboss.org/nexus/content/repositories/snapshots</url>
-->
<url>file://${project.basedir}/dist-maven</url>
</snapshotRepository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)
这出现在有效的pom中.
...
<distributionManagement>
<repository>
<id>local-hack-repo</id>
<name>LocalDir</name>
<url>file:///home/ondra/work/TOOLS/JUnitDiff/github/dist-maven</url>
</repository>
<snapshotRepository>
<id>jboss-snapshots-repository</id>
<name>JBoss Snapshots Repository</name>
<url>file:///home/ondra/work/TOOLS/JUnitDiff/github/dist-maven</url>
</snapshotRepository>
<downloadUrl>http://code.google.com/p/junitdiff/downloads/list</downloadUrl>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)
但是,Maven坚持认为它不存在:
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project JUnitDiff: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[INFO] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project JUnitDiff: Deployment …Run Code Online (Sandbox Code Playgroud) 我在deployAtEnd属性设置为的多模块项目中使用maven-deploy-plugin true.
执行后mvn deploy在根项目,部署插件是每个子项目执行的-我可以看到这样的:
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ subproject-name ---
[INFO] Deploying package:subproject-name:v1.1 at end
最后的调用是根项目:
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ parent-project ---
[INFO] Deploying package:parent-project:v1.1 at end
,这一切,不执行实际的部署.
如何在多模块项目中使部署插件正常工作deployAtEnd=true?
我正在尝试使用deploy-fileNexus 登台存储库的目标单独部署签名文件,但我注意到 mvn deploy 插件删除了扩展。我的文件是这样的:azerty-0.1.jar.asc
但部署的文件是: azerty-0.1.asc
我尝试添加一个分类器: -Dclassifier=jar
部署的文件是: azerty-0.1-jar.asc
这似乎是一种奇怪的行为。
问题:任何想法如何解决它?
我们最近看到一个错误,Maven试图检索一个不存在的SNAPSHOT.正如您所看到的那样,构建号(无论是什么,因为它不是我们的构建号)匹配,但时间戳不匹配,导致构建失败.每次说20次构建都会发生一次.
这是在Nexus中:

这就是构建过程中发生的事情:

正如您所看到的那样,它会尝试检索relations-models:jar:1.1-20170901.134955-278哪些不存在,而20170901.134954-278确实存在.注意一秒的偏移量.
这涉及(大)多模块项目,其中这是子模块之一.
Jar插件配置如下
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>me.magnet.redirect.RedirectService</mainClass>
<useUniqueVersions>false</useUniqueVersions>
<classpathLayoutType>custom</classpathLayoutType
<customClasspathLayout>$${artifact.artifactId}-$${artifact.baseVersion}.$${artifact.extension}</customClasspathLayout>
</manifest>
</archive>
</configuration>
</plugin>
像这样的部署插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<uniqueVersion>false</uniqueVersion>
<deployAtEnd>true</deployAtEnd>
</configuration>
</plugin>
构建也是并行运行的.
我正在尝试mvn release:prepare release:perform在一个项目上运行,该项目以前曾经在一些场景中没有问题,但是我看到了以下输出:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.937s
[INFO] Finished at: Thu Aug 23 15:06:01 BST 2012
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.2.1:prepare (default-cli) on project my-project: Unable to tag SCM
[ERROR] Provider message:
[ERROR] The svn tag command failed.
[ERROR] Command output:
[ERROR] svn: OPTIONS of 'https://<svn url here>': Server certificate verification failed: certificate has expired, issuer is not trusted (https://<svn url here>)
Run Code Online (Sandbox Code Playgroud)
我在这里~/.scm/svn-settings.xml建议包括以下内容 …
maven ×10
deployment ×3
java ×2
ant ×1
maven-3 ×1
maven-plugin ×1
nexus ×1
phase ×1
repository ×1
svn ×1