我想在多个项目中同步log4j和logback配置文件.我有一个项目(项目A)包含log4j和logback依赖项,以及配置文件.
项目A
- src/测试/资源
Project B has a dependency on 项目A. I would like to include the log config files in 项目A's JAR and have them automatically put in a specific target folder in Project B when resolving Maven dependencies for Project B.
I have tried maven-jar-plugin
in 项目A but it doesn't seem to work for my purpose.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<includes>
<include>src/test/resources/log4j2.xml</include>
<include>src/test/resources/回写测试.xml</include>
</includes>
</configuration>
</plugin>
任何帮助都将不胜感激.
谢谢
UPDATE:
虽然Eugene的答案被接受了,但我需要添加一个<resources>
条目,这样日志(log)配置文件就会包含在打包的JAR中.
<build>
<resources>
<resource>
<directory>src/test/resources</directory>
<includes>
<include>log4j2.xml</include>
<include>回写测试.xml</include>
</includes>
</resource>
</resources>
</build>
Executing mvn clean compile assembly:single deploy
from 项目A created and deployed the JAR with the log files included.
[INFO] --- maven-remote-resources-plugin:1.7.0:bundle (default) @ project-a ---
[INFO] Writing META-INF/maven/remote-resources.xml descriptor with 2 entries
从项目B执行mvn clean compile
将文件复制到输出目录
[INFO] --- maven-remote-resources-plugin:1.7.0:process (default) @ project-b ---
[INFO] Preparing remote bundle com.my.projects:project-a:1.0-SNAPSHOT
[INFO] Copying 2 resources from 1 bundle.