Gradle Project
External
- Project API: org.gradle.api.Project
- Project DSL: https://docs.gradle.org/current/dsl/org.gradle.api.Project.html
Internal
Overview
A Gradle project typically represents a software component to be built by executing a set of tasks in sequence. A project has a direct class representation in the Gradle domain model: org.gradle.api.Project. The Project instance is exposed for query and modification via the build.gradle file. Each project has its own build.gradle file.
The project instance is available to the build.gradle script via the project
variable, which corresponds to the Project.getProject() accessor. The project instance is not available in settings.gradle, only the root project descriptor via rootProject
variable, which corresponds to Settings.getRootProject(). You are not required to use the project
variable when accessing properties and methods of the project from build.gradle, it is assumed you mean the Project instance.
Project API and build.gradle DSL
The build script classpath for the project can be configured with Project.buildscript(Closure) which corresponds to the "buildscript" DSL element:
buildscript {
// configuration closure
}
See:
Plugins for the build can be declare with PluginAware.apply(...), which corresponds to the "apply" DSL element:
apply plugin:|from: '...'
See:
The project's coordinates and other state properties are available through a series of DSL variables: name, group, version, description, path, etc. Some of the coordinates, such as "group" and "version" can be also set in build.gradle with a variable assignment, while others, such as "name" cannot be changed.
group = "io.playground"
version = "0.1.0"
description = "Example project"
logger.info "Project coordinates: ${group} ${name} ${version} ${description} ${path}"
See:
The project logger is also accessible in build.gradle. See:
Dependencies and configurations can be managed with the "dependencies" and "configurations" DSL elements:
dependencies {
// configuration closure
}
configurations {
// configuration closure
}
See:
The DSL exposes project-level methods for file resolution:
File f = file('./some/path/inside/project')
See:
The project allows declaring new tasks in build.gradle and also defining completely new tasks in-line. See: