update: this is my code: `build.gradle` ```applic...
# announcements
m
update: this is my code:
build.gradle
Copy code
application {
    // Define the main class for the application.
    mainClass = 'translator.AppKt'
}

task myExecTask(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    main = 'translator.AppKt'
    args project.getProperty('myFirstArgument') + ' ' + project.getProperty('mySecondArgument');
}
gradle myExecTask -PmyFirstArgument=foo -PmySecondArgument=bar
got error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
--------------------------------------------------------------- how do I pass multiple arguments to gradle? this doesn't work
gradle run myfirstargument mysecondargument
google 3
stackoverflow 2
m
also #C19FD9681
v
But it is
--args
that you are after
m
please read my updated post
v
Again, if you want to pass arguments from commandline to a
JavaExec
task, use
--args
m
@Vampire
--args
can only read first argument
do you have code snippet of it?
v
gradle myExecTask --args foo --args bar
And with your approach you concatenate the "arguments" making them effectively one, if you want to supply them separately, don't concatenate them but give them with comma. But still that is not the idiomatic way to get an argument from the commandline to the task
m
so what is the best practice to do this?
v
Do I really have to repeat it a third time? o_O
😂 1
Use
--args
m
I'm fairly new on this. pardon me
v
Being new is fine, letting me repeat the same thing three times is ... well ... 😉
m
jeez… just read the Gradle documentation!