2011-01-10 5 views
5

Maven이 일부 레거시 코드 용 ANT 빌드를 호출하도록하고 있습니다. 개미 빌드는 개미를 통해 올바르게 빌드됩니다. 나는 받는다는 개미 플러그인을 사용하여 호출 할 때 그러나, 다음과 같은 오류와 함께 실패합니다Maven Ant BuildException - maven-antrun-plugin이 ... 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 \ 빈 이것은 다른 모든 것들에 대한 작동합니다. 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

제일 먼저 전화를 사용하고 있습니다 메이븐 코드 : 당신은 왜 compileinstall 단계에서 ANT 스크립트를 실행하지 않는다?

두 번째 문제 : 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

관련 문제