Search in sources :

Example 1 with BuildResult

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();
    });
}
Also used : BuildListener(org.gradle.BuildListener) BuildResult(org.gradle.BuildResult) Gradle(org.gradle.api.invocation.Gradle) AndroidConfig(com.android.build.gradle.AndroidConfig) Settings(org.gradle.api.initialization.Settings)

Example 2 with BuildResult

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())));
}
Also used : BuildResult(org.gradle.BuildResult) StandardOutputListener(org.gradle.api.logging.StandardOutputListener) ReportedException(org.gradle.initialization.ReportedException) GradleException(org.gradle.api.GradleException) LocationAwareException(org.gradle.internal.exceptions.LocationAwareException)

Example 3 with BuildResult

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());
}
Also used : Expectations(org.jmock.Expectations) BuildResult(org.gradle.BuildResult) Test(org.junit.Test)

Example 4 with BuildResult

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());
}
Also used : Expectations(org.jmock.Expectations) BuildResult(org.gradle.BuildResult) Test(org.junit.Test)

Example 5 with BuildResult

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);
        }
    });
}
Also used : BuildResult(org.gradle.BuildResult) BuildAdapter(org.gradle.BuildAdapter) DaemonExpirationResult(org.gradle.launcher.daemon.server.expiry.DaemonExpirationResult) DaemonExpirationListener(org.gradle.launcher.daemon.server.expiry.DaemonExpirationListener)

Aggregations

BuildResult (org.gradle.BuildResult)9 BuildAdapter (org.gradle.BuildAdapter)2 BuildListener (org.gradle.BuildListener)2 Settings (org.gradle.api.initialization.Settings)2 Gradle (org.gradle.api.invocation.Gradle)2 ReportedException (org.gradle.initialization.ReportedException)2 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 DataBindingBuilder (android.databinding.tool.DataBindingBuilder)1 Transform (com.android.build.api.transform.Transform)1 AndroidConfig (com.android.build.gradle.AndroidConfig)1 ExtraModelInfo (com.android.build.gradle.internal.ExtraModelInfo)1 LibraryCache (com.android.build.gradle.internal.LibraryCache)1 SdkHandler (com.android.build.gradle.internal.SdkHandler)1 JacocoPlugin (com.android.build.gradle.internal.coverage.JacocoPlugin)1 TransformTask (com.android.build.gradle.internal.pipeline.TransformTask)1 GradleJavaProcessExecutor (com.android.build.gradle.internal.process.GradleJavaProcessExecutor)1 GradleProcessExecutor (com.android.build.gradle.internal.process.GradleProcessExecutor)1 DexTransform (com.android.build.gradle.internal.transforms.DexTransform)1 JackPreDexTransform (com.android.build.gradle.tasks.JackPreDexTransform)1