Table of Contents

API Doc

这个接口是一个主要的API(你从构建文件中和Gradle 进行交互的一个API)
根据Project,你能够编程式访问所有Gradle 的特性 ..
点击查看Doc

Lifecycle

在Project 和build.gradle 文件之间 进行一对一的映射,在构建初始化阶段,Gradle将会为每一个参与到构建中的项目构建一个Project对象,如下所示:

  • 为构建创建Settings 实例…
  • 如果出现,评估settings.gradle 脚本,使用Settings 对象去配置它 …
  • 配置的Settings 对象去创建Project实例的体系 ..
  • 最终,通过执行每一个项目的build.gradle来评估每一个Project(如果Project出现,这里出现的意思有可能是被脚本过滤了,或者基于策略呈现的项目),基于广度优先算法顺序评估每一个project,例如一个项目优于它的子项目之前评估 ..但是这个顺序能够通过调用Project.evaluateDependsOnChildren() 或者通过使用Project.evaluationDependsOn(java.lang.String))增加一个显式的评估依赖 ..

    Tasks

    一个项目本质上是一个任务集合对象,每一个任务作为工作的基本单元执行,例如编译类或者运行单元测试,或者打包一个WAR文件,你能够使用TaskContainer上的其中一种方法例如:create()进行任务增加..
    例如TaskContainer.create(java.lang.String). 你能够定位/获取一个存在的任务(使用TaskContainer上的一种查询方法),例如TaskCollection.getByName(java.lang.String)).

    Dependencies

    一个项目通常具有需要为了使它工作的大量的依赖,同样一个项目通常生成大量的工件.
    例如其他项目能够使用的工件 ..这些依赖在配置中进行分类… 并且能够从仓库中抓取并更新…
    你能够通过:

  • Project.getConfigurations()方法去返回一个ConfigurationContainer进行配置管理 ..

  • Project.getDependencies() 方法返回一个DependencyHandler用来管理依赖.
  • Project.getArtifacts()方法返回的ArtifactHandler用来管理工件 …
  • Project.getRepositories()方法返回的RepositoryHandler用来管理仓库 ….

Multi-project Builds

项目被安排到项目的层次结构中,一个项目具有一个名称,在体系中具有一个完全修饰限定路径唯一标识它 ..

Plugins

插件能够被用来模块化 以及重用项目配置,插件能够通过PluginAware.apply(java.util.Map))方法应用或者通过PluginDependenciesSpec 插件脚本块 ..

Dynamic Project Properties

Gradle 执行项目构建文件并通过Project实例配置此项目..
脚本中的任何属性或者方法将被代理到相联系的Project对象 …
这就意味着你能够使用属于Project接口的任何方法或者属性- 直接在脚本中使用 ..
例如:

  1. defaultTasks('some-task') // Delegates to Project.defaultTasks()
  2. reportsDir = file('reports') // Delegates to Project.file() and the Java Plugin

你能够通过project属性访问Project 实例. 在某些情况下能够使得脚本更加的干净 ..
例如:
你通过project.name 而不是name 访问项目的名称 ..
一个项目有5个属性’scope’,它是用来查询属性的,你能够通过在构建文件中通过名称访问这些属性,或者通过调用项目的Project.property(java.lang.String)),这些scope如下:

  • Project 对象自身,这个范围包括了任何属性getter 以及由Project实现类所声明的setter … 例如 Project.getRootProject()能够用于访问 rootProject属性 …

这个范围的属性是可读或者可写的,依赖于属性相关的getter / setter 方法.

  • 这个项目的额外属性

每一个项目都包含了额外的属性Map,它们能够包含任意的名称-值对 ..
一旦定义,这个范围的属性将是可读且可写的,查看extra properties .

  • 由插件加入到此项目的扩展.

每一个扩展都是必要的(与扩展同名的)只读属性 - 每个扩展应该对应了一个名称 ..

  • 由插件增加到这个项目的约定属性 ..

一个插件能够增加属性以及方法到项目中(通过Convention对象)..
这个范围的属性也许是可读或者可写的 .. 依赖于约定对象 ..

  • 项目的任务

一个任务可以通过属性名的方式 使用它的名称进行访问…
这个范围内的属性都是只读的,例如一个叫做compile的任务 只能够通过comile属性访问 ….

  • 从父项目中继承的额外的属性以及约定属性

这些属性访问将会递归到根项目(这个范围的属性仅仅是只读的)…
当读取一个属性的时候,项目将会从上上下的根据此范围顺序进行查找,并且返回第一个发现此属性的范围中的属性值 ,如果没有发现,则抛出一个异常 …
查看Project.property(java.lang.String))

Extra Properties

所有的额外属性必须通过”ext” 命名空间进行定义,一旦有一个额外的属性已经被定义,
它在自己的项目中能够直接访问(例如项目中,任务中或者独立的子项目中) 并且它能够读取并更新 … - 根据前面针对扩展元素的定义 …可以知道 ..
仅仅只有初始化的声明需要通过命名空间完成 …

  1. project.ext.prop1 = "foo"
  2. task doStuff {
  3. ext.prop2 = "bar"
  4. }
  5. subprojects { ext.${prop3} = false }

读取”extra”属性 通过 “ext” 或者通过拥有者对象(project,隐式调用)

  1. ext.isSnapshot = version.endsWith("-SNAPSHOT")
  2. if (isSnapshot) {
  3. // do snapshot stuff
  4. }

Dynamic Methods

一个项目拥有5个方法作用域(“scope”),它们被用来查找方法:

  • Project 对象自身
  • build file,在project中查询匹配声明在构建文件中的方法 …
  • 由插件增加到此project的扩展 … 每一个扩展被信任为一个方法(它能够调用一个闭包或者Action 作为一个参数)
  • 由插件增加到项目中的约定方法. 一个插件能够增加属性以及方法到project中(通过项目Convention对象) ..
  • 这个项目的任务

为每一个任务增加的方法,通过任务的名称作为方法名 并携带一个闭包或者 Action 参数 .. 这种方法为关联的任务调用Task.configure(groovy.lang.Closure) 并使用提供的闭包进行配置 .. 举个例子,项目中包含了一个叫做compile的任务,那么将会拥有一个具有以前签名的方法: void compile(Closure configureClosure) ..

  • 父项目的方法,递归到根项目
  • 项目的属性的值是一个闭包 .. 这些闭包作为方法对待并通过提供的参数可以进行调用 ..

    Properties

    | Property | Description | | —- | —- | | allprojects | 包含了此项目和所有的子项目 | | ant | 此项目的AntBuilder,你能够使用它在构建文件中执行ant项目 … | | artifacts | 返回一个处理器可以用来配置由此项目生产的工件. | | buildDir | 此项目的构建目录. 这个构建目录是一个所有生成的工件将会放置的地方.. 此构建目录的默认值: projectDir/build | | buildFile | 此项目的构建脚本 | | buildscript | 此项目的构建脚本处理器,你能够使用此处理器查询此项目的构建脚本的详情.并管理用来编译并执行项目的构建脚本的类路径 … | | childProjects | The direct children of this project. | | configurations | The configurations of this project. | | convention | deprecated
    The Convention for this project. | | defaultTasks | 此项目的默认任务列表的名称,当开始构建时没有任务名提供的时候使用 . | | dependencies | 此项目的依赖管理器,用来管理依赖,新增或者删除.. 为了访问已经分配的依赖,这个配置能够被使用 … | | dependencyLocking | 访问配置依赖锁 | | description | The description of this project, if any. | | extensions | 允许用来为项目增加扩展,对于其他插件来说特别有用 … | | gradle | 此项目属于哪一个Gradle调用. | | group | The group of this project. Gradle always uses the toString() value of the group. The group defaults to the path with dots as separators. | | logger | The logger for this project. You can use this in your build file to write log messages. | | logging | LoggingManager 被用来读取日志并控制此项目构建脚本的标准输入输出/错误捕捉
    默认,System.out 重定向到Gradle 的日志系统中,并且使用QUIET 日志级别 …
    System.err 重定向到ERROR 日志级别 … | | name | The name of this project. Project.getPath()用来获取此项目体系下的唯一标识约束(完全修饰限定路径)
    项目名不具备唯一约定标识特性 … | | normalization | 提供对配置输入规范化的访问 | | parent | The parent project of this project, if any. | | path | The path of this project. The path is the fully qualified name of the project. | | pluginManager | 插件管理器 - 是一个插件感知对象 | | plugins | 应用到当前项目的插件的容器 | | project | project 对象,此方法在构建文件中通常有用,显式的访问project的属性和方法,使得构建脚本更加清晰 .. 例如:
    通过project.name 访问 而不是 name ..
    此方法允许你访问一个范围内的属性(可能这个属性被隐藏,例如,一个方法或者闭包) | | projectDir | The directory containing the project build file.
    包含项目构建文件的目录 .. | | properties | The properties of this project. See here for details of the properties which are available for a project.
    此项目的属性(只属于项目的属性) | | repositories | Returns a handler to create repositories which are used for retrieving dependencies and uploading artifacts produced by the project.
    管理仓库的处理器(被用来抓取依赖以及由项目产生工件上传) | | resources | Provides access to resource-specific utility methods, for example factory methods that create various resources.
    提供对特定于资源方法的访问,例如 创建各种资源的工厂方法 … | | rootDir | The root directory of this project. The root directory is the project directory of the root project.
    此项目的根目录,此根目录是根项目的项目目录 .. | | rootProject | The root project for the hierarchy that this project belongs to. In the case of a single-project build, this method returns this project.
    此项目所属的体系对应的根项目,对于但项目构建,此方法返回当前project(项目) | | state | The evaluation state of this project. You can use this to access information about the evaluation of this project, such as whether it has failed.
    此项目的评估状态,你能够使用它访问此项目的评估信息,例如它是否失败 … | | status | The status of this project. Gradle always uses the toString() value of the status. The status defaults to release.
    此项目的状态,Gradle 总是使用此状态的toString()
    此状态模式是release | | subprojects | The set containing the subprojects of this project.
    此项目包含的子项目 (非直接和直接)… | | tasks | The tasks of this project.
    项目的任务 | | version | The version of this project. Gradle always uses the toString() value of the version. The version defaults to unspecified.
    项目的版本,Gradle 总是使用此版本的toString的值,默认是unspecified … 未指定 … |

application plugin added Properties

Property Description
application The JavaApplication added by the application plugin.
applicationDefaultJvmArgs Array of string arguments to pass to the JVM when running the application
运行此应用所传递给JVM的string 数组参数
applicationDistribution The specification of the contents of the distribution.
发布的内容的规范..
applicationName The name of the application.
executableDir Directory to place executables in
放置可执行文件的位置 ..
mainClassName The fully qualified name of the application’s main class.
应用主类的完全限定类名 …

checkstyle plugin 增加的属性

checkstyle 由checkstyle 插件增加的CheckstyleExtension .

codenarc plugin 增加的属性

codenarc codenarc插件增加的codenarc

distribution plugin 增加的属性

distribution 此插件增加的DistributionContainer

ear plugin 增加的属性

Property Description
appDirName The name of the application directory, relative to the project directory. Default is “src/main/application”.
应用目录的名称,相对于项目目录,默认是src/main/application …
deploymentDescriptor A custom deployment descriptor configuration. Default is an “application.xml” with sensible defaults.
一个自定义部署描述符配置..
默认是一个具有合理默认值的application.xml ..
generateDeploymentDescriptor Specifies if the deploymentDescriptor should be generated if it does not exist. Default is true.
如果指定的部署描述符不存在,是否指定生成,默认true …
libDirName The name of the library directory in the EAR file. Default is “lib”.
EAR文件中library 目录的名称
默认是lib …

eclispse plugin 增加的属性

eclipse 此插件增加的 EclipseModel 属性

idea plugin 增加的属性

idea 由idea插件增加的 IdeaModel 属性

jacoco plugin 增加的属性

jacoco 增加的一个JacocoPluginExtension <-> 扩展属性

java plugin 增加的属性

archivesBaseName The base name to use for archive files.
归档文件的基础名称
base The BasePluginExtension added by the java plugin.
由java 插件增加的 BasePluginExtension .
distsDirName The name for the distributions directory. This in interpreted relative to the project’ build directory.
发行目录的名称,相对于项目的构建目录解析 ..
distsDirectory The directory to generate TAR and ZIP archives into.
生成Tar 以及Zip 归档文件的目录 …
docsDir Returns a file pointing to the root directory supposed to be used for all docs.
指向所有文档的根目录的文件
docsDirName The name of the docs directory. Can be a name or a path relative to the build dir.
同上,但是它是文档目录的名称,也可以是一个相对于构建目录的路径 …
java The JavaPluginExtension added by the java plugin.
libsDirName The name for the libs directory. This in interpreted relative to the project’ build directory.
libsDirectory The directory to generate JAR and WAR archives into.
reporting The ReportingExtension added by the java plugin.
sourceCompatibility The source compatibility used for compiling Java sources.
sourceSets The source sets container.
targetCompatibility The target compatibility used for compiling Java sources.
testReportDir Returns a file pointing to the root directory to be used for reports.
testReportDirName The name of the test reports directory. Can be a name or a path relative to ReportingExtension.getBaseDir().
测试报告目录的名称,能够是名称或者相对于ReportingExtension.getBaseDir()的路径 ..
testResultsDir Returns a file pointing to the root directory of the test results.
返回一个指向测试结果的根目录文件 …
testResultsDirName The name of the test results directory. Can be a name or a path relative to the build dir.
测试结果目录的名称,能够是名称或者相对于构建目录的路径…

pmd 插件增加的属性

pmd pmd插件增加的一个PmdExtension 的扩展

project-report 插件增加的属性

projectReportDir 这个目录指定了生成的项目报告应该放入哪里(这是一个文件)
projectReportDirName 同上 但是指定的是项目报告的目录名称 - 相对于项目报告目录而言 …

publishing 插件增加的属性

publishing 发布插件增加的一个PublishingExtension 扩展

signing 插件增加的属性

signing 签名插件增加的一个SigningExtension扩展 ..

visual-studio 插件增加的属性

visualStudio visual-studio插件增加的VisualStudioRootExtension 扩展 .

war 插件增加的属性

webAppDir 指定了web应用目录
webAppDirName web应用目录的名称,相对于项目目录

xcode 插件增加的属性

xcode xcode插件增加的XcodeRootExtension

Methods

Method Description
absoluteProjectPath)
(path)
转换一个名称为绝对项目路径
根据相对于项目进行解析 ..
afterEvaluate)
(closure)
在项目评估之后立即调用增加的闭包..
这个项目作为参数传递给此闭包.
例如一个监听器获取通知 - 当一个构建文件所属的项目已经被执行 ..
一个父项目也许会增加这些监听器到子项目中 …
afterEvaluate)
(action)
此项目评估之后立即执行这些action…
allprojects)
(action)
配置这个项目以及每一个子项目 …
ant)
(configureAction)
Executes the given action against the AntBuilder for this project. You can use this in your build file to execute ant tasks. See example in javadoc for Project.getAnt()
使用给定AntBuilder执行给定的动作
你能够在构建文件中使用执行ant任务..
apply)
(closure)
Applies zero or more plugins or scripts.
apply)
(options)
Applies a plugin or script, using the given options provided as a map. Does nothing if the plugin has already been applied.
应用一个插件或者脚本,使用给定的选项提供一个map参数传递,如果插件已经应用不做任何事情 …
groovy 语法支持非常简单的map属性传递 … 作为一个options进行设置 ..
apply)
(action)
Applies zero or more plugins or scripts.
artifacts)
(configureAction)
Configures the published artifacts for this project.
配置此项目需要发布的所有工件 …
beforeEvaluate)
(closure)
Adds a closure to be called immediately before this project is evaluated. The project is passed to the closure as a parameter.
在项目执行之前执行此增加的闭包,这个项目作为参数传递到闭包中 ..
beforeEvaluate)
(action)
Adds an action to execute immediately before this project is evaluated.
configure)
(objects, configureClosure)
Configures a collection of objects via a closure. This is equivalent to calling Project.configure(java.lang.Object, groovy.lang.Closure)) for each of the given objects.
通过一个闭包配置一个对象集合,这等价于在每一个项目上执行Project.configure(java.lang.Object,groovy.lang.Closure)
configure)
(objects, configureAction)
Configures a collection of objects via an action.
configure)
(object, configureClosure)
Configures an object via a closure, with the closure’s delegate set to the supplied object. This way you don’t have to specify the context of a configuration statement multiple times.
通过闭包配置一个对象,将闭包的代理设置为应用的对象,这种方式你不必在配置语句中多次指定上下文 ..
container)
(type)
Creates a container for managing named objects of the specified type. The specified type must have a public constructor which takes the name as a String parameter.
创建指定类型的管理命名对象的容器,这个指定的类型必须具有一个公共构造器 ,能够接受字符串 name参数 ..
container)
(type, factoryClosure)
Creates a container for managing named objects of the specified type. The given closure is used to create object instances. The name of the instance to be created is passed as a parameter to the closure.
为指定的类型 - 创建一个用来管理命名对象的容器 ..
给定的闭包被用来创建对象实例,这个实例的名称能够通过闭包的参数传递 获取创建…
container)
(type, factory)
Creates a container for managing named objects of the specified type. The given factory is used to create object instances.
为指定类型 创建一个用来管理命名对象的容器 ..
这个给定的工厂被用来创建一个对象实例 …
copy)
(closure)
Copies the specified files. The given closure is used to configure a CopySpec, which is then used to copy the files. Example:
拷贝指定的文件,给定的闭包被用来配置一个CopySpec,例如它们被用来拷贝文件 …
copy)
(action)
Copies the specified files. The given action is used to configure a CopySpec, which is then used to copy the files.
拷贝特定的文件,但是通过给定的action配置CopySpec..
copySpec)
()
Creates a CopySpec which can later be used to copy files or create an archive.
创建一个CopySpec 之后使用它copy文件或者创建归档文件 …
copySpec)
(closure)
Creates a CopySpec which can later be used to copy files or create an archive. The given closure is used to configure the CopySpec before it is returned by this method.
使用闭包创建一个CopySpec之后被用来复制文件或者创建一个归档文件,这个给定的闭包被用来配置CopySpec(在它通过此方法返回之前)
copySpec)
(action)
Creates a CopySpec which can later be used to copy files or create an archive. The given action is used to configure the CopySpec before it is returned by this method.
通过给定的action配置CopySpec …
defaultTasks)
(defaultTasks)
Sets the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
设置项目的默认任务的名称,当开始构建时没有提供任务名称的时候被使用 …
delete)
(paths)
Deletes files and directories.
delete)
(action)
Deletes the specified files. The given action is used to configure a DeleteSpec, which is then used to delete the files.
配置如何删除文件(通过此action 配置给定的DeleteSpec)
dependencyLocking)
(configuration)
Configures dependency locking
evaluationDependsOn)
(path)
Declares that this project has an evaluation dependency on the project with the given path.
声明这个项目在给定的路径上已经有一个评估依赖 …
exec)
(closure)
Executes an external command. The closure configures a ExecSpec.
执行外部命令 … 这个闭包配置一个ExecSpec …
exec)
(action)
Executes an external command.
file)
(path)
Resolves a file path relative to the project directory of this project. This method converts the supplied path based on its type:
相对于项目的目录解析一个文件路径 ..
这个方法基于它的类型转换给定的路径。。。
file)
(path, validation)
Resolves a file path relative to the project directory of this project and validates it using the given scheme. See PathValidation for the list of possible validations.
基于项目的目录相对解析一个文件路径并且通过给定的方案验证它(查看路径验证查看验证详情)
fileTree)
(baseDir)
Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per Project.file(java.lang.Object)).
创建一个新的可配置文件树 - 使用给定的base 目录 ..
这个给定的baseDir 路径在每一个Project.file(java.lang.Object)上都会进行评估 …
为了创建一个可配置的文件树
fileTree)
(baseDir, configureClosure)
Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per Project.file(java.lang.Object)). The closure will be used to configure the new file tree. The file tree is passed to the closure as its delegate. Example:
创建一个新的可配置的文件树 - 通过base目录,给定的baseDir用Project.file(…)进行评估 ..
这个闭包将会被用来配置新的文件树 ..
举个例子 … 这个文件树将作为闭包代理…
fileTree)
(baseDir, configureAction)
Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per Project.file(java.lang.Object)). The action will be used to configure the new file tree. Example:
通过给定的action 进行可配置文件树配置 …
fileTree)
(args)
Creates a new ConfigurableFileTree using the provided map of arguments. The map will be applied as properties on the new file tree. Example:
使用提供的参数map 创建一个新的可配置文件树 ..
这个map 将作为属性应用到每一个新的文件树。
files)
(paths, configureClosure)
Creates a new ConfigurableFileCollection using the given paths. The paths are evaluated as per Project.files(java.lang.Object[])). The file collection is configured using the given closure. The file collection is passed to the closure as its delegate. Example:
使用给定的路径创建一个新的可配置的文件集合 ..
这个路径通过每一个…评估 ..
通过给定闭包配置文件集合 … 文件集合作为闭包的代理对象 ..
files)
(paths, configureAction)
Creates a new ConfigurableFileCollection using the given paths. The paths are evaluated as per Project.files(java.lang.Object[])). The file collection is configured using the given action. Example:
同上,使用action …
files)
(paths)
Returns a ConfigurableFileCollection containing the given files. You can pass any of the following types to this method:
返回包含给定文件的可配置的文件集合 ..
你能够传递此方法允许的任何类型进行调用
… 字符串数组 … 等等 详情查看gradle的doc …
它支持多种类型 …
findProject)
(path)
Locates a project by path. If the path is relative, it is interpreted relative to this project.
通过路径定位一个项目,如果路径是相对的,它是相对于此项目进行解析 …
findProperty)
(propertyName)
Returns the value of the given property or null if not found. This method locates a property as follows:
返回给定属性的值或者null …
getAllTasks)
(recursive)
Returns a map of the tasks contained in this project, and optionally its subprojects.
返回此项目中所包含的任务map …
可能包含以及子项目中的 …
getTasksByName)
(name, recursive)
Returns the set of tasks with the given name contained in this project, and optionally its subprojects. NOTE: This is an expensive operation since it requires all projects to be configured.
返回此项目中给定名称的任务集合 ..
可能包含子项目中的任务集合 ..
这是一个昂贵的操作 -因为它会导致所有的项目被配置 …
hasProperty)
(propertyName)
Determines if this project has the given property. See here for details of the properties which are available for a project.
判断给定项目中是否拥有这个属性 …
here 查看一个项目中属性查找规则 ..
javaexec)
(closure)
Executes a Java main class. The closure configures a JavaExecSpec.
执行一个Java 主类 ..
通过闭包配置一个JavaExecSpec ..
javaexec)
(action)
Executes an external Java process.
执行外部Java 程序 …
mkdir)
(path)
Creates a directory and returns a file pointing to it.
创建一个目录并返回指向它的目录 …
normalization)
(configuration)
Configures input normalization.
配置输入标准化 …
project)
(path)
Locates a project by path. If the path is relative, it is interpreted relative to this project.
根据目录定位一个项目,如果目录是相对的 ..
它基于当前项目定位给定项目 …
project)
(path, configureClosure)
Locates a project by path and configures it using the given closure. If the path is relative, it is interpreted relative to this project. The target project is passed to the closure as the closure’s delegate.
它使用给定的路径以及闭包定位一个项目,如果路径是相对的,它相对此项目解析 ..
目标项目将作为闭包的代理对象 ..
project)
(path, configureAction)
Locates a project by path and configures it using the given action. If the path is relative, it is interpreted relative to this project
同上,使用action 配置 ..
property)
(propertyName)
Returns the value of the given property. This method locates a property as follows:
返回给定属性的值 …
relativePath)
(path)
Returns the relative path from the project directory to the given path. The given path object is (logically) resolved as described for Project.file(java.lang.Object)), from which a relative path is calculated.
返回从项目目录到给定路径的相对路径。给定的路径对象(逻辑上)按照 Project.file(java.lang.Object) 的描述进行解析,从中计算相对路径。
relativeProjectPath)
(path)
Converts a name to a project path relative to this project.
转换一个名字到相对此项目的项目路径
setProperty)
(name, value)
Sets a property of this project. This method searches for a property with the given name in the following locations, and sets the property on the first location where it finds the property.
设置项目的属性 …
subprojects)
(action)
Configures the sub-projects of this project
配置子项目(包括非直接子项目)
sync)
(action)
Synchronizes the contents of a destination directory with some source directories and files. The given action is used to configure a CopySpec, which is then used to synchronize the files.
同步具有某些源目录和文件的目标目录的内容 ..
给定的action 被用来配置CopySpec …
它们被用来同步文件 …
tarTree)
(tarPath)
Creates a new FileTree which contains the contents of the given TAR file. The given tarPath path can be:
针对给定的Tar创建包含它的内容的FileTree ..
task)
(name)
Creates a Task with the given name and adds it to this project. Calling this method is equivalent to calling Project.task(java.util.Map, java.lang.String)) with an empty options map.
创建具有给定名称的任务并增加到项目中 ..
此方法等价于Project.task … (包含一个空选项的map参数的调用)
task)
(name, configureClosure)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given closure is executed to configure the task.
同上,在任务返回之前,使用给定闭包配置任务 …
task)
(name, configureAction)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given action is executed to configure the task.
同上 使用action …
task)
(args, name)
Creates a Task with the given name and adds it to this project. A map of creation options can be passed to this method to control how the task is created. The following options are available:
同上 通过map options 控制如何创建任务。。。
task)
(args, name, configureClosure)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given closure is executed to configure the task. A map of creation options can be passed to this method to control how the task is created. See Project.task(java.util.Map, java.lang.String)) for the available options.
同上,给定的闭包用来配置任务,map 选项被用来控制如何创建任务 …
查看doc 了解详情。。
uri)
(path)
Resolves a file path to a URI, relative to the project directory of this project. Evaluates the provided path object as described for Project.file(java.lang.Object)), with the exception that any URI scheme is supported, not just ‘file:’ URIs.
解析文件路径为URI,相对于此项目的项目目录,评估由Project.file的描述进行处理 …支持多种URI 方案 …不仅仅是file
zipTree)
(zipPath)
Creates a new FileTree which contains the contents of the given ZIP file. The given zipPath path is evaluated as per Project.file(java.lang.Object)). You can combine this method with the Project.copy(groovy.lang.Closure)) method to unzip a ZIP file.
创建给定ZIP文件内容的FileTree, 给定的zip路径根据Project.file进行评估 … 你能够使用Project.copy(groovy.lang.Closure)方法去解压一个ZIP …
因为闭包如何复制是由我们自己定制的 …

ear插件增加的方法

Method Description
appDirName)
(appDirName)
Allows changing the application directory. Default is “src/main/application”.
改变应用的目录
deploymentDescriptor)
(configureAction)
Configures the deployment descriptor for this EAR archive.配置此EAR归档文件的部署描述符
libDirName)
(libDirName)
Allows changing the library directory in the EAR file. Default is “lib”.
改变Ear文件中的库目录

java 插件增加的方法

Method Description
manifest)
()
Creates a new instance of a Manifest.
manifest)
(closure)
Creates and configures a new instance of a Manifest. The given closure configures the new manifest instance before it is returned.
根据给定的闭包配置新创建的mainfest 实例 …
manifest)
(action)
Creates and configures a new instance of a Manifest.

Script blocks

这些在前面的说法是动态方法中的闭包属性(许多都是插件提供的)

Block Description
allprojects) Configures this project and each of its sub-projects.
ant) Executes the given closure against the AntBuilder for this project. You can use this in your build file to execute ant tasks. The AntBuild is passed to the closure as the closure’s delegate. See example in javadoc for Project.getAnt()
artifacts) Configures the published artifacts for this project.
buildscript) Configures the build script classpath for this project.
配置此项目的构建脚本类路径
configurations) Configures the dependency configurations for this project.
配置此项目的依赖配置
dependencies) Configures the dependencies for this project.
配置此项目的依赖
repositories) Configures the repositories for this project.
subprojects) Configures the sub-projects of this project.

application 插件增加的脚本块

application )由应用插件增加的 JavaApplication 脚本代码块

checkstyle 插件增加的脚本块

checkstyle) Configures the CheckstyleExtension added by the checkstyle plugin.

codenarc 插件增加的脚本块

codenarc) Configures the CodeNarcExtension added by the codenarc plugin.

distribution 插件增加的脚本块

distributions) Configures the DistributionContainer added by the distribution plugin.

ear 插件增加的脚本块

deploymentDescriptor) Configures the deployment descriptor for this EAR archive.

eclipse 插件增加的脚本块

eclipse) Configures the EclipseModel added by the eclipse plugin.

idea 插件增加的脚本块

idea) Configures the IdeaModel added by the idea plugin.

jicoco 插件的增加的脚本快

jacoco) Configures the JacocoPluginExtension added by the jacoco plugin.

java 插件增加的脚本块

base) Configures the BasePluginExtension added by the java plugin.
java) Configures the JavaPluginExtension added by the java plugin.
reporting) Configures the ReportingExtension added by the java plugin.
sourceSets) Configures the source sets of this project.

pmd 插件增加的脚本块

base) Configures the BasePluginExtension added by the java plugin.
java) Configures the JavaPluginExtension added by the java plugin.
reporting) Configures the ReportingExtension added by the java plugin.
sourceSets) Configures the source sets of this project.

publishing 插件增加的脚本块

publishing) Configures the PublishingExtension added by the publishing plugin.

signing 插件增加的脚本块

signing) Configures the SigningExtension added by the signing plugin.

visual-studio 插件增加的脚本块

visualStudio) Configures the VisualStudioRootExtension added by the visual-studio plugin.

xcode 插件增加的脚本块

xcode) Configures the XcodeRootExtension added by the xcode plugin.

属性详情

这里建议查看官方的解释 …
内容详细,有示例,没有解释完善的需要 ..
Property details