代码之家  ›  专栏  ›  技术社区  ›  javamonkey79

maven antrun插件

  •  18
  • javamonkey79  · 技术社区  · 14 年前

    我的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时安特伦:快跑“我明白了:

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

    为什么回声没有出现?

    2 回复  |  直到 8 年前
        1
  •  29
  •   Pascal Thivent    14 年前

    因为你应该使用 Maven AntRun Plugin Maven Ant Plugin ). 修改插件配置如下:

      <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] ------------------------------------------------------------------------
    ...
    
        2
  •  3
  •   Ben Hutchison    11 年前

    maven-antrun-plugin 正在使用足够新的版本。

    我项目中一个无关的BOM将其锁定为1.3 <echo>