2017-08-17 69 views
1

我的項目的簡化設置如下:如何防止在maven-assembly-plugin中指定兄弟模塊的版本?

root |--parent |--service-1 |--service-2 |--service-aggregator

我需要裝配「服務-1」 &「服務-2」模塊「服務聚合器」。我正在使用maven-assembly-plugin的相同,它工作正常,但我預見維護問題,其中無論任何service-1或service-2的版本將更改,我將需要更新service-aggregator pom。 xml也。

因此,我正在尋找一種方法來防止在service-aggregator pom.xml中編寫service-1/-2的版本,即我只需要service-aggregator來簡單地選擇最新版本的service-1/-2。

我已經通過了maven-assembly-plugin documentation中提供的示例,但那些包含彙編模塊(在我的示例中爲服務聚合器)中提到的版本。

請讓我知道,如果有任何細節丟失&我會添加它。

這裏是服務聚合的pom.xml的重點內容:

<modelVersion>4.0.0</modelVersion> 
<parent> 
    <groupId>com.company.project</groupId> 
    <artifactId>parent</artifactId> 
    <version>0.0.1</version> 
</parent> 
<groupId>com.company.project.parent</groupId> 
<artifactId>service-aggregator</artifactId> 

<name>service-aggregator</name> 
<dependencies> 
    <dependency> 
     <groupId>com.company.project.parent</groupId> 
     <artifactId>service-1</artifactId> 
     <version>0.0.1</version> <!-- this is the line troubling me --> 
    </dependency> 
    <dependency> 
     <groupId>com.company.project.parent</groupId> 
     <artifactId>service-2</artifactId> 
     <version>0.0.1</version> <!-- this is the line troubling me --> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.6</version> 
      <configuration> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
       <skipAssembly>${skip.assembly}</skipAssembly> 
      </configuration> 
      <executions> 
       <execution> 
        <id>make-assembly</id> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 
<properties> 
    <skip.assembly>false</skip.assembly> 
</properties> 

+1

這可能會幫助https://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-late -A-依賴ST-版本的 – Rohan

回答

1

最好的辦法是使用性質是這樣的:

<modelVersion>4.0.0</modelVersion> 
<parent> 
    <groupId>com.company.project</groupId> 
    <artifactId>parent</artifactId> 
    <version>0.0.1</version> 
</parent> 
<groupId>com.company.project.parent</groupId> 
<artifactId>service-aggregator</artifactId> 

<name>service-aggregator</name> 
<dependencies> 
    <dependency> 
     <groupId>com.company.project.parent</groupId> 
     <artifactId>service-1</artifactId> 
     <version>${project.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>com.company.project.parent</groupId> 
     <artifactId>service-2</artifactId> 
     <version>${project.version}</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.6</version> 
      <configuration> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
       <skipAssembly>${skip.assembly}</skipAssembly> 
      </configuration> 
      <executions> 
       <execution> 
        <id>make-assembly</id> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 
相關問題