2012-02-09 21 views
1

私は、次のような問題を持っている:のMavenのjavaのmaven-antrun-プラグイン

私は検証フェーズのための私のpom.xmlファイル内蟻プラグインを設定しています。このタスクは単にコンソールに文字列をエコーすることです。問題は、私の執行が加速されているのを見ても、タスクは実行されないということです。誰も同じような問題に遭遇しましたか?以下は私のpom.xmlファイルのコードで次のようにを実行するとMVNを確認するとき私が得る出力がある

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>com.mp</groupId> 
<artifactId>parentApp</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>pom</packaging> 
<name>parentApp</name> 
<description>This is just to test pom inheritance</description> 


<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<build> 
    <defaultGoal>package</defaultGoal> 
    <plugins> 
     <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.1</version> 
      <executions> 
       <execution> 
        <id>echodir</id> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <phase>verify</phase> 
        <inherited>true</inherited> 
        <configuration> 
         <task> 
          <echo>*************************************************** Build Dir</echo> 
          <mkdir>./hey</mkdir> 
         </task> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.activemq</groupId> 
      <artifactId>activemq-core</artifactId> 
      <version>5.1.0</version> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.16</version> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building parentApp 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-antrun-plugin:1.1:run (echodir) @ parentApp --- 
[INFO] Executing tasks 
[INFO] Executed tasks 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.321s 
[INFO] Finished at: Thu Feb 09 17:28:01 CET 2012 
[INFO] Final Memory: 2M/121M 
[INFO] ------------------------------------------------------------------------ 

だからとの間には、出力は最終的にはありませんタスクの実行実行タスクですが、プラグイン自体が考慮されます。どんな考え?

+0

<plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <id>echodir</id> <goals> <goal>run</goal> </goals> <phase>verify</phase> <inherited>true</inherited> <configuration> <target> <echo>*************************************************** Build Dir</echo> <mkdir dir="hey"/> </target> </configuration> </execution> </executions> </plugin> 
達人-antrun-プラグイン 1.6? – ollins

+0

予想される出力がデバッグ出力に含まれているかどうかを確認するために、-eまたは-Xフラグを指定してmavenを実行してみましたか? 'mvn -e verify'または' mvn -X verify' – hatboyzero

+0

'mkdir'コマンドを削除してみて、' echo'しかないのを見てみましょう。また、私はそのプラグインの新しいバージョンを使用しようとします(1.7は現在) – Michael

答えて

1

おそらく1.1バージョンのmaven antrunプラグインにバグがあります。

私のために次のスニペットが機能します。 <mkdir>./hey</mkdirant mkdir taskの構文が間違っています。また、taskdeprecatedであり、targetが好ましい。

0

のように、中を確認するいくつかの他のタスクをやってみてください。コメントの一部で述べたように、「いくつかのディレクトリにいくつかのファイルをコピーする」

<copy file="${project.build.directory}/somefile" todir="some dir" 
overwrite="true" /> 
0

は、プラグインの最新バージョン(1.7)を使用します。また、<task>タグを<target>タグに置き換えてください。例:

<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.7</version> 
    <executions> 
     <execution> 
      <id>echodir</id> 
      <goals> 
       <goal>run</goal> 
      </goals> 
      <phase>verify</phase> 
      <inherited>true</inherited> 
      <configuration> 
       <target> 
        <echo>*************************************************** Build Dir</echo> 
       </target> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
関連する問題