【发布时间】:2013-07-07 13:55:17
【问题描述】:
我们正在尝试从同一个 pom 文件构建两个 jar(是的,我读过 this Sonotype blog post 说不这样做),因为出于内部政治原因,我们需要一个拥有所有资源的容器,而另一个没有。我们已经为 maven-jar-plugin 配置了我们认为应该可以工作的配置,但始终包含资源。这是我们的 pom 文件的相关部分:
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>package-consumer</id>
<phase>package</phase>
<configuration>
<classifier>consumer</classifier>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.bmp</exclude>
<exclude>**/*.jpg</exclude>
<exclude>**/*.jpeg</exclude>
<exclude>**/*.gif</exclude>
<exclude>**/*.xml</exclude>
<exclude>**/*.sql</exclude>
<exclude>**/*.log4j</exclude>
<exclude>**/*.properties</exclude>
<exclude>**/*.sh</exclude>
</excludes>
</resource>
</resources>
</configuration>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
当我们构建时,我们得到了 OurProject.Jar 和 OurProject-consumer.jar,正如人们所期望的那样,但所有相同的资源都在每个 jar 文件中。
我们尝试了<exclude>**/*</exclude> 和<exclude>**/resources/*.*</exclude>,而不是列表或特定扩展名。没有喜悦。我希望我们缺少一些基本的东西。
【问题讨论】: