Groovy Documentation

org.gradle
Class GradleLauncher

java.lang.Object
  org.gradle.GradleLauncher

class GradleLauncher

GradleLauncher is the main entry point for embedding Gradle. You use this class to manage a Gradle build, as follows:

  1. Optionally create a StartParameter instance and configure it with the desired properties. The properties of StartParameter generally correspond to the command-line options of Gradle. You can use #createStartParameter(String[]) to create a StartParameter from a set of command-line options.
  2. Obtain a GradleLauncher instance by calling #newInstance, passing in the StartParameter, or an array of Strings that will be treated as command line arguments.
  3. Optionally add one or more listeners to the GradleLauncher.
  4. Call #run to execute the build. This will return a BuildResult. Note that if the build fails, the resulting exception will be contained in the BuildResult.
  5. Query the build result. You might want to call BuildResult#rethrowFailure() to rethrow any build failure.
author:
Hans Dockter


Nested Class Summary
enum GradleLauncher.Stage

 
Constructor Summary
GradleLauncher(GradleInternal gradle, InitScriptHandler initScriptHandler, SettingsHandler settingsHandler, IGradlePropertiesLoader gradlePropertiesLoader, BuildLoader buildLoader, BuildConfigurer buildConfigurer, LoggingConfigurer loggingConfigurer, ListenerManager listenerManager)

Creates a new instance.

 
Method Summary
void addListener(java.lang.Object listener)

Adds a {

void addStandardErrorListener(StandardOutputListener listener)

Adds a {

void addStandardOutputListener(StandardOutputListener listener)

Adds a {

static StartParameter createStartParameter(java.lang.String[] commandLineArgs)

Returns a StartParameter object out of command line syntax arguments.

BuildResult getBuildAnalysis()

Evaluates the settings and all the projects.

BuildResult getBuildAndRunAnalysis()

Evaluates the settings and all the projects.

static void injectCustomFactory(GradleFactory gradleFactory)

static GradleLauncher newInstance(StartParameter startParameter)

Returns a GradleLauncher instance based on the passed start parameter.

static GradleLauncher newInstance(java.lang.String[] commandLineArgs)

Returns a GradleLauncher instance based on the passed command line syntax arguments.

BuildResult run()

Executes the build for this GradleLauncher instance and returns the result.

GradleLauncher valueOf(java.lang.String name)

Returns the enum constant of this type with the specified name.

GradleLauncher[] values()

Returns an array containing the constants of this enum type, in the order they are declared.

 
Methods inherited from class java.lang.Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Constructor Detail

GradleLauncher

public GradleLauncher(GradleInternal gradle, InitScriptHandler initScriptHandler, SettingsHandler settingsHandler, IGradlePropertiesLoader gradlePropertiesLoader, BuildLoader buildLoader, BuildConfigurer buildConfigurer, LoggingConfigurer loggingConfigurer, ListenerManager listenerManager)
Creates a new instance. Don't call this directly, use #newInstance(StartParameter) or #newInstance(String[]) instead. Note that this method is package-protected to discourage it's direct use.


 
Method Detail

addListener

public void addListener(java.lang.Object listener)

Adds a BuildListener to this build instance. The listener is notified of events which occur during the execution of the build.

param:
listener The listener to add. Has no effect if the listener has already been added.


addStandardErrorListener

public void addStandardErrorListener(StandardOutputListener listener)

Adds a StandardOutputListener to this build instance. The listener is notified of any text written to standard error by Gradle's logging system

param:
listener The listener to add. Has no effect if the listener has already been added.


addStandardOutputListener

public void addStandardOutputListener(StandardOutputListener listener)

Adds a StandardOutputListener to this build instance. The listener is notified of any text written to standard output by Gradle's logging system

param:
listener The listener to add. Has no effect if the listener has already been added.


createStartParameter

public static StartParameter createStartParameter(java.lang.String[] commandLineArgs)
Returns a StartParameter object out of command line syntax arguments. Every possible command line option has it associated field in the StartParameter object.
param:
commandLineArgs A String array where each element denotes an entry of the Gradle command line syntax


getBuildAnalysis

public BuildResult getBuildAnalysis()
Evaluates the settings and all the projects. The information about available tasks and projects is accessible via the org.gradle.api.invocation.Gradle#getRootProject() object.
return:
A BuildResult object. Never returns null.


getBuildAndRunAnalysis

public BuildResult getBuildAndRunAnalysis()
Evaluates the settings and all the projects. The information about available tasks and projects is accessible via the org.gradle.api.invocation.Gradle#getRootProject() object. Fills the execution plan without running the build. The tasks to be executed tasks are available via org.gradle.api.invocation.Gradle#getTaskGraph().
return:
A BuildResult object. Never returns null.


injectCustomFactory

public static void injectCustomFactory(GradleFactory gradleFactory)


newInstance

public static GradleLauncher newInstance(StartParameter startParameter)
Returns a GradleLauncher instance based on the passed start parameter.
param:
startParameter The start parameter object the GradleLauncher instance is initialized with


newInstance

public static GradleLauncher newInstance(java.lang.String[] commandLineArgs)
Returns a GradleLauncher instance based on the passed command line syntax arguments. Certain command line arguments won't have any effect if you choose this method (e.g. -v, -h). If you want to act upon, you better use #createStartParameter(String[]) in conjunction with #newInstance(String[]).
param:
commandLineArgs A String array where each element denotes an entry of the Gradle command line syntax


run

public BuildResult run()

Executes the build for this GradleLauncher instance and returns the result. Note that when the build fails, the exception is available using BuildResult#getFailure().

return:
The result. Never returns null.


valueOf

GradleLauncher valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.


values

GradleLauncher[] values()
Returns an array containing the constants of this enum type, in the order they are declared.


 

Groovy Documentation