我正在开发一个新的maven模块,并且在解决依赖项时遇到一些问题。目标是创建一个maven对象,它提供我的jar存档和一堆其他资源。我创建了我的pom.xml,并将带有install:install-file的jar存档安装到存储库中。这很好用。但现在我正在努力争取资源。这是一个例子:
如果没有需要在一个软件包中部署的资源,myJar存档就没用了。你能给我一个例子或提示我应该使用哪个插件吗?
答案 0 :(得分:0)
使用maven程序集插件。我们可以做到以下几点:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptors>
<descriptor>src/assembly/jar_with_resources.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
[...]
</project>
您需要定义jar_with_resources.xml描述符,其中您可以准确地说明程序集中包含的内容以及未包含的内容。