maven antrun 插件

发布于 2024-09-24 19:53:05 字数 1337 浏览 0 评论 0原文

我的 pom 中有以下内容:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ant-plugin</artifactId>
    <version>2.3</version>
    <configuration>
       <target>
          <echo
            message="hello ant, from Maven!" />
          <echo>Maybe this will work?</echo>
       </target>
    </configuration>
</plugin>

然而,当我运行 'mvn antrun:run' 时,我得到这个:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'antrun'.
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject
[INFO]    task-segment: [antrun:run]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: default-cli}]
[INFO] Executing tasks
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Sep 24 13:33:14 PDT 2010
[INFO] Final Memory: 16M/28M
[INFO] ------------------------------------------------------------------------

为什么回声没有出现?

TIA

I have the following in my pom:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ant-plugin</artifactId>
    <version>2.3</version>
    <configuration>
       <target>
          <echo
            message="hello ant, from Maven!" />
          <echo>Maybe this will work?</echo>
       </target>
    </configuration>
</plugin>

Yet, when I run 'mvn antrun:run' I get this:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'antrun'.
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject
[INFO]    task-segment: [antrun:run]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: default-cli}]
[INFO] Executing tasks
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Sep 24 13:33:14 PDT 2010
[INFO] Final Memory: 16M/28M
[INFO] ------------------------------------------------------------------------

How come the echo's don't show up?

TIA

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

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

发布评论

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

评论(2

霓裳挽歌倾城醉 2024-10-01 19:53:05

因为如果你想执行Ant,你应该使用 Maven AntRun Plugin任务,而不是 Maven Ant 插件(它用于生成从 POM 构建 Ant 1.6.2 或更高版本的文件)。修改您的插件配置如下:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.5</version>
    <configuration>
      <target>
        <echo message="hello ant, from Maven!"/>
        <echo>Maybe this will work?</echo>
      </target>
    </configuration>
  </plugin>

调用 antrun:run 将起作用:

$ mvn antrun:run 
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Q3790798 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-antrun-plugin:1.5:run (default-cli) @ Q3790798 ---
[INFO] Executing tasks

main:
     [echo] hello ant, from Maven!
     [echo] Maybe this will work?
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
...

Because you are supposed to use the Maven AntRun Plugin if you want to execute Ant tasks, not the Maven Ant Plugin (which is used to generate build files for Ant 1.6.2 or above from the POM). Modify your plugin configuration as below:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.5</version>
    <configuration>
      <target>
        <echo message="hello ant, from Maven!"/>
        <echo>Maybe this will work?</echo>
      </target>
    </configuration>
  </plugin>

And invoking antrun:run will work:

$ mvn antrun:run 
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Q3790798 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-antrun-plugin:1.5:run (default-cli) @ Q3790798 ---
[INFO] Executing tasks

main:
     [echo] hello ant, from Maven!
     [echo] Maybe this will work?
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
...
逆光飞翔i 2024-10-01 19:53:05

确保 maven-antrun-plugin 使用足够新的版本。

我的项目中一个不相关的 BOM 将其锁定为 1.3,并且 被忽略。删除 BOM 并为 antrun 指定 1.7 后,回显起作用了。

Make sure maven-antrun-plugin is using a recent enough version.

An unrelated BOM in my project was locking it to 1.3, and <echo> was being ignored. After removing the BOM and specifying 1.7 for antrun, the echoes worked.

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