我的maven项目中有以下结构
src
|-main
|-java
|-org.my....
|- ..classes
|-resources
|-configs
|-config1.xml
|-config2.xml
|-log4j.xml
我想在构建项目之后在jar之外获取resources/configs
目录。也就是说,在我运行mvn clean install
之后,我想在target
project.jar
configs
|-config1.xml
|-config2.xml
我正在使用maven-shade-plugin
,我尝试了以下内容,但它没有用。
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<manifestEntries>
<Main-Class>org.mainClass</Main-Class>
<Class-Path>configs</Class-Path>
<!--<resource>src/main/resources/configs</resource>-->
<!--<file>README.txt</file>-->
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
答案 0 :(得分:3)
请尝试使用此
https://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html
<outputDirectory>${basedir}/target/extra-resources</outputDirectory>