interface Script
This interface is implemented by all Gradle scripts to add in some Gradle-specific methods. As your compiled script class will implement this interface, you can use the methods and properties declared by this interface directly in your script.
Generally, a Script
object will have a delegate object attached to it. For example, a build script will have a Project instance attached to it, and an initialization script will have a instance attached to it. Any property reference or method call which is not found on this Script
object is forwarded to the delegate object.
abstract fun apply(closure: Closure<Any>): Unit
Configures the delegate object for this script using plugins or scripts. The given closure is used to configure an org.gradle.api.plugins.ObjectConfigurationAction which is then used to configure the delegate object. abstract fun apply(options: MutableMap<String, *>): Unit
Configures the delegate object for this script using plugins or scripts. The following options are available:
For more detail, see org.gradle.api.plugins.ObjectConfigurationAction. |
|
abstract fun buildscript(configureClosure: Closure<Any>): Unit
Configures the classpath for this script. The given closure is executed against this script's ScriptHandler. The ScriptHandler is passed to the closure as the closure's delegate. |
|
abstract fun copy(closure: Closure<Any>): WorkResult
Copy the specified files. The given closure is used to configure a org.gradle.api.file.CopySpec, which is then used to copy the files. Example: Note that CopySpecs can be nested:
|
|
abstract fun copySpec(closure: Closure<Any>): CopySpec
Creates a org.gradle.api.file.CopySpec which can later be used to copy files or create an archive. The given closure is used to configure the org.gradle.api.file.CopySpec before it is returned by this method. |
|
abstract fun delete(vararg paths: Any): Boolean
Deletes files and directories. |
|
abstract fun exec(closure: Closure<Any>): ExecResult
Executes an external command. The closure configures a org.gradle.process.ExecSpec. abstract fun exec(action: Action<in ExecSpec>): ExecResult
Executes an external command. |
|
abstract fun file(path: Any): File
Resolves a file path relative to the directory containing this script. This works as described for abstract fun file(path: Any, validation: PathValidation): File
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. |
|
abstract fun fileTree(baseDir: Any): ConfigurableFileTree
Creates a new The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried. abstract fun fileTree(args: MutableMap<String, *>): ConfigurableFileTree
Creates a new
The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried. abstract fun fileTree(baseDir: Any, configureClosure: Closure<Any>): ConfigurableFileTree
Creates a new
The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried. |
|
abstract fun files(vararg paths: Any): ConfigurableFileCollection
Returns a ConfigurableFileCollection containing the given files. This works as described for abstract fun files(paths: Any, configureClosure: Closure<Any>): ConfigurableFileCollection
Creates a new |
|
abstract fun getBuildscript(): ScriptHandler
Returns the script handler for this script. You can use this handler to manage the classpath used to compile and execute this script. |
|
abstract fun getLogger(): Logger
Returns the logger for this script. You can use this in your script to write log messages. |
|
abstract fun getLogging(): LoggingManager
Returns the org.gradle.api.logging.LoggingManager which can be used to receive logging and to control the standard output/error capture for this script. By default, System.out is redirected to the Gradle logging system at the QUIET log level, and System.err is redirected at the ERROR log level. |
|
abstract fun getResources(): ResourceHandler
Provides access to resource-specific utility methods, for example factory methods that create various resources. |
|
abstract fun javaexec(closure: Closure<Any>): ExecResult
Executes a Java main class. The closure configures a org.gradle.process.JavaExecSpec. abstract fun javaexec(action: Action<in JavaExecSpec>): ExecResult
Executes a Java main class. |
|
abstract fun mkdir(path: Any): File
Creates a directory and returns a file pointing to it. |
|
abstract fun <T : Any> property(clazz: Class<T>): PropertyState<T>
Creates a |
|
abstract fun <T : Any> provider(value: Callable<T>): Provider<T>
Creates a |
|
abstract fun relativePath(path: Any): String
Returns the relative path from the directory containing this script to the given path. The given path object is (logically) resolved as described for |
|
abstract fun tarTree(tarPath: Any): FileTree
Creates a new
Unless custom implementation of resources is passed, the tar tree attempts to guess the compression based on the file extension. You can combine this method with the
|
|
abstract fun uri(path: Any): URI
Resolves a file path to a URI, relative to the directory containing this script. Evaluates the provided path object as described for |
|
abstract fun zipTree(zipPath: Any): FileTree
Creates a new The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried. |