Maven antrun: pass maven properties to ant

前端 未结 3 1848
不知归路
不知归路 2021-01-07 23:20

I am trying to pass maven properties (defined through profiles) to a antrun execution:


    

        
3条回答
  •  别那么骄傲
    2021-01-08 00:07

    You can pass the properties by defining new Ant properties (using the property tag in your target within the configuration). So for example:

    
    
        4.0.0
    
        com.test
        test-module
        test-module
        SNAPSHOT
    
        
            false
        
    
        
            
                customProfile
                
                    true
                
            
        
    
        
            
                
                    org.apache.maven.plugins
                    maven-antrun-plugin
                    1.7
                    
                        
                            compile
                            compile
                            
                                
                                    
                                    
                                    
                                
                            
                            
                                run
                            
                        
                    
                
            
        
    
    

    When I execute mvn compile on this pom the output is:

    main:
    [echo] Custom Ant Property is: false
    [echoproperties] #Ant properties
    [echoproperties] #Thu Aug 08 17:17:30 CEST 2013
    [echoproperties] ant.project.name=maven-antrun-
    [echoproperties] ant.version=Apache Ant(TM) version 1.8.2 compiled on December 20 2010
    [echoproperties] antProperty=false
    

    and when the command is mvn -PcustomProfile compile then the output is:

    main:
    [echo] Custom Ant Property is: true
    [echoproperties] #Ant properties
    [echoproperties] #Thu Aug 08 17:18:30 CEST 2013
    [echoproperties] ant.project.name=maven-antrun-
    [echoproperties] ant.version=Apache Ant(TM) version 1.8.2 compiled on December 20 2010
    [echoproperties] antProperty=true
    

    This works using maven 3.0.5.

提交回复
热议问题