build script (in root dir) "build.gradle"
Build (1) -> (n) Projects -> sub projects
"ProjectDescriptor" is the representation
Gradle provided tasks: e.g. Java "Test"
Plugins provide more tasks
In configuration phase a task graph is created - Directed Acyclic Graph
Initialization (setting): read setting file, determine participants, create instances
Configuration (build scripts): evaluate build scripts, build a task graph
Execution
if only need to run
script to invoke / download on demand gradle
"gradlew" / "gradlew.bat" at root
Gradle uses caching to build faster
If task input / output not changed, task will be skipped
So avoid overlapping / overwriting out files
Kotlin is the recommended language
Simply use ".gradle.kts" where ".gradle" for groovy
Settings - "settings.gradle" - always include one even empty
Build script - "build.gradle"
buildSrc - included build for complex logics e.g. custom task and plugin implementation not shared
gradle.properties - properties
alternatively properties in build script or command line parameters
keep properties separate to build logics
Always include one (otherwise gradle traverses to the root)
See https://docs.gradle.org/current/javadoc/org/gradle/api/initialization/Settings.html
The "org.gradle.api.initialization.Settings" instance one-to-one correspondes to the file
Use for:
assemble multi-project build (include, includeFlat)
automatically create a root project
default name: directory
"includeFlat" include project parallel to root
Works with Maven repository
implementation (use in most case)
maven "compile"
use in most case
available to projects applies "Java Plugin"
api
maven "compile"
available to projects applies "Java Library Plugin"
compileOnly
maven "provided"
runtimeOnly
maven "runtime"
testImplementation
for that required to compile tests
testRuntimeOnly
for that required to run tests
providedCompile
for WAR plugin
like compileOnly and make sure aren't packaged in the WAR file
providedRuntime
for WAR plugin
like compileOnly and make sure aren't packaged in the WAR file
To get started to build a project:
check if wrapper is there - use wrapper
"gradle projects" - list projects
"gradle tasks" - find out tasks
gradle help --task <taskname>
gradle <taskname>