Maven War Plugin - add external resources from another jar
If I wanted to pull out a resource from another jar, say an image or XML file, is that possible? Would I use the 开发者_运维问答Maven Assembly Plugin or the War Plugin to do this? I want it to end up in a WAR file.
Walter
You could use the Dependency plugin in your war module and bind the dependency:unpack
goal to the generate-resources
phase. Check the Unpacking specific artifacts example.
I want to extract some resource form artefactory to used in other proyect, we need 2 plugins maven-dependency-plugin to extract and maven-clean-plugin to clean proyect. call first plugin execute the goal dependency:unpack.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>com.company.artifactory</artifactId>
<version>${project.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<includes>dirInsideJar/**/*.*</includes>
<outputDirectory>src/main/resources</outputDirectory>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/resources/dirInsideJar</directory>
</fileset>
</filesets>
</configuration>
</plugin>
The usage of the above is explained in this article.
精彩评论