我们有一个使用Apply
运行下载的JAR的配置文件。
图表A :(可行)
我们可以使用属性maven-antrun-plugin
(Can I use the path to a Maven dependency as a property?)引用下载的JAR。但在此解决方案中,自定义依赖项和存储库信息不仅限于配置文件的范围。
${maven.dependency.com.foobar.target-jar.jar.path}
图表B :(没有让它发挥作用)
在这里,我们将依赖项和存储库信息移动到配置文件中。 Maven成功下载了工件,但我们不再知道如何通过属性引用它。
<project>
...
<repositories>
<repository>
<id>thirdparty</id>
<name>Third Party</name>
<url>
[URL for the repository that holds the target JAR]
</url>
<layout>default</layout>
</repository>
</repositories>
...
<dependencies>
<dependency>
<groupId>com.foobar</groupId>
<artifactId>target-jar</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
...
<profiles>
<profile>
<id>runJARprofile</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<inherited>false</inherited>
<executions>
<execution>
<id>run-jar</id>
<phase>package</phase>
<configuration>
<target name="runJar" fork="true">
<java jar="${maven.dependency.com.foobar.target-jar.jar.path}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
...
</project>
答案 0 :(得分:0)
我在这里创建了类似于附件B 的POM,并在<div ui-view></div>
期间收到以下消息:
mvn package -P runJARprofile
我将相应的行更改为:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run
(run-jar) on project so-36848518: An Ant BuildException has occured:
Cannot execute a jar in non-forked mode. Please set fork='true'.
[ERROR] around Ant part ...<java jar="${my:test:jar}"/>...
和
<java jar="${my:test:jar} fork="true"/>