Gradle Concepts: Difference between revisions
Line 15: | Line 15: | ||
The configuration scripts are written in the ''Gradle build language'', which is a DSL and a Groovy extension. A build is configured by three types of configuration scripts, which together express build requirements and inform the build runtime: build scripts, a settings script and an init script. Each of those scripts contains executable statements and script blocks, which are a special case of executable statement, consisting in a method invocation on a closure. The logic expressed in a specific script applies to its delegate object. Though syntax is similar for all three scripts, specific blocks must make sense with the delegate object. The corresponding delegate objects for all three types of configuration scripts will be described below. | The configuration scripts are written in the ''Gradle build language'', which is a DSL and a Groovy extension. A build is configured by three types of configuration scripts, which together express build requirements and inform the build runtime: build scripts, a settings script and an init script. Each of those scripts contains executable statements and script blocks, which are a special case of executable statement, consisting in a method invocation on a closure. The logic expressed in a specific script applies to its delegate object. Though syntax is similar for all three scripts, specific blocks must make sense with the delegate object. The corresponding delegate objects for all three types of configuration scripts will be described below. | ||
[[Image:Gradle_Configuration_Scripts.png]] | |||
Revision as of 18:13, 17 May 2018
External
- DSL reference https://docs.gradle.org/current/dsl/
Internal
Overview
Gradle is a general-purpose build tool, which can build pretty much anything its configuration scripts declare. It is primarily used to build Java and Groovy, but it can build other languages as well.
Configuration Scripts
The configuration scripts are written in the Gradle build language, which is a DSL and a Groovy extension. A build is configured by three types of configuration scripts, which together express build requirements and inform the build runtime: build scripts, a settings script and an init script. Each of those scripts contains executable statements and script blocks, which are a special case of executable statement, consisting in a method invocation on a closure. The logic expressed in a specific script applies to its delegate object. Though syntax is similar for all three scripts, specific blocks must make sense with the delegate object. The corresponding delegate objects for all three types of configuration scripts will be described below.
- Build script structure: statements, blocks. A statement is .... A block is a method which takes a closure as an argument. Configuration closure. It configures the associated delegate object as it executes. There is a relatively low number of top-level blocks:
- allprojects{}
- artifacts{}
- Gradle Concepts Build Lifecycle. Configuration scripts and their delegate object.
- Core Types:
- Settings. https://docs.gradle.org/current/dsl/org.gradle.api.initialization.Settings.html
- Project. https://docs.gradle.org/current/dsl/org.gradle.api.Project.html
- Gradle. https://docs.gradle.org/current/dsl/org.gradle.api.invocation.Gradle.html
- Task https://docs.gradle.org/current/dsl/org.gradle.api.Task.html
- Configuration https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.Configuration.html
- A build consists of executing a series of tasks in succession.
- Extensions, as in publishing extension.
- Go through the lifecycle without plugins. Understand. Then introduce essential plugins.
- Most of Gradle's power comes from external plugins
- Java plugin.
- Maven publishing plugin.