gpt4 book ai didi

java - 如何将信息从 antrun 检索回 maven?

转载 作者:行者123 更新时间:2023-11-30 11:54:56 24 4
gpt4 key购买 nike

如何从 maven-antrun-plugin 获取信息回到 Maven 脚本?例如:

[...]
<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

最佳答案

我不确定这个解决方案是否有效,但也许你可以试一试:

<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 插件中添加一些依赖才能运行它......

关于java - 如何将信息从 antrun 检索回 maven?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5289425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com