我使用Maven
构建JAR
。当我检查JAR
时,我发现在META-INF
文件夹中有一个maven
文件夹。我希望它被排除在构建之外。我的pom.xml
中的当前构建代码如下:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>Libraries</classpathPrefix>
<mainClass>com.company.Main</mainClass>
</manifest>
<manifestEntries>
<Built-By>Me</Built-By>
</manifestEntries>
</archive>
<!-- <excludes>
<exclude>META-INF/maven/**</exclude>
</excludes> -->
</configuration>
</plugin>
<!-- ...more plugins... -->
</plugins>
</build>
我看到使用
exclude
标签可以排除一些内容,但是似乎并不起作用。这可能只适用于本地文件/文件夹?maven
文件夹不是源代码的一部分,它只是由Maven
添加进来的。
这个答案有点用,但它使用了不同的artifact,因此当我把它粘贴到我的pom.xml
中时会生成第二个JAR
。我想要使用我的当前构建代码,并像上面描述的那样排除maven
文件夹。如何使用maven
构建规则来实现呢?
<exclude>META-INF/maven/**</exclude>
对我有用。 - Wortig