我有一个像这样设置的maven项目:
\src
\--main
\--java
\--fu
\--bar
\--AppMain.java
\--resources
\--log4j.xml
使用pom使用maven-resources-plugin
将我的资源文件移动到目标目录,如下所示:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>my/target/dir/config</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
maven-jar-plugin
创建这样的jar:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>fu.bar.AppMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
当我运行mvn clean install
时,我的目标位置包括已编译的jar和\config\log4j.xml
。但是,jar还包含log4j.xml
。
如何从jar中排除log4j.xml并仍然将其移至\my\target\dir\config
?
答案 0 :(得分:0)
将此添加到我的pom是诀窍:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>