2016-08-02 134 views
0

在我的項目中,我有幾個文件可以打包成一個ZIP文件並將其上傳到Nexus存儲庫。如何使用Maven將ZIP文件上傳到Nexus並避免在Nexus中創建pom工件?

我實現了使用Maven Assembly插件兩個動作:

的pom.xml

<groupId>com.ddd.tools</groupId> 
<artifactId>mytool</artifactId> 
<version>2.1.0</version> 
<packaging>pom</packaging> 

<name>Tool</name> 
<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.4</version> 
      <configuration> 
       <!-- File bin.xml saves information about which files are to be included to the ZIP archive. --> 
       <descriptor>bin.xml</descriptor> 
       <finalName>${pom.artifactId}-${pom.version}</finalName> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

BIN.XML

<assembly ...> 
    <id>bin</id> 
    <formats> 
     <format>zip</format> 
    </formats> 
    <fileSets> 
     <fileSet> 
      <directory>src/release</directory> 
      <outputDirectory>/</outputDirectory> 
      <includes> 
       <include>Tool.exe</include> 
      </includes> 
     </fileSet> 
    </fileSets> 
</assembly> 

現在,當我看着我的Nexus看到兩個工件:

<dependency> 
     <groupId>com.ddd.tools</groupId> 
     <artifactId>mytool</artifactId> 
     <version>2.1.0</version> 
     <type>pom</type> 
    </dependency> 

<dependency> 
    <groupId>com.ddd.tools</groupId> 
    <artifactId>mytool</artifactId> 
    <version>2.1.0</version> 
    <classifier>bin</classifier> 
    <type>zip</type> 
</dependency> 

我只是在後者的ZIP神器感興趣,因爲它是我上傳的ZIP文件。

我如何從Nexus中擺脫第一個POM神器?或者有任何我可能需要它的場景?

+0

首先,您的pom中的finalName配置對上傳到Nexus沒有用處。而且你不能阻止這個pom神器,因爲它是必要的。是的,所有的時候,你都在使用這種依賴關係,pom工件被用來識別工件。你粘貼的片段只是作爲依賴的用法,但他們需要用來分析這是什麼樣的工件以及它是否具有其他依賴關係(在這種情況下不需要)的pom工件。 – khmarbaise

回答

相關問題