Gradle

[b]Gradle Plugins[/b]
a. two types: script plugins (by apply from) and binary plugins (by apply plugin-id)
Script plugins are automatically resolved and can be applied from a script on the local filesystem or at a remote location.
binary plugins apply plugins by their plugin id, which is a globally unique identifier, or name, for plugins.
b. two steps: resolve & apply
Resolving a plugin means finding the correct version of the jar which contains a given plugin and adding it the script classpath.
Applying a plugin means actually executing the plugin's Plugin.apply(T) on the Project you want to enhance with the plugin.
c. non-core binary plugins need to be resolved before applied via below 4 ways.
Including the plugin from the plugin portal or a custom repository using the plugins DSL (see Section 27.5.2, “Applying plugins with the plugins DSL”).
Including the plugin from an external jar defined as a buildscript dependency (see the section called “Applying plugins with the buildscript block”).
Defining the plugin as a source file under the buildSrc directory in the project (see Section 43.4, “Build sources in the buildSrc project”).
Defining the plugin as an inline class declaration inside a build script.

Most plugins need to obtain some configuration from the build script. One method for doing this is to use extension objects. The Gradle Project has an associated ExtensionContainer object that helps keep track of all the settings and properties being passed to plugins.

[b]Dependency Management[/b]:
1. Dependency configration
In Gradle dependencies are grouped into configurations(A configuration is simply a named set of dependencies). Configurations have a name, a number of other properties, and they can extend each other.Many Gradle plugins add pre-defined configurations to your project.
A project's configurations are managed by a configurations object.

configurations {
compile {
description = 'compile classpath'
transitive = true
}
runtime {
extendsFrom compile
}
}

2. Dependency types
External module dependency
Client module dependency
Project dependency
File dependency
Gradle API dependency
Local Groovy dependency

Configuration file
settings.gradle file tells Gradle how the project and subprojects are structured.
The root build.gradle is often used to share common configuration between the child projects.

Three Build phases:
Initialization
Configuration
Execution

[b]Properties[/b]:
1. System Properties
gradle xxx -DmySystemProp=xxx --> System.properties['someProperty']
2. Project Properties
gradle xxx -PmyProjectProp=xxx --> project.hasProperty('someProperty')
3. ext property
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值