Gradle task - pass arguments to Java application

后端 未结 7 2178
春和景丽
春和景丽 2020-12-04 14:40

I have a Java application that runs with a custom gradle task and the application requires some arguments upon being invoked. These are:

programName ( string         


        
相关标签:
7条回答
  • 2020-12-04 15:44

    Sorry for answering so late.

    I figured an answer alike to @xlm 's:

    task run (type: JavaExec, dependsOn: classes){
        if(project.hasProperty('myargs')){
            args(myargs.split(','))
        }
        description = "Secure algorythm testing"
        main = "main.Test"
        classpath = sourceSets.main.runtimeClasspath
    }
    

    And invoke like:

    gradle run -Pmyargs=-d,s
    
    0 讨论(0)
提交回复
热议问题