Accepted answer

The 'build' task in Gradle is commonly mistaken for a task that builds all tasks in a project. The 'build' task is actually provided by the java-base plugin and includes the following tasks:

compileJava, processResources, classes, jar, assemble, compileTestJava, processTestResources, testClasses, test, and check

Instead of running 'gradle build' I recommend the use of defaultsTasks

`defaultTasks 'build', 'shadowJar'`

Putting that line in your build.gradle will allow Gradle to be invoked without arguments such that both build and shadowJar are both run.

> gradle

I am not familiar with the shadowJar plugin, but if it exposes a task named shadowJar, the use of a dependsOn line in build.gradle could simplify the defaultTasks line.

project.tasks.shadowJar.dependsOn build

simplifies the defaultTasks line to

defaultTasks 'shadowJar'

Related Query

More Query from same tag