2015-01-14 82 views
1

我正在設置我們的系統,以基於所使用的jdk爲不同版本的java工件執行雙重構建。有4個罐子可以製造:神器,神器測試,神器源和神器測試源。這裏是構建的輸出確保測試罐命名正確

[INFO] Installing /Users/carlos/workspace/svn/Libraries/artifact-name/trunk/pom.xml to /Users/carlos/.m2/repository/package-path/artifact-name/1.0.8-SNAPSHOT/artifact-name-1.0.8-SNAPSHOT.pom 
[INFO] Installing /Users/carlos/workspace/svn/Libraries/path/artifact-name-1.0.8-SNAPSHOT-java6.jar to /Users/carlos/.m2/repository/package-path/artifact-name/1.0.8-SNAPSHOT/artifact-name-1.0.8-SNAPSHOT-java6.jar 
[INFO] Installing /Users/carlos/workspace/svn/Libraries/path/artifact-name-1.0.8-SNAPSHOT-sources.jar to /Users/carlos/.m2/repository/package-path/artifact-name/1.0.8-SNAPSHOT/artifact-name-1.0.8-SNAPSHOT-sources.jar 
[INFO] Installing /Users/carlos/workspace/svn/Libraries/path/artifact-name-1.0.8-SNAPSHOT-test-sources.jar to /Users/carlos/.m2/repository/package-path/artifact-name/1.0.8-SNAPSHOT/artifact-name-1.0.8-SNAPSHOT-test-sources.jar 
[INFO] Installing /Users/carlos/workspace/svn/Libraries/path/artifact-name-1.0.8-SNAPSHOT-tests.jar to /Users/carlos/.m2/repository/package-path/artifact-name/1.0.8-SNAPSHOT/artifact-name-1.0.8-SNAPSHOT-tests.jar 

你可以看到主構件是用java6構建的並且具有適當的分類器。我假設test分類器覆蓋了java6分類器,但我不確定。有沒有辦法讓它被明確命名爲測試和jdk?類似於-1.0.8-SNAPSHOT-tests-java6.jar。如果可能的話,我想避免手動更改final.name,只是使用庫存功能,就像我爲主物品所做的那樣。

以下是pom的相關部分。

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-jar-plugin</artifactId> 
       <version>${maven.jar.version}</version> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>${maven.compiler.version}</version> 
       <configuration> 
        <source>${jdk.version}</source> 
        <target>${jdk.version}</target> 
        <forceJavacCompilerUse>true</forceJavacCompilerUse> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-source-plugin</artifactId> 
       <version>${maven.source.version}</version> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.9</version> 
      <executions> 
       <execution> 
        <id>analyze</id> 
        <goals> 
         <goal>analyze-only</goal> 
        </goals> 
        <configuration> 
         <failOnWarning>true</failOnWarning> 
         <ignoreNonCompile>true</ignoreNonCompile> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-deploy-plugin</artifactId> 
      <version>2.4</version> 
      <!--<configuration>--> 
      <!--<skip>true</skip>--> 
      <!--</configuration>--> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>${jdk.version}</source> 
       <target>${jdk.version}</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-source-plugin</artifactId> 
      <executions> 
       <execution> 
        <goals> 
         <goal>jar</goal> 
         <goal>test-jar</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-jar-plugin</artifactId> 
      <configuration> 
       <classifier>${jdk.version.display}</classifier> 
      </configuration> 
      <executions> 
       <execution> 
        <goals> 
         <goal>test-jar</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 
<profiles> 
    <profile> 
     <id>java6</id> 
     <activation> 
      <activeByDefault>false</activeByDefault> 
      <jdk>1.6</jdk> 
     </activation> 
     <properties> 
      <jdk.version>1.6</jdk.version> 
      <jdk.version.display>java6</jdk.version.display> 
     </properties> 
    </profile> 
    <profile> 
     <id>java7</id> 
     <activation> 
      <activeByDefault>false</activeByDefault> 
      <jdk>1.7</jdk> 
     </activation> 
     <properties> 
      <jdk.version>1.7</jdk.version> 
      <jdk.version.display>java7</jdk.version.display> 
     </properties> 
    </profile> 
    <profile> 
     <id>java8</id> 
     <activation> 
      <activeByDefault>false</activeByDefault> 
      <jdk>1.8</jdk> 
     </activation> 
     <properties> 
      <jdk.version>1.8</jdk.version> 
      <jdk.version.display>java8</jdk.version.display> 
     </properties> 
    </profile> 
</profiles> 

回答

0

-sources-tests-test-sources JAR文件本身使用分類器。所以例如在sources的情況下,您需要覆蓋maven-source-plugin的<classifier>配置選項(另請參閱Maven deploy + source classifiers)。我懷疑這樣做會在所有使用-sources工件的工具集中得到很好的測試。例如,如果您調用分類器java6-sources,那麼Eclipse是否仍會下載java6分類器工件的源代碼?那麼tests,test-sources和(如果你以後需要它)javadoc分類器,你是否會進一步使你的POM複雜化以產生所有這些不同呢?也許你可以完成所有工作,但不是簡單地沿着這條路走下去,簡單地使用兩個不同的工件標識將會更容易,一個用於java6,另一個用於java7,並且將分類器排除在等式之外。