Search in sources :

Example 1 with BuildDefinition

use of org.gradle.api.internal.BuildDefinition 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 BuildDefinition

use of org.gradle.api.internal.BuildDefinition in project gradle by gradle.

the class BuildSourceBuilder method createBuildSourceClasspath.

private ClassPath createBuildSourceClasspath(final GradleInternal gradle, File buildSrcDir, final StartParameter containingBuildParameters) {
    if (!buildSrcDir.isDirectory()) {
        LOGGER.debug("Gradle source dir does not exist. We leave.");
        return ClassPath.EMPTY;
    }
    final StartParameter buildSrcStartParameter = containingBuildParameters.newBuild();
    buildSrcStartParameter.setCurrentDir(buildSrcDir);
    buildSrcStartParameter.setProjectProperties(containingBuildParameters.getProjectProperties());
    buildSrcStartParameter.setSearchUpwards(false);
    buildSrcStartParameter.setProfile(containingBuildParameters.isProfile());
    final BuildDefinition buildDefinition = BuildDefinition.fromStartParameterForBuild(buildSrcStartParameter, buildSrcDir, DefaultPluginRequests.EMPTY);
    assert buildSrcStartParameter.getBuildFile() == null;
    return buildOperationExecutor.call(new CallableBuildOperation<ClassPath>() {

        @Override
        public ClassPath call(BuildOperationContext context) {
            ClassPath classPath = buildBuildSrc(buildDefinition);
            context.setResult(BUILD_BUILDSRC_RESULT);
            return classPath;
        }

        @Override
        public BuildOperationDescriptor.Builder description() {
            return BuildOperationDescriptor.displayName("Build buildSrc").progressDisplayName("Building buildSrc").details(new BuildBuildSrcBuildOperationType.Details() {

                @Override
                public String getBuildPath() {
                    return gradle.getIdentityPath().toString();
                }
            });
        }
    });
}
Also used : StartParameter(org.gradle.StartParameter) ClassPath(org.gradle.internal.classpath.ClassPath) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) BuildDefinition(org.gradle.api.internal.BuildDefinition)

Aggregations

BuildDefinition (org.gradle.api.internal.BuildDefinition)2 BuildAdapter (org.gradle.BuildAdapter)1 BuildResult (org.gradle.BuildResult)1 StartParameter (org.gradle.StartParameter)1 DefaultDeploymentRegistry (org.gradle.deployment.internal.DefaultDeploymentRegistry)1 ClassPath (org.gradle.internal.classpath.ClassPath)1 Stoppable (org.gradle.internal.concurrent.Stoppable)1 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)1 BuildTreeScopeServices (org.gradle.internal.service.scopes.BuildTreeScopeServices)1