Search in sources :

Example 1 with GradleInternal

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

the class BuildSourceBuilder method buildGradleLauncher.

private GradleLauncher buildGradleLauncher(StartParameter startParameter) {
    StartParameter startParameterArg = startParameter.newInstance();
    startParameterArg.setProjectProperties(startParameter.getProjectProperties());
    startParameterArg.setSearchUpwards(false);
    startParameterArg.setProfile(startParameter.isProfile());
    GradleLauncher gradleLauncher = nestedBuildFactory.nestedInstance(startParameterArg);
    GradleInternal build = gradleLauncher.getGradle();
    if (build.getParent().findIdentityPath() == null) {
        // When nested inside a nested build, we need to synthesize a path for this build, as the root project is not yet known for the parent build
        // Use the directory structure to do this. This means that the buildSrc build and its containing build may end up with different paths
        Path path = build.getParent().getParent().getIdentityPath().child(startParameter.getCurrentDir().getParentFile().getName()).child(startParameter.getCurrentDir().getName());
        build.setIdentityPath(path);
    }
    return gradleLauncher;
}
Also used : Path(org.gradle.util.Path) DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath) ClassPath(org.gradle.internal.classpath.ClassPath) StartParameter(org.gradle.StartParameter) GradleLauncher(org.gradle.initialization.GradleLauncher) GradleInternal(org.gradle.api.internal.GradleInternal)

Example 2 with GradleInternal

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

the class DryRunBuildExecutionAction method execute.

public void execute(BuildExecutionContext context) {
    GradleInternal gradle = context.getGradle();
    if (gradle.getStartParameter().isDryRun()) {
        for (Task task : gradle.getTaskGraph().getAllTasks()) {
            task.setEnabled(false);
        }
    }
    context.proceed();
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) Task(org.gradle.api.Task)

Example 3 with GradleInternal

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

the class ExcludedTaskFilteringBuildConfigurationAction method configure.

public void configure(BuildExecutionContext context) {
    GradleInternal gradle = context.getGradle();
    Set<String> excludedTaskNames = gradle.getStartParameter().getExcludedTaskNames();
    if (!excludedTaskNames.isEmpty()) {
        final Set<Spec<Task>> filters = new HashSet<Spec<Task>>();
        for (String taskName : excludedTaskNames) {
            filters.add(taskSelector.getFilter(taskName));
        }
        gradle.getTaskGraph().useFilter(Specs.intersect(filters));
    }
    context.proceed();
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) Task(org.gradle.api.Task) Spec(org.gradle.api.specs.Spec) HashSet(java.util.HashSet)

Example 4 with GradleInternal

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

the class DefaultBuildController method getTargetProject.

private ProjectInternal getTargetProject(Object target) {
    ProjectInternal project;
    if (target == null) {
        project = gradle.getDefaultProject();
    } else if (target instanceof GradleProjectIdentity) {
        GradleProjectIdentity projectIdentity = (GradleProjectIdentity) target;
        GradleInternal build = findBuild(projectIdentity);
        project = findProject(build, projectIdentity);
    } else if (target instanceof GradleBuildIdentity) {
        GradleBuildIdentity buildIdentity = (GradleBuildIdentity) target;
        project = findBuild(buildIdentity).getDefaultProject();
    } else {
        throw new IllegalArgumentException("Don't know how to build models for " + target);
    }
    return project;
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) GradleBuildIdentity(org.gradle.tooling.internal.gradle.GradleBuildIdentity) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) GradleProjectIdentity(org.gradle.tooling.internal.gradle.GradleProjectIdentity)

Example 5 with GradleInternal

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

the class BuildModelActionRunner method run.

@Override
public void run(BuildAction action, final BuildController buildController) {
    if (!(action instanceof BuildModelAction)) {
        return;
    }
    final BuildModelAction buildModelAction = (BuildModelAction) action;
    final GradleInternal gradle = buildController.getGradle();
    gradle.addBuildListener(new BuildResultAdapter(gradle, buildController, buildModelAction));
    if (buildModelAction.isModelRequest()) {
        gradle.getStartParameter().setConfigureOnDemand(false);
    }
    if (buildModelAction.isRunTasks()) {
        buildController.run();
    } else {
        buildController.configure();
    }
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) BuildModelAction(org.gradle.tooling.internal.provider.BuildModelAction)

Aggregations

GradleInternal (org.gradle.api.internal.GradleInternal)30 StartParameter (org.gradle.StartParameter)4 ShowStacktrace (org.gradle.api.logging.configuration.ShowStacktrace)3 BuildState (org.gradle.internal.build.BuildState)3 IncludedBuildState (org.gradle.internal.build.IncludedBuildState)3 IncludedBuildInternal (org.gradle.internal.composite.IncludedBuildInternal)3 ListenerManager (org.gradle.internal.event.ListenerManager)3 ScriptUsageLocationReporter (org.gradle.internal.featurelifecycle.ScriptUsageLocationReporter)3 BuildOperationExecutor (org.gradle.internal.operations.BuildOperationExecutor)3 BuildScopeServices (org.gradle.internal.service.scopes.BuildScopeServices)3 File (java.io.File)2 BuildResult (org.gradle.BuildResult)2 Project (org.gradle.api.Project)2 Task (org.gradle.api.Task)2 ExceptionAnalyser (org.gradle.api.internal.ExceptionAnalyser)2 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)2 BuildConfigurer (org.gradle.configuration.BuildConfigurer)2 BuildConfigurationActionExecuter (org.gradle.execution.BuildConfigurationActionExecuter)2 BuildExecuter (org.gradle.execution.BuildExecuter)2 InternalBuildAdapter (org.gradle.internal.InternalBuildAdapter)2