Using maven to build multiple resources assemblies that are very similar

后端 未结 2 827
时光取名叫无心
时光取名叫无心 2021-01-02 17:54

I\'m having a problem with this very redundant maven configuration.

The application I\'m working on sometimes gets built for environments that need alternate resourc

2条回答
  •  旧巷少年郎
    2021-01-02 18:23

    Assuming the following structure:

    src/
    └── main
        ├── assembly
        │   └── iterator.xml
        └── environment
            ├── dev
            │   └── server.properties
            ├── pretest
            │   └── server.properties
            ├── production
            │   └── server.properties
            ├── qa
            │   └── server.properties
            └── test
                └── server.properties
    

    where you can use the following assembly-descriptor like this:

    
      ${item}
      
        war
      
      false
      
        
          true
          false
        
      
      
        
          WEB-INF
          ${basedir}/src/main/environment/${item}/
          
            **
          
        
      
          WEB-INF
          ${project.build.directory}/environment/${item}
          
            **
          
      
      
    
    

    using the iterator-maven-plugin will solve the problem:

      
        
          
            com.soebes.maven.plugins
            iterator-maven-plugin
            0.2
            
              
                package
                
                  executor
                
                
                  
                    dev
                    test
                    qa
                    production
                    pretest
                  
                  
                    
                      single
                      
                        org.apache.maven.plugins
                        maven-assembly-plugin
                      
                      
                        
                          ${project.basedir}/src/main/assembly/iterator.xml
                        
                      
                    
                  
                
              
            
          
        
      
    

    The iterator-maven-plugin is available via maven central. I think you can adapt the above configuration/structure to your problem.

提交回复
热议问题