maven-assembly-plugin
不能這樣工作。
那裏你想要做的是覆蓋裝配描述符jar-with-dependencies
的配置,這是不可能的。
如果你想要做的是創造類似於大會jar-with-dependencies
但沒有自己的項目的一些具體的類中創建一個罐子,你必須編寫自己的組裝和調用它在maven-assembly-plugin
像什麼如下。
大會src/assembly/jar-with-deps-with-exclude.xml
:
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<!-- TODO: a jarjar format would be better -->
<id>jar-with-dependencies-and-exclude-classes</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<outputDirectory>/</outputDirectory>
<directory>${project.build.outputDirectory}</directory>
<excludes>
<exclude>com/uiservices/controllers/*.*</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
這將不依賴創建裝配包裝並您的類除了排除的那些補充說。
然後在你的pom.xml:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>only</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/jar-with-deps-with-exclude.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
但是,如果你需要的是你沒有排除類經典罐子,你可以排除他們在maven-jar-plugin
直接:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>com/uiservices/controllers/*.*</exclude>
</excludes>
</configuration>
</plugin>
我和OP有同樣的問題,這個建議的解決方案解決了我的問題。 –