如何从antrun中检索信息回maven?

发布于 2024-10-21 20:25:25 字数 725 浏览 1 评论 0原文

如何从 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

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

I'm interested to use this foo property later in Maven. How to it get out of antrun?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睡美人的小仙女 2024-10-28 20:25:25

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

<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>

这个想法是通过使用 定义一个可用于 Maven 的属性(此处称为 foo.mvn) project.setProperty("foo.mvn", ${foo});.我在这里使用 JavaScript,因此您需要在 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>

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文