Interface ScriptHandler
-
public interface ScriptHandlerA
ScriptHandlerallows you to manage the compilation and execution of a build script. You can declare the classpath used to compile and execute a build script. This classpath is also used to load the plugins which the build script uses.You can obtain a
ScriptHandlerinstance usingProject.getBuildscript()orScript.getBuildscript().To declare the script classpath, you use the
DependencyHandlerprovided bygetDependencies()to attach dependencies to the "classpath" configuration. These dependencies are resolved just prior to script compilation, and assembled into the classpath for the script.For most external dependencies you will also need to declare one or more repositories where the dependencies can be found, using the
RepositoryHandlerprovided bygetRepositories().
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLASSPATH_CONFIGURATIONThe name of the configuration used to assemble the script classpath.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidconfigurations(Action<? super ConfigurationContainer> configureClosure)Configures the configurations for the script.voiddependencies(Closure configureClosure)Configures the dependencies for the script.voiddependencyLocking(Closure configureClosure)Configures dependency lockingjava.lang.ClassLoadergetClassLoader()Returns theClassLoaderwhich contains the classpath for this script.ConfigurationContainergetConfigurations()Returns the configurations of this handler.DependencyHandlergetDependencies()Returns the dependencies of the script.DependencyLockingHandlergetDependencyLocking()Provides access to configuring dependency lockingRepositoryHandlergetRepositories()Returns a handler to create repositories which are used for retrieving dependencies for the script classpath.java.io.FilegetSourceFile()Returns the file containing the source for the script, if any.java.net.URIgetSourceURI()Returns the URI for the script source, if any.voidrepositories(Closure configureClosure)Configures the repositories for the script dependencies.
-
-
-
Field Detail
-
CLASSPATH_CONFIGURATION
static final java.lang.String CLASSPATH_CONFIGURATION
The name of the configuration used to assemble the script classpath.- See Also:
- Constant Field Values
-
-
Method Detail
-
getSourceFile
@Nullable java.io.File getSourceFile()
Returns the file containing the source for the script, if any.- Returns:
- The source file. Returns null if the script source is not a file.
-
getSourceURI
@Nullable java.net.URI getSourceURI()
Returns the URI for the script source, if any.- Returns:
- The source URI. Returns null if the script source has no URI.
-
getRepositories
RepositoryHandler getRepositories()
Returns a handler to create repositories which are used for retrieving dependencies for the script classpath.- Returns:
- the repository handler. Never returns null.
-
repositories
void repositories(Closure configureClosure)
Configures the repositories for the script dependencies. Executes the given closure against theRepositoryHandlerfor this handler. TheRepositoryHandleris passed to the closure as the closure's delegate.- Parameters:
configureClosure- the closure to use to configure the repositories.
-
getDependencies
DependencyHandler getDependencies()
Returns the dependencies of the script. The returned dependency handler instance can be used for adding new dependencies. For accessing already declared dependencies, the configurations can be used.- Returns:
- the dependency handler. Never returns null.
- See Also:
getConfigurations()
-
dependencies
void dependencies(Closure configureClosure)
Configures the dependencies for the script. Executes the given closure against theDependencyHandlerfor this handler. TheDependencyHandleris passed to the closure as the closure's delegate.- Parameters:
configureClosure- the closure to use to configure the dependencies.
-
getConfigurations
ConfigurationContainer getConfigurations()
Returns the configurations of this handler. This usually contains a single configuration, called "classpath".- Returns:
- The configuration of this handler.
-
configurations
@Incubating void configurations(Action<? super ConfigurationContainer> configureClosure)
Configures the configurations for the script. Executes the given action against theConfigurationContainerfor this handler.- Parameters:
configureClosure- The action used to configure the script configurations.- Since:
- 8.4
-
dependencyLocking
void dependencyLocking(Closure configureClosure)
Configures dependency locking- Parameters:
configureClosure- the configuration action- Since:
- 6.1
-
getDependencyLocking
DependencyLockingHandler getDependencyLocking()
Provides access to configuring dependency locking- Returns:
- the
DependencyLockingHandler - Since:
- 6.1
-
getClassLoader
java.lang.ClassLoader getClassLoader()
Returns theClassLoaderwhich contains the classpath for this script.- Returns:
- The ClassLoader. Never returns null.
-
-