Can I force Maven 2 to require a property to be specified on the command line?

后端 未结 4 1076
被撕碎了的回忆
被撕碎了的回忆 2020-12-31 02:19

I\'m setting up a maven build, and the destination server needs to be specified on the command line as a property (which is then used to select the appropriate profile), eg<

4条回答
  •  生来不讨喜
    2020-12-31 02:44

    To elaborate on edbrannin's alternate solution:

    
      4.0.0
      com.yourcompany
      yourproject
      1.0-SNAPSHOT
      
        
          
            maven-antrun-plugin
            
              
                checkParam
                initialize
                run
                
                  
                    
                  
                
              
            
          
        
      
    
    

    will give you the following output:

    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] An Ant BuildException has occured: 'env' property must be set
    

    IMHO the most straightforward way to do it (the one I'd go for personally).

    You could even control a set of allowed values using a nested containing and tags (see the Ant manual: http://ant.apache.org/manual/Tasks/conditions.html)

提交回复
热议问题