网上有些参考,大都是复制粘贴别人的,然而实际并不能很好的生效。
参考了RocketMQ的源码,找到了一种方法
可以删掉文件,或者目录(包,以及包下的文件)
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>process-classes</phase> <goals> <goal>run</goal> </goals> </execution> </executions> <configuration> <tasks> <echo>Removing slf4j-api's dummy StaticLoggerBinder and StaticMarkerBinder</echo> <!--一下分别是排除源文件目录,资源文件, 资源文件目录 --> <delete dir="target/classes/com/p2/temp/conceal"/> <delete file="target/classes/a.properties"/> <delete dir="target/classes/spring"/> </tasks> </configuration> </plugin>这个是利用了ant插件,ant本身就是类似于maven的项目管理工具,那么能不能不涉及ant,只用maven呢?(当然这里ant和maven之间的插件关系我没有详细研究)
答案是发扬我大天朝人民模仿的天赋
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> <configuration> <!--一下分别是排除源文件目录,资源文件, 资源文件目录 --> <excludes> <exclude>/com/p2/temp/conceal/</exclude> <exclude>/*.properties</exclude> <exclude>/spring/</exclude> </excludes> </configuration> </plugin>