像這樣的東西應該工作:
<assembly>
<id>without-log4j-config</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>true</unpack>
<scope>runtime</scope>
<unpackOptions>
<excludes>
<exclude>**/log4j.xml</exclude>
<exclude>**/log4j.properties</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
<files>
<file>
<source>pom.xml</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
<fileSets>
<fileSet>
<useDefaultExcludes>false</useDefaultExcludes>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/java</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
<moduleSets>
<moduleSet>
<includeSubModules>false</includeSubModules>
<sources>
<outputDirectoryMapping>/</outputDirectoryMapping>
<excludeSubModuleDirectories>false</excludeSubModuleDirectories>
<fileSets>
<fileSet>
<directory>src/main/java</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</sources>
<binaries>
<dependencySets>
<dependencySet>
<unpack>true</unpack>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
你還需要這在你的POM:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>src/main/resources/whatever-you-name-the-snippet-above.xml</descriptor>
</descriptors>
</configuration>
</plugin>
這是一個重要的組成部分:
<appendAssemblyId>true</appendAssemblyId>
沒有它,如果你運行您的自定義程序集將被覆蓋。
相關(類似的事實)問題與附加的細節在它的答案:[自定義maven組裝](http://stackoverflow.com/q/3493381/320399) – blong 2013-08-08 16:37:17