Gradle Project and Build Script: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 18: Line 18:
Gradle reads and builds artifacts that are compatible with Maven repositories, so they are described by [[Maven_Concepts#Maven_Coordinates|Maven project coordinates]]. Project coordinates [[#Project_Name.2C_artifactId|artifactId]], [[#Group.2C_groupId|groupId]] and [[#Version|version]] can be read or set in the [[Gradle_Settings_Script_and_Settings_Instance#Overview|settings configuration file]] via the [[Gradle_Settings_Script_and_Settings_Instance#ProjectDescriptor_-_Access_to_Projects_from_Settings|ProjectDescriptor]] interface, or in the build configuration file, described by this article, via the [https://docs.gradle.org/current/dsl/org.gradle.api.Project.html Project] interface. These details apply to single project builds and [[#Multi-Project_Builds|multi-project builds]].
Gradle reads and builds artifacts that are compatible with Maven repositories, so they are described by [[Maven_Concepts#Maven_Coordinates|Maven project coordinates]]. Project coordinates [[#Project_Name.2C_artifactId|artifactId]], [[#Group.2C_groupId|groupId]] and [[#Version|version]] can be read or set in the [[Gradle_Settings_Script_and_Settings_Instance#Overview|settings configuration file]] via the [[Gradle_Settings_Script_and_Settings_Instance#ProjectDescriptor_-_Access_to_Projects_from_Settings|ProjectDescriptor]] interface, or in the build configuration file, described by this article, via the [https://docs.gradle.org/current/dsl/org.gradle.api.Project.html Project] interface. These details apply to single project builds and [[#Multi-Project_Builds|multi-project builds]].


==Project Name, artifactId==
====Project Name, artifactId====





Revision as of 02:28, 19 May 2018

External

Internal

Overview

A Project is the main API to use to interact with Gradle. All top level statements within a "build.gradle" build script are delegated to the corresponding Project instance and when executed, modify its state.

In case of a multi-project build, It is possible to configure a project build from another build script associated with any project in the hierarchy. This capability is called cross-project configuration. Gradle implements cross-project configuration via configuration injection. Configuration injection is the default way to define common behavior.

Project Coordinates

Gradle reads and builds artifacts that are compatible with Maven repositories, so they are described by Maven project coordinates. Project coordinates artifactId, groupId and version can be read or set in the settings configuration file via the ProjectDescriptor interface, or in the build configuration file, described by this article, via the Project interface. These details apply to single project builds and multi-project builds.

Project Name, artifactId

The project name can only be set in the initialization phase, in the settings configuration, via the ProjectDescriptor interface. An attempt to set the project name in the configuration phase or execution phase via the Project interface will trigger a Gradle execution error.

Group, groupId

Version

Top-Level Script Blocks

allprojects{}

Applies the given configuration closure, in order, to the current project and all of its sub-projects.

subprojects{}

Applies the given configuration closure, in order, to all sub-projects of the current project.

artifacts{}

buildscript{}

configurations{}

dependencies{}

repositories{}

sourceSets{}

publishing{}

Multi-Project Builds

Root Project

Multi-Project Build Layout

Project Hierarchy

Sub-Project