我如何可以部署使用Maven - antrun-插件创建一个zip文件? [英] How can I deploy a zip file created with the maven-antrun-plugin?
问题描述
我使用Maven的antrun-插件做蚂蚁,最终导致一个zip文件一堆的工作。我想zip文件部署到我们的行家服务器(Artifactory的)。在Maven的antrun部分按预期工作,并成功创建zip文件;然而,部署失败,出现以下错误信息:
I'm using the maven-antrun-plugin to do a bunch of work with Ant, which ultimately results in a zip file. I'd like to deploy the zip file to our maven server (Artifactory). The maven-antrun-portion works as intended and successfully creates the zip file; however deployment fails with the following error message:
org.apache.maven.lifecycle.LifecycleExecutionException:未能执行目标org.apache.maven.plugins:行家 - 部署 - 插件:2.6:部署(默认部署)项目项目名称:中包装这个项目没有指定一个文件添加到构建神器
我的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>
<phase>compile</phase>
<configuration>
<target>
<!-- Do lots of other stuff with Ant. -->
<!-- Create a zip file. -->
<zip basedir="mydir" destfile="${WORKSPACE}/MyZip.zip" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<configuration>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>zip</packaging>
<file>MyZip.zip</file>
<url>${project.distributionManagement.snapshotRepository.url}</url>
</configuration>
</plugin>
</plugins>
</build>
</project>
当我调用这个(从父POM)与 MVN -U -pl项目名称清洁部署
我在部署阶段获得前面提到的错误。有谁知道我在做什么错误或如何才能解决这个问题?
When I invoke this (from the parent POM) with mvn -U -pl projectname clean deploy
I get the aforementioned error during the deploy phase. Does anyone know what I'm doing wrong or how I can fix this?
推荐答案
这是为我工作的解决方案(我不知道这是否是理想的,它似乎相当的hackish)为切换到部署:部署文件
目标:
The solution that worked for me (I'm not sure if it is ideal, it seems rather hackish) was to switch to the deploy:deploy-file
goal:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>artifactory</repositoryId>
<packaging>zip</packaging>
<generatePom>true</generatePom>
<url>${project.distributionManagement.snapshotRepository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>${WORKSPACE}/MyZip.zip</file>
</configuration>
</plugin>
和显式调用它:
mvn -U -X -pl projectname clean install deploy:deploy-file
这篇关于我如何可以部署使用Maven - antrun-插件创建一个zip文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!