2013-08-14 1 views
1

My Maven 프로젝트는 Java 6 및 Java 7 프로젝트에서 모두 사용되는 jar 파일입니다. 그래서 다음과 같이 사용될 수있는 다른 유물을 가지고 싶습니다다른 분류 자로 이슈 빌드

<dependency> 
    <groupId>com.example</groupId> 
    <artifactId>example</artifactId> 
    <version>1.0</version> 
    <classifier>jdk6</classifier> 
</dependency> 

나 또한 그들에게 한 번에 만들 수 싶습니다. 그래서 프로파일은 아마 갈 길이 아닙니다. 여러 플러그인 실행을 사용해 보았습니다. '

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <version>2.3.2</version> 
    <executions> 
     <execution> 
      <id>jdk6</id> 
      <phase>compile</phase> 
      <goals> 
       <goal>compile</goal> 
      </goals> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
       <fork>true</fork> 
       <compilerArguments> 
        <d>${project.build.outputDirectory}/jdk6</d> 
       </compilerArguments> 
      </configuration> 
     </execution> 
     <execution> 
      <id>jdk7</id> 
      <phase>compile</phase> 
      <goals> 
       <goal>compile</goal> 
      </goals> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
       <fork>true</fork> 
       <compilerArguments> 
        <d>${project.build.outputDirectory}/jdk7</d> 
       </compilerArguments> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

하지만 내가 할 수있는 : 그럼 난 두 개의 디렉토리에 두 번 구축 받는다는-컴파일러 플러그인을 구성하려고

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>createClassesDir</id> 
      <phase>process-resources</phase> 
      <configuration> 
       <tasks> 
        <mkdir dir="${project.build.outputDirectory}/jdk6" /> 
        <mkdir dir="${project.build.outputDirectory}/jdk7" /> 
       </tasks> 
      </configuration> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

:

첫째, 두 개의 별도의 빌드 디렉토리를 작성 그것을 작동시키지 마십시오. 소스 파일이 이미 컴파일되었으므로 두 번째 컴파일은 수행하지 않습니다.

[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ example --- 
[INFO] Compiling 1 source file to [...]/example/target/classes 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (jdk6) @ example --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (jdk7) @ example --- 
[INFO] Nothing to compile - all classes are up to date 

두 환경 모두에서 컴파일 할 수있는 방법을 알고 있습니까?

+0

의 중복 가능성 : http://stackoverflow.com/questions/12320322/build-multiple-artifacts-with-different-classifiers-at-once –

+0

나는 그것이 중복 생각하지 않는 다른 문제 때문에 이것은 다른 자원을 가지고있는 것과 관련이있는 반면, 이것은 컴파일에 관한 것입니다. – Cos64

답변

0

같은 메이븐 프로젝트에서 2 개의 메이븐 항아리를 만들어서는 안된다고 정직하게 말하십시오. here을 읽을 수있는 이유가 있습니다. 당신은 또한 SO에 question를 참조 할 수 있습니다

Using profiles 
    By doing two executions of maven jar plugin 

원한다면

같은 문서에서는, 당신은 아직도 그것을 할 수있는 두 가지 방법을 설명합니다.

더 자세히 프로젝트에 대해 2 개의 pom 파일을 갖는 데 문제가 없다면, 2 개의 pom 파일을 이와 같이 만들어서 sepately 빌드하면 같은 결과를 얻을 수 있습니다.

pom-jdk6.xml 
    pom-jdk7.xml 
관련 문제