Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document behavior around -- to differentiate between task options and Gradle command-line flags #21158

Closed
big-guy opened this issue Jul 1, 2022 · 0 comments
Assignees
Labels
a:bug a:documentation Documentation content good first issue Good for newcomers in:invoking-gradle Running Executing in:writing-tasks task option
Milestone

Comments

@big-guy
Copy link
Member

big-guy commented Jul 1, 2022

When we add a new command-line option to Gradle, we run the risk that a task may have a task option with the same name. When that happens, the Gradle option wins. There's a way around this.

It's a common pattern in other tools (git, grep, etc) to use -- as a way to separate "options" from positional arguments. Gradle follows this same pattern, but there's no documentation for it. We should also check if there's test coverage.

This should be documented in our user manual but we should also consider putting something in gradle -h.

See #21154

Example

If you have this build:

abstract class MyTask extends DefaultTask {
    @Option(option="profile", description="foobar")
    void setProfile(String value) {
        System.out.println("Called setProfile")
    }
}

task mytask(type: MyTask)

If you run gradle mytask --profile, Gradle swallows the --profile as an option.

If you run gradle -- mytask --profile=foo, we treat --profile as a task option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug a:documentation Documentation content good first issue Good for newcomers in:invoking-gradle Running Executing in:writing-tasks task option
Projects
None yet
Development

No branches or pull requests

4 participants