Open andreabisiach opened 3 years ago
This is still an issue as of v3.1.6, but I stumbled on the solution: task options must be specified as entries in the "Gradle Tasks" list, on the Run Configuration's "Gradle Tasks" tab.
Note that space-separated arguments wrapped in quotes are passed as a single argument. To pass multiple arguments, they must be unquoted. In contrast, running Gradle from a shell may split quoted arguments. For example, using --args="a b"
passes a single argument of "a b" in Buildship, but two arguments of "a" and "b" when invoking ./gradlew
from bash. Meanwhile, --args=a b
will set two arguments in Buildship, but will fail in bash unless all of "--args=a b"
is quoted.
Also, using "Project Settings"->"Program/JVM Arguments" doesn't work unless their values are prefixed with -D
or -P
. It doesn't matter which prefix is added to which argument type. This suggests that when Buildship invokes Gradle, it doesn't add the proper command-line switches to those arguments.
I hit a similar issue. I'm trying to run --write-verification-metadata sha256 help
from Gradle and also getting "no task found" no matter where I put the flag and its arguments. @AndrewFerr If you have an idea on how to make this one work it would be helpful.
@nlisker What worked for me was setting the run configuration's Gradle Tasks to just help
, and putting --write-verification-metadata
& sha256
as two items under Project Settings > Advanced Options > Program Arguments.
I tried AndrewFerr's solution. I don't get an error now, but the command doesn't run. The console shows
Working Directory: C:\Users\Nir\git\jfx
Gradle user home: C:\Users\Nir\.gradle
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 7.6
Java Home: C:\Program Files\Java\jdk-18
JVM Arguments: None
Program Arguments: --write-verification-metadata sha256
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: help
and nothing happens.
Expected Behavior
I have a Gradle build that applies the following plugins:
I need to pass parameters to the task 'run' while testing my application. From the command line i can run:
/gradlew run --args="someargs"
"someargs" is then passed to the public static void main(String[] args) of the class specified in:I expect to be able to do the same from Eclips using Buildship.
Current Behavior
I tried adding --args="someargs" to the command: But it raises the error: Task 'run --ars="someargs"' not found in root project
I have changed the command back to 'run' and added --args="someargs" as Program Argument Suddenly the task does not run at all and there is only this limited output in the Console. Nothing after "Gradle Tasks: run"
Gradle executions are empty
Context
I need to simulate passing run parameters to my java application build with Gradle while coding in Eclipse
Steps to Reproduce
System.out.println(String.join(",", args));
/gradlew run --args="someargs"
Your Environment
Gradle
Eclipse
Buildship
Eclipse Buildship Buildship, Eclipse Plug-ins for Gradle 3.1.5.v20210113-0904 org.eclipse.buildship