Gradle build without tests

I want to execute gradle build without executing the unit tests. I tried:

$ gradle -Dskip.tests build

That doesn't seem to do anything. Is there some other command I could use?


You should use the -x command line argument which excludes any task.

Try:

gradle build -x test 

Update:

The link in Peter's comment changed. Here is the diagram from the Gradle user's guide


Try:

gradle assemble

To list all available tasks for your project, try:

gradle tasks

UPDATE:

This may not seem the most correct answer at first, but read carefully gradle tasks output or docs.

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.

You can add the following lines to build.gradle, **/* excludes all the tests.

test {
    exclude '**/*'
}

The accepted answer is the correct one.

OTOH, the way I previously solved this was to add the following to all projects:

test.onlyIf { ! Boolean.getBoolean('skip.tests') }

Run the build with -Dskip.tests=true and all test tasks will be skipped.


You can exclude tasks

 gradle build --exclude-task test 

https://docs.gradle.org/current/userguide/command_line_interface.html#sec:command_line_executing_tasks