Build Launcher
A BuildLauncher allows you to configure and execute a Gradle build.
Instances of BuildLauncher are not thread-safe. You use a BuildLauncher as follows:
- Create an instance of
BuildLauncherby calling newBuild. - Configure the launcher as appropriate.
- Call either run or run to execute the build.
- Optionally, you can reuse the launcher to launch additional builds.
ProjectConnection connection = GradleConnector.newConnector()
.forProjectDirectory(new File("some-folder"))
.connect();
try {
BuildLauncher build = connection.newBuild();
//select tasks to run:
build.forTasks("clean", "test");
//include some build arguments:
build.withArguments("-i", "--project-dir", "some-project-dir");
//configure the standard input:
build.setStandardInput(new ByteArrayInputStream("consume this!".getBytes()));
//in case you want the build to use java different than default:
build.setJavaHome(new File("/path/to/java"));
//if your build needs crazy amounts of memory:
build.setJvmArguments("-Xmx2048m", "-XX:MaxPermSize=512m");
//if you want to listen to the progress events:
ProgressListener listener = null; // use your implementation
build.addProgressListener(listener);
//kick the build off:
build.run();
} finally {
connection.close();
}
Content copied to clipboard
If the target Gradle version is >=6.8 then you can use BuildLauncher to execute tasks from included builds. You can target tasks from included builds by specifying the task identity path (i.e. ':included-build-name:subproject-name:taskName').
Since
1.0-milestone-3
Functions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Sets the launchables to execute.
Link copied to clipboard
Sets the tasks to be executed.
Link copied to clipboard
Executes the build, blocking until it is complete.
Launches the build.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard