Table of Contents

  • Properties
  • Methods
  • Script blocks
  • Property details
  • Method details
  • Script block details

API Doc

这个接口将被所有的Gradle Groovy DSL 脚本实现 -为对应的脚本文件增加一些Gradle 特定的方法..
由于你的编译脚本类将会实现此接口,你能够直接在脚本中使用这些此接口实现的属性或者方法 ..
通常来说,Script对象有一个代理对象(依附),举个例子,构建脚本将有一个Project实例,
初始化脚本将有一个Gradle实例,任何属性引用或者方法调用(如果未在此接口上找到,那么他将转发到代理对象上)

Properties

  • buildscript 脚本的脚本处理器,你能够使用这个处理器管理被用来编译并执行此脚本的类路径
  • logger 脚本的日志器,你你能够在脚本中用来写入日志消息 ..
  • logging LoggingManager 能够被用来为脚本接收日志并且控制标准输出 / 错误捕捉,默认来说,System.out 直接重定向Gradle 日志系统的 QUIET 日志级别 ..System.err 将重定向到ERROR 日志级别 ..
  • resources 提供资源相关的工具方法的访问,例如创建各种资源的工厂方法 ..

Methods

Method Description
apply)
(closure)
Configures the delegate object for this script using plugins or scripts.
apply)
(options)
Configures the delegate object for this script using plugins or scripts.
copy)
(closure)
Copy the specified files. The given closure is used to configure a CopySpec, which is then used to copy the files. Example:
拷贝指定的文件,这个闭包被用来配置一个CopySpec ..
它将被用来拷贝文件 - 做出配置 …
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,在它由这个方法返回之前 …
delete)
(paths)
Deletes files and directories.
exec)
(closure)
Executes an external command. The closure configures a ExecSpec.
exec)
(action)
Executes an external command.
file)
(path)
Resolves a file path relative to the directory containing this script. This works as described for Project.file(java.lang.Object))
根据此脚本的目录进行相对文件解析路径,等价于Project.file(java.lang.Object) …
file)
(path, validation)
Resolves a file path relative to the directory containing this script 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 Script.file(java.lang.Object)).
fileTree)
(baseDir, configureClosure)
Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per Script.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:

创建一个可配置的文件树(通过给定的baseDir,并且闭包被用来配置新的文件树) …
这个文件树作为闭包的代理对象 …
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:
files)
(paths, configureClosure)
Creates a new ConfigurableFileCollection using the given paths. The file collection is configured using the given closure. This method works as described for Project.files(java.lang.Object, groovy.lang.Closure)). Relative paths are resolved relative to the directory containing this script.
files)
(paths)
Returns a ConfigurableFileCollection containing the given files. This works as described for Project.files(java.lang.Object[])). Relative paths are resolved relative to the directory containing this script.
javaexec)
(closure)
Executes a Java main class. The closure configures a JavaExecSpec.
javaexec)
(action)
Executes a Java main class.
mkdir)
(path)
Creates a directory and returns a file pointing to it.
relativePath)
(path)
Returns the relative path from the directory containing this script to the given path. The given path object is (logically) resolved as described for Script.file(java.lang.Object)), from which a relative path is calculated.
tarTree)
(tarPath)
Creates a new FileTree which contains the contents of the given TAR file. The given tarPath path can be:
uri)
(path)
Resolves a file path to a URI, relative to the directory containing this script. Evaluates the provided path object as described for Script.file(java.lang.Object)), with the exception that any URI scheme is supported, not just ‘file:’ URIs.
zipTree)
(zipPath)
Creates a new FileTree which contains the contents of the given ZIP file. The given zipPath path is evaluated as per Script.file(java.lang.Object)). You can combine this method with the Script.copy(groovy.lang.Closure)) method to unzip a ZIP file.

一般来说它提供了对文件的操作,以及外部命令执行的方法 …

更多详情

Script