<formats>
<format>jar</format>
</formats>
但是配置我的裝配描述有罐子類型的組件,運行安裝MVN得到的壓縮文件,而不是jar.Where我在哪裏呢?
<formats>
<format>jar</format>
</formats>
但是配置我的裝配描述有罐子類型的組件,運行安裝MVN得到的壓縮文件,而不是jar.Where我在哪裏呢?
這種配置產生了罐組件與所述分類器jar-assembly
containi只有目標/類的內容。如果需要將其他內容添加到jar,則可以添加其他文件集。爲確保您的目標目錄中沒有以前運行的zip存檔,可以將其刪除或運行mvn clean
。
<assembly>
<id>jar-assembly</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
插件配置應該看起來像這樣。注意設置appendAssemblyId爲false將導致默認罐子從組裝罐子被替換,刪除元素,如果這不是所需的行爲:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/archive.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
爲什麼不使用pre-defined assembly jar -with-dependencies?下面的描述符文件:
<assembly>
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
</fileSet>
</fileSets>
</assembly>
要使用預定義的描述符使用assembly:assembly
,運行:
mvn assembly:assembly -DdescriptorId=jar-with-dependencies
爲了製造組件作爲正常構建週期的一部分,結合單個或單目錄魔力到封裝階段(見Usage):
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
[...]
</project>
該描述符將捆綁在jar中的項目的所有依賴關係,這並不總是需要的 –
你從哪裏得到這個鏈接?它與Maven站點上的內容不同:http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies – User1
@ User1 Google的錯誤:)我確實指向文檔的一個非常舊的版本。感謝您指出了這一點。 –
您可以發佈您組件的其餘部分? –