问题描述
如何从 maven-antrun-plugin 获取信息回Maven 脚本?例如:
How can I get information from maven-antrun-plugin back to Maven script? For example:
[...]
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec ... resultproperty="foo">
</target>
</configuration>
</execution>
</executions>
</build>
[...]
我有兴趣稍后在 Maven 中使用这个 foo
属性.如何摆脱antrun
?
I'm interested to use this foo
property later in Maven. How to it get out of antrun
?
推荐答案
我不确定这个解决方案是否有效,但也许你可以试一试:
I am not sure if this solution will work, but maybe you can give it a try:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec ... resultproperty="foo">
<taskdef name="script"
classname="org.apache.tools.ant.taskdefs.optional.Script"
classpathref="maven.plugin.classpath" />
<script language="javascript">
<![CDATA[
project.setProperty("foo.mvn", ${foo});
]]>
</script>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<!-- Needed to run script (of Javascript) task. -->
<dependency>
<groupId>ant</groupId>
<artifactId>ant-optional</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>bsf</groupId>
<artifactId>bsf</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
<version>1.6R5</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
这个想法是通过使用 project.setProperty("foo.mvn", ${foo}); 定义一个可用于 Maven 的属性(这里称为
foo.mvn
);代码>.我这里使用的是 JavaScript,所以你需要在 antrun
插件中添加一些依赖项才能运行它...
The idea is to use define a property available for Maven (called here foo.mvn
) by using the project.setProperty("foo.mvn", ${foo});
. I am using JavaScript here, so you need to add some dependencies in the antrun
plugin to be able to run it...
这篇关于如何从antrun检索信息回maven?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!