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有同样的问题,这个建议的解决方案解决了我的问题。 –