Search in sources :

Example 1 with DefaultDeploymentRegistry

use of org.gradle.deployment.internal.DefaultDeploymentRegistry in project gradle by gradle.

the class DefaultGradleLauncherFactory method newInstance.

@Override
public GradleLauncher newInstance(StartParameter startParameter, BuildRequestContext requestContext, ServiceRegistry parentRegistry) {
    // This should only be used for top-level builds
    if (rootBuild != null) {
        throw new IllegalStateException("Cannot have a current build");
    }
    if (!(parentRegistry instanceof BuildTreeScopeServices)) {
        throw new IllegalArgumentException("Service registry must be of build-tree scope");
    }
    BuildTreeScopeServices buildTreeScopeServices = (BuildTreeScopeServices) parentRegistry;
    // TODO: Push this up more so we can inject plugins into the root build as well.
    BuildDefinition buildDefinition = BuildDefinition.fromStartParameter(startParameter);
    DefaultGradleLauncher launcher = doNewInstance(buildDefinition, null, requestContext.getCancellationToken(), requestContext, requestContext.getEventConsumer(), buildTreeScopeServices, ImmutableList.of(new Stoppable() {

        @Override
        public void stop() {
            rootBuild = null;
        }
    }));
    rootBuild = launcher;
    final DefaultDeploymentRegistry deploymentRegistry = parentRegistry.get(DefaultDeploymentRegistry.class);
    launcher.getGradle().addBuildListener(new BuildAdapter() {

        @Override
        public void buildFinished(BuildResult result) {
            deploymentRegistry.buildFinished(result);
        }
    });
    return launcher;
}
Also used : BuildResult(org.gradle.BuildResult) DefaultDeploymentRegistry(org.gradle.deployment.internal.DefaultDeploymentRegistry) BuildTreeScopeServices(org.gradle.internal.service.scopes.BuildTreeScopeServices) Stoppable(org.gradle.internal.concurrent.Stoppable) BuildAdapter(org.gradle.BuildAdapter) BuildDefinition(org.gradle.api.internal.BuildDefinition)

Example 2 with DefaultDeploymentRegistry

use of org.gradle.deployment.internal.DefaultDeploymentRegistry in project gradle by gradle.

the class DefaultRootBuildState method run.

@Override
public <T> T run(Function<? super BuildTreeLifecycleController, T> action) {
    if (completed) {
        throw new IllegalStateException("Cannot run more than one action for a build.");
    }
    try {
        RootBuildLifecycleListener buildLifecycleListener = listenerManager.getBroadcaster(RootBuildLifecycleListener.class);
        buildLifecycleListener.afterStart();
        try {
            GradleInternal gradle = getBuildController().getGradle();
            DefaultDeploymentRegistry deploymentRegistry = gradle.getServices().get(DefaultDeploymentRegistry.class);
            gradle.addBuildListener(new InternalBuildAdapter() {

                @Override
                public void buildFinished(BuildResult result) {
                    deploymentRegistry.buildFinished(result);
                }
            });
            return action.apply(buildTreeLifecycleController);
        } finally {
            buildLifecycleListener.beforeComplete();
        }
    } finally {
        completed = true;
    }
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) BuildResult(org.gradle.BuildResult) DefaultDeploymentRegistry(org.gradle.deployment.internal.DefaultDeploymentRegistry) RootBuildLifecycleListener(org.gradle.initialization.RootBuildLifecycleListener) InternalBuildAdapter(org.gradle.internal.InternalBuildAdapter)

Aggregations

BuildResult (org.gradle.BuildResult)2 DefaultDeploymentRegistry (org.gradle.deployment.internal.DefaultDeploymentRegistry)2 BuildAdapter (org.gradle.BuildAdapter)1 BuildDefinition (org.gradle.api.internal.BuildDefinition)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 RootBuildLifecycleListener (org.gradle.initialization.RootBuildLifecycleListener)1 InternalBuildAdapter (org.gradle.internal.InternalBuildAdapter)1 Stoppable (org.gradle.internal.concurrent.Stoppable)1 BuildTreeScopeServices (org.gradle.internal.service.scopes.BuildTreeScopeServices)1