Clarification about -x for more tasks to exclude

The following command works:

  • gradle build -x test

it according with Gradle build without tests.

I read the Excluding tasks from execution section and indicates:

You can exclude a task from being executed using the -x or --exclude-task command-line option and providing the name of the task to exclude.

It is reflected in the first link. Until here, all is ok. But …

My questions are:

One: if I want exclude more tasks (for example javadoc), how should be the command?

  • gradle build -x javadoc -x test or gradle build -x javadoc test?

Use -x for each task to exclude? (former case) or use just one -x for all the tasks to exclude? (latter case)

Two Does the order of tasks matter?, so

  • is the same gradle build -x javadoc -x test and gradle build -x test -x javadoc?,

perhaps exists a special scenario.

Thank you.

One former, two no. :slight_smile:

1 Like

Thanks for the reply. Is there an official documentation about them? - if not I would create an issue in Github.

For “One” how you did you know that the latter does not work? Just testing or some error was thrown?
For “Two” based on the command’s output, Did you get that conclusion?

Thanks for your support

Is there an official documentation about them?

Gradle User Manual: Version 7.2 says

You can exclude a task from being executed using the -x or --exclude-task command-line option and providing the name of the task to exclude.

The commandline --help says

Specify a task to be excluded from execution.

So I’d say it pretty clearly mentions that you can exclude one task with one -x argument.
It does not mention though, that you can have multiple -x arguments, but that is the same as with other parameters like -I, -D, or -P.
If you think more clarification is necessary I also suggest you open a feature request issue for that.

For “One” how you did you know that the latter does not work? Just testing or some error was thrown?

Well, I use Gradle since its pre-1.0 phase and just know it pretty well. :smiley:
Besides that, there will not be an error as gradle build -x javadoc test is a valid command.
It says "execute build and test, but exclude javadoc" :-).

For “Two” based on the command’s output, Did you get that conclusion?

I’m not sure what you mean.
You asked whether it makes a difference in which order you exclude tasks.
And I said no, it does not matter in which order you don’t do tasks because you don’t do them.

The order in which you specify tasks that should be executed would be a different topic.
Because if the tasks do not appear in the others’ dependency tasks, then they are executed in the order you specify them.
But actually this should usually not really have a significance, because if the build works with one order but does not work with another order, then the build has a bug where some dependency declaration is missing.

1 Like

Thanks for the polite and well explained information.