Exclude properties file from WAR type submodule in Maven

I have a complex script for packaging my EAR projects, below is a kind of visual description to fully understand it:

ProjA.ear
 |-- ProjA.war
 |-- Util.war
 |   |-- WEB-INF
 |   |   |-- classes
 |   |   |   -- log4j.properties

      

Likewise, I have another project whose structure is:

ProjB.ear
 |-- ProjB.war
 |-- Util.war
 |   |-- WEB-INF
 |   |   |-- classes
 |   |   |   -- log4j.properties

      

Util.war is a common project (except log4j.properties) for ProjA and ProjB.

Below I have described the dependency of Util.war in both ProjA and ProjB:

    <dependency>
        <groupId>abc</groupId>
        <artifactId>xyz</artifactId>
        <version>${project.version}</version>
        <type>war</type>
    </dependency>

      

Now the question is, how do I have different versions of the log4j.properties file for each project, how do I configure Maven to add a custom ProjA file when packing ProjA, and use a different version when packing ProjB?

Please let me know if you don't understand the mixed scenario :).

Hello,

+3


source to share


1 answer


I think you can remove your log4j.properties from Util.war because it depends on the application. instead you can use the ProjA.ear / APP-INF / classes and the ProjB / APP-INF / classes folder to do this.

see What's the difference between app-inf and web-inf folders in JavaEE applications?

The Application Server automatically adds this folder to the Class-Path. But be aware of loading the first class of the parent first class



see Java EE and Java SE classloading

However, in Java EE, the class loader first tries to load the class itself and then delegate the class loading of that class to its parent class loader.

This operator depends on your application server.

0


source







All Articles