Building same project in Maven with different artifactid (based on JDK used)

后端 未结 5 688
悲哀的现实
悲哀的现实 2020-12-01 12:05

I have a scenario wherein my project needs to be compiled in different JDKs and the resulting artifact name should be different based on the JDK used. For example if the pro

5条回答
  •  暖寄归人
    2020-12-01 12:42

    A similar problem is the different variants of the JDBC api used in different versions of the JDK.

    I decided that these needed different arifactIds rather than classifiers.

    You can achieve this by setting a property in settings and then referencing this in the artifactId tag:

    
      4.0.0
      throwing-jdbc-${jdbc.version}
      Throwing JDBC
      
        
          jdbc3
          
            false
            [1.3,1.4,1.5]
          
          
            3.0
          
          
            
              
                org.codehaus.mojo
                build-helper-maven-plugin
                1.7
                
                  
                    src/jdbc3-variants/java
                  
                
                
                  
                    
                      add-source
                    
                  
                
              
            
          
        
        
          jdbc4
          
            false
            1.6
          
          
            4.0
          
          
            
              
                org.apache.maven.plugins
                maven-compiler-plugin
                
                  1.6
                  1.6
                
              
              
                org.codehaus.mojo
                build-helper-maven-plugin
                
                  
                    src/jdbc4/java
                    src/jdbc4-variants/java
                  
                
                
                  
                    
                      add-source
                    
                  
                
              
            
          
        
        
          jdbc41
          
            false
            1.7
          
          
            4.1
          
          
            
              
                org.apache.maven.plugins
                maven-compiler-plugin
                
                  1.7
                  1.7
                
              
              
                org.codehaus.mojo
                build-helper-maven-plugin
                
                  
                    src/jdbc4/java
                    src/jdbc4.1/java
                    src/jdbc4.1-variants/java
                  
                
                
                  
                    
                      add-source
                    
                  
                
              
            
          
        
      
      
        
          junit
          junit
          3.8.1
          test
        
      
      
        src/main/java
        
          
            org.apache.maven.plugins
            maven-source-plugin
            2.2.1
            
              
                verify
                
                  jar
                
              
            
          
        
      
    
    

提交回复
热议问题