我正在使用下面顯示的pom.xml
文件使用mvn assembly:single
構建特定的JAR文件(myproduct-1.0-SNAPSHOT-jar-with-dependencies.jar
)。如何在彙編後執行FTP上傳任務:在Maven中單個執行?
我希望能夠通過FTP上傳該文件,如another question中所述。
添加以下代碼部分,以便能夠做到使用mvn install:install
上傳:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<target>
<property name="file_name" value="myproduct-1.0-SNAPSHOT-jar-with-dependencies.jar" />
<ant antfile="${basedir}/build.xml">
<target name="upload" />
</ant>
</target>
</configuration>
</plugin>
我得到的錯誤Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install (default-cli) on project ...: The packaging for this project did not assign a file to the build artifact -> [Help 1]
。
如何通過FTP上傳由mvn assembly:single
生成的文件(或者使用單獨的調用,或者在生成myproduct-1.0-SNAPSHOT-jar-with-dependencies.jar
之後)?
這裏的pom.xml
文件:
<?xml version="1.0" encoding="UTF-8"?>
<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.mycompany</groupId>
<artifactId>myproduct</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
<url>http://maven.restlet.com</url>
</repository>
</repositories>
<dependencies>
[...]
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<target>
<property name="file_name" value="myproduct-1.0-SNAPSHOT-jar-with-dependencies.jar" />
<ant antfile="${basedir}/build.xml">
<target name="upload" />
</ant>
</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
@DmitriPisarenko對不起,'fromDir'需要'fromFile'。你爲「url」指定了什麼? – Tunaki
@DmitriPisarenko它應該是'toFile',而不是'toDir'。 – Tunaki
@DmitriPisarenko您是否修改了Maven設置?你如何運行Maven? – Tunaki