Create two artifacts (war) for a single maven project

后端 未结 2 591
一生所求
一生所求 2021-01-28 09:34

I have a Java web project that we deploy on the server of two different customers, 99% of the code is the same, right now I have two ApplicationBuilders, which is the class that

2条回答
  •  时光说笑
    2021-01-28 09:54

    Create 2 different Maven Profiles, one for each customer, that copies a version of class ApplicationBuilderFactory to the right directory before compile stage.

    
        
            
                org.apache.maven.plugins
                maven-antrun-plugin
                1.7
                
                    
                        copy-files
                        generate-sources
                        
                            run
                        
                        
                            
                                
                            
                        
                    
                
            
        
    
    
    
         
            customer1
            
                    customer1
            
     
         
            customer2i
            
                    customer2
            
         
    

    Instead of having only one src/main/java/pkg/ApplicationBuilderFactory.java, we have:

    • src/main/java/pkg/ApplicationBuilderFactory.java.customer1
    • src/main/java/pkg/ApplicationBuilderFactory.java.customer2.

    So before compiling java code, we copy one of these versions to the src/main/java/pkg/ApplicationBuilderFactory.java.

    So generate 2 different .wars using 2 different profiles.

提交回复
热议问题