Table of Contents
The Base Plugin provides some tasks and conventions that are common to most builds and adds a structure to the build that promotes consistency in how they are run. Its most significant contribution is a set of lifecycle tasks that act as an umbrella for the more specific tasks provided by other plugins and build authors.
clean— type:DeleteDeletes the build directory and everything in it, i.e. the path specified by the
Project.getBuildDir()project property.check— lifecycle taskPlugins and build authors should attach their verification tasks, such as ones that run tests, to this lifecycle task using
check.dependsOn(task).assemble— lifecycle taskPlugins and build authors should attach tasks that produce distributions and other consumable artifacts to this lifecycle task. For example,
jarproduces the consumable artifact for Java libraries. Attach tasks to this lifecycle task usingassemble.dependsOn(task).build— lifecycle taskDepends on:
check,assembleIntended to build everything, including running all tests, producing the production artifacts and generating documentation. You will probably rarely attach concrete tasks directly to
buildasassembleandcheckare typically more appropriate.buildConfiguration— task ruleAssembles those artifacts attached to the named configuration. For example,
buildArchiveswill execute any task that is required to create any artifact attached to thearchivesconfiguration.uploadConfiguration— task ruleDoes the same as
buildConfiguration, but also uploads all the artifacts attached to the given configuration.cleanTask— task ruleRemoves the defined outputs of a task, e.g.
cleanJarwill delete the JAR file produced by thejartask of the Java Plugin.
The Base Plugin adds no configurations for dependencies, but it does add the following configurations for artifacts:
defaultA fallback configuration used by consumer projects. Let’s say you have project B with a project dependency on project A. Gradle uses some internal logic to determine which of project A’s artifacts and dependencies are added to the specified configuration of project B. If no other factors apply — you don’t need to worry what these are — then Gradle falls back to using everything in project A’s
defaultconfiguration.New builds and plugins should not be using the
defaultconfiguration! It remains for the reason of backwards compatibility.archivesA standard configuration for the production artifacts of a project. This results in an
uploadArchivestask for publishing artifacts attached to thearchivesconfiguration.
Note that the assemble task generates all artifacts that are attached to the archives configuration.
The Base Plugin only adds conventions related to the creation of archives, such as ZIPs, TARs and JARs. Specifically, it provides the following project properties that you can set:
archivesBaseName— default:$project.nameProvides the default
AbstractArchiveTask.getBaseName()for archive tasks.distsDirName— default: distributionsDefault name of the directory in which distribution archives, i.e. non-JARs, are created.
libsDirName— default: libsDefault name of the directory in which library archives, i.e. JARs, are created.
The plugin also provides default values for the following properties on any task that extends AbstractArchiveTask:
destinationDirDefaults to
$buildDir/$distsDirNamefor non-JAR archives and$buildDir/$libsDirNamefor JARs and derivatives of JAR, such as WARs.versionDefaults to
$project.versionor 'unspecified' if the project has no version.baseNameDefaults to
$archivesBaseName.