use of org.gradle.BuildResult in project atlas by alibaba.
the class AtlasPlugin method configurePlugin.
/**
* 启动设置插件
*/
private void configurePlugin() {
creator = "Atlas Gradle PLUGIN";
extraModelInfo = new ExtraModelInfo(project, PluginTypeUtils.isLibraryProject(project));
prepareBuildTools(project, extraModelInfo, atlasExtension.getTBuildConfig().getUseCustomAapt());
tAndroidBuilder = AtlasBuildContext.androidBuilder;
sdkHandler = new SdkHandler(project, getLogger());
AndroidConfig extension = DefaultGroovyMethods.asType(DefaultGroovyMethods.getAt(project.getExtensions(), "android"), AndroidConfig.class);
sdkHandler.initTarget(extension.getCompileSdkVersion(), extension.getBuildToolsRevision(), extension.getLibraryRequests(), tAndroidBuilder, SdkHandler.useCachedSdk(project));
project.getGradle().addBuildListener(new BuildListener() {
@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) {
sdkHandler.unload();
}
private final LibraryCache libraryCache = LibraryCache.getCache();
});
}
use of org.gradle.BuildResult in project gradle by gradle.
the class InProcessGradleExecuter method doRun.
@Override
protected ExecutionResult doRun() {
if (isForkRequired()) {
return doStart().waitForFinish();
}
StandardOutputListener outputListener = new OutputListenerImpl();
StandardOutputListener errorListener = new OutputListenerImpl();
BuildListenerImpl buildListener = new BuildListenerImpl();
BuildResult result = doRun(outputListener, errorListener, buildListener);
try {
result.rethrowFailure();
} catch (Exception e) {
throw new UnexpectedBuildFailure(e);
}
return assertResult(new InProcessExecutionResult(buildListener.executedTasks, buildListener.skippedTasks, new OutputScrapingExecutionResult(outputListener.toString(), errorListener.toString())));
}
use of org.gradle.BuildResult in project gradle by gradle.
the class BuildResultLoggerTest method logsBuildFailedAndTotalTime.
@Test
public void logsBuildFailedAndTotalTime() {
context.checking(new Expectations() {
{
one(buildTimeClock).getElapsed();
will(returnValue("10s"));
one(textOutputFactory).create(BuildResultLogger.class, LogLevel.LIFECYCLE);
will(returnValue(textOutput));
}
});
listener.buildFinished(new BuildResult("Action", null, new RuntimeException()));
assertEquals("\n{failure}ACTION FAILED{normal}\n\nTotal time: 10s\n", textOutput.getValue());
}
use of org.gradle.BuildResult in project gradle by gradle.
the class BuildResultLoggerTest method logsBuildSuccessAndTotalTime.
@Test
public void logsBuildSuccessAndTotalTime() {
context.checking(new Expectations() {
{
one(buildTimeClock).getElapsed();
will(returnValue("10s"));
one(textOutputFactory).create(BuildResultLogger.class, LogLevel.LIFECYCLE);
will(returnValue(textOutput));
}
});
listener.buildFinished(new BuildResult("Action", null, null));
assertEquals("\n{success}ACTION SUCCESSFUL{normal}\n\nTotal time: 10s\n", textOutput.getValue());
}
use of org.gradle.BuildResult in project gradle by gradle.
the class DefaultDaemonScanInfo method notifyOnUnhealthy.
@Override
public void notifyOnUnhealthy(final Action<? super String> listener) {
/*
The semantics of this method are that the given action should be notified if the
Daemon is going to be terminated at the end of this build.
It is not a generic outlet for “expiry events”.
Ideally, the value given would describe the problem and not be phrased in terms of why we are shutting down,
but this is a practical compromise born out of piggy backing on the expiration listener mechanism to implement it.
*/
final DaemonExpirationListener daemonExpirationListener = new DaemonExpirationListener() {
@Override
public void onExpirationEvent(DaemonExpirationResult result) {
if (result.getStatus() == DaemonExpirationStatus.GRACEFUL_EXPIRE) {
try {
listener.execute(result.getReason());
} finally {
listenerManager.removeListener(this);
}
}
}
};
listenerManager.addListener(daemonExpirationListener);
listenerManager.addListener(new BuildAdapter() {
@Override
public void buildFinished(BuildResult result) {
listenerManager.removeListener(daemonExpirationListener);
}
});
}
Aggregations