如何从antrun回信息到Maven? [英] How to retrieve information from antrun back to maven?

查看:178
本文介绍了如何从antrun回信息到Maven?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能从 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中后期使用属性。如何得到它了 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(富定义Maven的可用属性(这里称为 foo.mvn )。 MVN$ {foo的}); 。我在这里使用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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆