Resource file conflict resolution

I have a project A that depends on another project B, the project looks like this

|
– A
|
–B

Both A and B have a resource file: src/main/resources/log4j2.xml

Gradle packs Project B’s log4j2.xml instead of Project A’s file.

Is there a way to specify which file to include?

I think you’ll find that both log4j2.xml are on the classpath and it’s classpath ordering determining which one wins.

Where are you seeing ProjectB’s log config “winning”? (eg when running tests or when actually running your application)

I personally don’t think any library should pack log4j2.xml inside. It’s only wars and applications which should pack logging config. Can you move from src/main/resources to src/test/resources so it’s not packed inside the jar?

Or perhaps you could set the log4j.configurationFile system property and use a unique path instead of log4j2.xml (eg log4j.configurationFile=projectA-log4j2.xml)