use of org.gradle.BuildResult in project gradle by gradle.
the class DefaultGradleLauncher method doBuild.
private BuildResult doBuild(final Stage upTo) {
Throwable failure = null;
try {
buildListener.buildStarted(gradle);
doBuildStages(upTo);
} catch (Throwable t) {
failure = exceptionAnalyser.transform(t);
}
BuildResult buildResult = new BuildResult(upTo.name(), gradle, failure);
buildListener.buildFinished(buildResult);
if (failure != null) {
throw new ReportedException(failure);
}
return buildResult;
}
use of org.gradle.BuildResult in project gradle by gradle.
the class ClientProvidedBuildActionRunner method run.
@Override
public void run(BuildAction action, final BuildController buildController) {
if (!(action instanceof ClientProvidedBuildAction)) {
return;
}
final GradleInternal gradle = buildController.getGradle();
ClientProvidedBuildAction clientProvidedBuildAction = (ClientProvidedBuildAction) action;
PayloadSerializer payloadSerializer = getPayloadSerializer(gradle);
final InternalBuildAction<?> clientAction = (InternalBuildAction<?>) payloadSerializer.deserialize(clientProvidedBuildAction.getAction());
final boolean isRunTasks = clientProvidedBuildAction.isRunTasks();
gradle.addBuildListener(new BuildAdapter() {
@Override
public void buildFinished(BuildResult result) {
if (result.getFailure() == null) {
buildController.setResult(buildResult(clientAction, gradle, isRunTasks));
}
}
});
if (isRunTasks) {
buildController.run();
} else {
buildController.configure();
}
}
use of org.gradle.BuildResult in project gradle by gradle.
the class InProcessGradleExecuter method executeBuild.
private BuildResult executeBuild(GradleInvocation invocation, StandardOutputListener outputListener, StandardOutputListener errorListener, BuildListenerImpl listener) {
// Augment the environment for the execution
System.setIn(connectStdIn());
processEnvironment.maybeSetProcessDir(getWorkingDir());
for (Map.Entry<String, String> entry : invocation.environmentVars.entrySet()) {
processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
}
Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
System.getProperties().putAll(implicitJvmSystemProperties);
resetTempDirLocation();
// TODO: Fix tests that rely on this being set before we process arguments like this...
StartParameter startParameter = new StartParameter();
startParameter.setCurrentDir(getWorkingDir());
startParameter.setShowStacktrace(ShowStacktrace.ALWAYS);
CommandLineParser parser = new CommandLineParser();
ParametersConverter parametersConverter = new ParametersConverter();
parametersConverter.configure(parser);
final Parameters parameters = new Parameters(startParameter);
parametersConverter.convert(parser.parse(getAllArgs()), parameters);
BuildActionExecuter<BuildActionParameters> actionExecuter = GLOBAL_SERVICES.get(BuildActionExecuter.class);
ListenerManager listenerManager = GLOBAL_SERVICES.get(ListenerManager.class);
listenerManager.addListener(listener);
try {
// TODO: Reuse more of BuildActionsFactory
BuildAction action = new ExecuteBuildAction(startParameter);
BuildActionParameters buildActionParameters = createBuildActionParameters(startParameter);
BuildRequestContext buildRequestContext = createBuildRequestContext(outputListener, errorListener);
startMeasurement();
actionExecuter.execute(action, buildRequestContext, buildActionParameters, GLOBAL_SERVICES);
return new BuildResult(null, null);
} catch (ReportedException e) {
return new BuildResult(null, e.getCause());
} finally {
stopMeasurement();
listenerManager.removeListener(listener);
}
}
use of org.gradle.BuildResult in project atlas by alibaba.
the class BasePlugin method configureProject.
protected void configureProject() {
extraModelInfo = new ExtraModelInfo(project, isLibrary());
checkGradleVersion();
sdkHandler = new SdkHandler(project, getLogger());
project.afterEvaluate(p -> {
if (!p.getGradle().getStartParameter().isOffline() && AndroidGradleOptions.getUseSdkDownload(p)) {
SdkLibData sdkLibData = SdkLibData.download(getDownloader(), getSettingsController());
dependencyManager.setSdkLibData(sdkLibData);
sdkHandler.setSdkLibData(sdkLibData);
}
});
androidBuilder = new AndroidBuilder(project == project.getRootProject() ? project.getName() : project.getPath(), creator, new GradleProcessExecutor(project), new GradleJavaProcessExecutor(project), extraModelInfo, getLogger(), isVerbose());
dataBindingBuilder = new DataBindingBuilder();
dataBindingBuilder.setPrintMachineReadableOutput(extraModelInfo.getErrorFormatMode() == ExtraModelInfo.ErrorFormatMode.MACHINE_PARSABLE);
project.getPlugins().apply(JavaBasePlugin.class);
jacocoPlugin = project.getPlugins().apply(JacocoPlugin.class);
project.getTasks().getByName("assemble").setDescription("Assembles all variants of all applications and secondary packages.");
// call back on execution. This is called after the whole build is done (not
// after the current project is done).
// This is will be called for each (android) projects though, so this should support
// being called 2+ times.
project.getGradle().addBuildListener(new BuildListener() {
private final LibraryCache libraryCache = LibraryCache.getCache();
@Override
public void buildStarted(Gradle gradle) {
}
@Override
public void settingsEvaluated(Settings settings) {
}
@Override
public void projectsLoaded(Gradle gradle) {
}
@Override
public void projectsEvaluated(Gradle gradle) {
}
@Override
public void buildFinished(BuildResult buildResult) {
ExecutorSingleton.shutdown();
sdkHandler.unload();
ThreadRecorder.get().record(ExecutionType.BASE_PLUGIN_BUILD_FINISHED, project.getPath(), null, new Recorder.Block() {
@Override
public Void call() throws Exception {
PreDexCache.getCache().clear(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/dex-cache/cache.xml"), getLogger());
JackConversionCache.getCache().clear(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/jack-cache/cache.xml"), getLogger());
libraryCache.unload();
Main.clearInternTables();
return null;
}
});
}
});
project.getGradle().getTaskGraph().addTaskExecutionGraphListener(new TaskExecutionGraphListener() {
@Override
public void graphPopulated(TaskExecutionGraph taskGraph) {
for (Task task : taskGraph.getAllTasks()) {
if (task instanceof TransformTask) {
Transform transform = ((TransformTask) task).getTransform();
if (transform instanceof DexTransform) {
PreDexCache.getCache().load(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/dex-cache/cache.xml"));
break;
} else if (transform instanceof JackPreDexTransform) {
JackConversionCache.getCache().load(new File(project.getRootProject().getBuildDir(), FD_INTERMEDIATES + "/jack-cache/cache.xml"));
break;
}
}
}
}
});
}
Aggregations