Maven overwrite resource file in dependency

前端 未结 2 1046
轮回少年
轮回少年 2020-12-16 03:23

I have two Maven modules, A and B. A is a dependency of B. Both modules have a resource file named default.properti

2条回答
  •  心在旅途
    2020-12-16 03:59

    I know this is 3 years old but I had the same problem and this is the closest question I found, but still without correct answer so maybe someone will find it useful.

    Example maven-assembly descriptor based on jar-with-dependencies (fixes overriding of log4j.properties by dependencies):

    
        jar-with-dependencies
        
            jar
        
        false
        
            
                /
                false
                true
                
                    
                        log4j.properties
                    
                
                runtime
            
        
        
            
                ${project.build.outputDirectory}
                /
            
        
    
    

    The key is to provide different rules for dependencies and the actual project (top of hierarchy). Those can be split by using false and providing separate rules in fileSets for the project. Otherwise none of log4j.properties would be packed, including the top one.

提交回复
热议问题