Using Maven 'exec:exec' with Arguments

前端 未结 1 737
陌清茗
陌清茗 2020-12-14 02:54

I have a project configured to build and run with Maven. The project depends on platform specific native libraries, and I\'m using the strategy found here to manage those d

1条回答
  •  北海茫月
    2020-12-14 03:10

    I managed to find a reasonably elegant solution to my problem using Maven environment variables.

    The default values are defined as properties in the pom, and added to the exec plugin as arguments:

    ...
    
        defaultA
        defaultB
    
    ...
    
        org.codehaus.mojo
        exec-maven-plugin
        1.2.1
        
            java
            
                -Djava.library.path=${project.build.directory}/lib
                -classpath
                
                com.example.app.MainClass
                -a
                ${argumentA}
                -b
                ${argumentB}
            
        
    
    ...
    

    Now I can run with default parameters exactly as I did before:

    mvn exec:exec
    

    And I can easily override the defaults for each argument at the command line using:

    mvn exec:exec -DargumentA=alternateA -DargumentB=alternateB
    

    0 讨论(0)
提交回复
热议问题