Maven: how to filter the same resource multiple times with different property values?

后端 未结 4 725
暖寄归人
暖寄归人 2021-02-02 14:12

Our project uses Log4J, configured via log4j.properties file. We have multiple production servers, which log to different log files, so that the logs can be differentiated. So l

4条回答
  •  遇见更好的自我
    2021-02-02 14:55

    Although this is a bit old, I came across the thread recently and would like to propose an updated solution using the iterator-maven-plugin. An overview is found here: http://khmarbaise.github.io/iterator-maven-plugin/

    A specific example of how you can accomplish your goal would be to combine the iterator plugin with a copy resource and filter enabled. You could even add custom properties file to use as a filter in case you have other attributes that are unique per node with this approach.

    
    
        com.soebes.maven.plugins
        iterator-maven-plugin
        0.3
    
        
            
                configure-log-properties
                validate
                
                    iterator
                
                
                    log.file.postfix
                    1,2,3,4,5
                    
    
                        
                            
                                maven-resources-plugin
                                2.7
                            
    
                            copy-resources
    
                            
                                ${project.build.directory}/nodes/${log.file.postfix}
    
                                
                                    
                                        src/main/resources
                                        
                                            log4j.properties
                                        
                                        true
                                    
                                
                            
    
                        
                    
                
            
        
    
    

提交回复
热议问题