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 | -f filename | -d key | -h)
Options:
string Message to be used.
-d key Use default messages, key must be s[hort], m[edium] or l[ong].
-f filename Use specified file as input.
-h Help dialog.
Gradle task looks like:
task run (type: JavaExec){
description = "Secure algorythm testing"
main = 'main.Test'
classpath = sourceSets.main.runtimeClasspath
}
I've tried running gradle run -h
and it does not work.
Best Answer
Gradle 4.9+
This assumes your
build.gradle
is configured with the Application plugin. Yourbuild.gradle
should look similar to this:Pre-Gradle 4.9
Include the following in your
build.gradle
:Then to run:
gradle run -PappArgs="['arg1', 'args2']"