2011-01-10 25 views
5

MavenがいくつかのレガシーコードのANTビルドを呼び出そうとしています。アリのビルドはantを介して正しく構築されます。私はMavenのアリプラグインを使用して、それを呼び出したときしかし、それは次のエラーで失敗します。maven-antrun-pluginを使用したMaven Ant BuildException ... javacコンパイラを見つけることができません

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run  (default) on project CoreServices: An Ant BuildException has occured: The following error occurred while executing this line: 
[ERROR] C:\dev\projects\build\build.xml:158: The following error occurred while executing this line: 
[ERROR] C:\dev\projects\build\build.xml:62: The following error occurred while executing this line: 
[ERROR] C:\dev\projects\build\build.xml:33: The following error occurred while executing this line: 
[ERROR] C:\dev\projects\ods\build.xml:41: Unable to find a javac compiler; 
[ERROR] com.sun.tools.javac.Main is not on the classpath. 
[ERROR] Perhaps JAVA_HOME does not point to the JDK. 
[ERROR] It is currently set to "C:\bea\jdk150_11\jre" 

私のjavacはCに存在する:\ BEA \ jdk150_11 \ binに、これは他のすべてのもののために動作します。 MavenがJAVA_HOMEのこのバージョンを取得しているかどうかはわかりません。 Windows環境変数のJAVA_HOMEはC:\ bea \ jdk150_11 \に設定されています。

私はbuild.xmlのは

<build> 
    <plugins> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.6</version> 

    <executions> 
      <execution> 
      <phase>install</phase> 
      <configuration> 

       <target> 
    <ant antfile="../build/build.xml" target="deliver" > 
    </ant> 
       </target> 
      </configuration> 
      <goals> 
       <goal>run</goal> 
      </goals> 
      </execution> 
     </executions> 
    </plugin> 
    </plugins> 
    </build> 

答えて

15

最初のものである呼び出すために使用していますMavenのコード:なぜあなたはcompileinstallフェーズでANTスクリプトを実行していませんか?

2番目の問題:MavenがJAVA_HOMEがJDKを指しているにもかかわらず、MavenがJDKの代わりにJREを実行するという問題が原因です。これを修正するには、maven-antrun-pluginの依存関係を手動で調整する必要があります。これは単なる例です:

<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.6</version> 
    <dependencies> 
     <dependency> 
      <groupId>com.sun</groupId> 
      <artifactId>tools</artifactId> 
      <version>1.5.0</version> 
      <scope>system</scope> 
      <systemPath>${java.home}/../lib/tools.jar</systemPath> 
     </dependency> 
    </dependencies> 
    <executions> 
     <execution> 
      <phase>compile</phase> 
      <configuration><target><ant/></target></configuration> 
      <goals><goal>run</goal></goals> 
     </execution> 
    </executions> 
</plugin> 
+4

修正リンクが壊れています。私はそれが答えとリンクに細部を置くことを勧めている理由だと思います。 – wrgrs

+2

@ルーカス - あなたはこの答えを修正するか削除する必要があります。 –

+1

@JarrodRobersonそれを指摘してくれてありがとう。私はプラグインのサンプル設定を貼り付けました。 – Lukasz

関連する問題