Search in sources :

Example 11 with ProjectInternal

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

the class DefaultTaskSelector method getSelection.

private TaskSelection getSelection(String path, ProjectInternal project) {
    ResolvedTaskPath taskPath = taskPathResolver.resolvePath(path, project);
    ProjectInternal targetProject = taskPath.getProject();
    if (taskPath.isQualified()) {
        configurer.configure(targetProject);
    } else {
        configurer.configureHierarchy(targetProject);
    }
    TaskSelectionResult tasks = taskNameResolver.selectWithName(taskPath.getTaskName(), taskPath.getProject(), !taskPath.isQualified());
    if (tasks != null) {
        // An exact match
        return new TaskSelection(taskPath.getProject().getPath(), path, tasks);
    }
    Map<String, TaskSelectionResult> tasksByName = taskNameResolver.selectAll(taskPath.getProject(), !taskPath.isQualified());
    NameMatcher matcher = new NameMatcher();
    String actualName = matcher.find(taskPath.getTaskName(), tasksByName.keySet());
    if (actualName != null) {
        return new TaskSelection(taskPath.getProject().getPath(), taskPath.getPrefix() + actualName, tasksByName.get(actualName));
    }
    throw new TaskSelectionException(matcher.formatErrorMessage("task", taskPath.getProject()));
}
Also used : ResolvedTaskPath(org.gradle.execution.taskpath.ResolvedTaskPath) NameMatcher(org.gradle.util.internal.NameMatcher) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 12 with ProjectInternal

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

the class DefaultTasksBuildExecutionAction method configure.

@Override
public void configure(BuildExecutionContext context) {
    StartParameter startParameter = context.getGradle().getStartParameter();
    for (TaskExecutionRequest request : startParameter.getTaskRequests()) {
        if (!request.getArgs().isEmpty()) {
            context.proceed();
            return;
        }
    }
    // Gather the default tasks from this first group project
    ProjectInternal project = context.getGradle().getDefaultProject();
    // so that we don't miss out default tasks
    projectConfigurer.configure(project);
    List<String> defaultTasks = project.getDefaultTasks();
    if (defaultTasks.size() == 0) {
        defaultTasks = new ArrayList<>();
        for (BuiltInCommand command : builtInCommands) {
            defaultTasks.addAll(command.asDefaultTask());
        }
        LOGGER.info("No tasks specified. Using default task {}", GUtil.toString(defaultTasks));
    } else {
        LOGGER.info("No tasks specified. Using project default tasks {}", GUtil.toString(defaultTasks));
    }
    startParameter.setTaskNames(defaultTasks);
    context.proceed();
}
Also used : StartParameter(org.gradle.StartParameter) TaskExecutionRequest(org.gradle.TaskExecutionRequest) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) BuiltInCommand(org.gradle.configuration.project.BuiltInCommand)

Example 13 with ProjectInternal

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

the class DefaultConfiguration method markReferencedProjectConfigurationsObserved.

private void markReferencedProjectConfigurationsObserved(InternalState requestedState, ResolverResults results) {
    ProjectInternal consumingProject = domainObjectContext.getProject();
    ProjectState consumingProjectState = consumingProject == null ? null : consumingProject.getOwner();
    for (ResolvedProjectConfiguration projectResult : results.getResolvedLocalComponents().getResolvedProjectConfigurations()) {
        ProjectState targetProjectState = projectStateRegistry.stateFor(projectResult.getId());
        dependencyObservedBroadcast.dependencyObserved(consumingProjectState, targetProjectState, requestedState, projectResult);
    }
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ProjectState(org.gradle.api.internal.project.ProjectState) ResolvedProjectConfiguration(org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedProjectConfiguration)

Example 14 with ProjectInternal

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

the class BuildLogger method projectsLoaded.

@Override
public void projectsLoaded(Gradle gradle) {
    if (logger.isInfoEnabled()) {
        ProjectInternal projectInternal = (ProjectInternal) gradle.getRootProject();
        logger.info("Projects loaded. Root project using {}.", projectInternal.getBuildScriptSource().getDisplayName());
        logger.info("Included projects: {}", projectInternal.getAllprojects());
    }
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 15 with ProjectInternal

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

the class DefaultTransformerInvocationFactory method createInvocation.

@Override
public CacheableInvocation<ImmutableList<File>> createInvocation(Transformer transformer, File inputArtifact, ArtifactTransformDependencies dependencies, TransformationSubject subject, InputFingerprinter inputFingerprinter) {
    ProjectInternal producerProject = determineProducerProject(subject);
    TransformationWorkspaceServices workspaceServices = determineWorkspaceServices(producerProject);
    UnitOfWork execution;
    if (producerProject == null) {
        execution = new ImmutableTransformerExecution(transformer, inputArtifact, dependencies, buildOperationExecutor, fileCollectionFactory, inputFingerprinter, fileSystemAccess, workspaceServices);
    } else {
        execution = new MutableTransformerExecution(transformer, inputArtifact, dependencies, buildOperationExecutor, fileCollectionFactory, inputFingerprinter, workspaceServices);
    }
    return executionEngine.createRequest(execution).withIdentityCache(workspaceServices.getIdentityCache()).getOrDeferExecution(new DeferredExecutionHandler<TransformationResult, CacheableInvocation<ImmutableList<File>>>() {

        @Override
        public CacheableInvocation<ImmutableList<File>> processCachedOutput(Try<TransformationResult> cachedOutput) {
            return CacheableInvocation.cached(mapResult(cachedOutput));
        }

        @Override
        public CacheableInvocation<ImmutableList<File>> processDeferredOutput(Supplier<Try<TransformationResult>> deferredExecution) {
            return CacheableInvocation.nonCached(() -> fireTransformListeners(transformer, subject, () -> mapResult(deferredExecution.get())));
        }

        @Nonnull
        private Try<ImmutableList<File>> mapResult(Try<TransformationResult> cachedOutput) {
            return cachedOutput.map(result -> result.resolveOutputsForInputArtifact(inputArtifact)).mapFailure(failure -> new TransformException(String.format("Execution failed for %s.", execution.getDisplayName()), failure));
        }
    });
}
Also used : InputChangesInternal(org.gradle.internal.execution.history.changes.InputChangesInternal) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) ProjectStateRegistry(org.gradle.api.internal.project.ProjectStateRegistry) CurrentFileCollectionFingerprint(org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint) Hashing(org.gradle.internal.hash.Hashing) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) INCREMENTAL(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputPropertyType.INCREMENTAL) FileValueSupplier(org.gradle.internal.execution.fingerprint.InputFingerprinter.FileValueSupplier) Provider(org.gradle.api.provider.Provider) ExecutionEngine(org.gradle.internal.execution.ExecutionEngine) ImmutableList(com.google.common.collect.ImmutableList) InputFingerprinter(org.gradle.internal.execution.fingerprint.InputFingerprinter) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Duration(java.time.Duration) Map(java.util.Map) DeferredExecutionHandler(org.gradle.internal.execution.DeferredExecutionHandler) WorkspaceProvider(org.gradle.internal.execution.workspace.WorkspaceProvider) Providers(org.gradle.api.internal.provider.Providers) DefaultFileNormalizationSpec(org.gradle.internal.execution.fingerprint.impl.DefaultFileNormalizationSpec) Nonnull(javax.annotation.Nonnull) OverlappingOutputs(org.gradle.internal.execution.history.OverlappingOutputs) Nullable(javax.annotation.Nullable) UnitOfWork(org.gradle.internal.execution.UnitOfWork) FileSystemLocation(org.gradle.api.file.FileSystemLocation) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot) InputVisitor(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputVisitor) CallableBuildOperation(org.gradle.internal.operations.CallableBuildOperation) ValueSnapshot(org.gradle.internal.snapshot.ValueSnapshot) Hasher(org.gradle.internal.hash.Hasher) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor) FileSystemAccess(org.gradle.internal.vfs.FileSystemAccess) FileCollectionFingerprinter(org.gradle.internal.execution.fingerprint.FileCollectionFingerprinter) HashCode(org.gradle.internal.hash.HashCode) File(java.io.File) CachingDisabledReason(org.gradle.internal.execution.caching.CachingDisabledReason) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) FILE(org.gradle.internal.file.TreeType.FILE) Try(org.gradle.internal.Try) CachingDisabledReasonCategory(org.gradle.internal.execution.caching.CachingDisabledReasonCategory) DIRECTORY(org.gradle.internal.file.TreeType.DIRECTORY) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) Optional(java.util.Optional) DefaultFileSystemLocation(org.gradle.api.internal.file.DefaultFileSystemLocation) NON_INCREMENTAL(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputPropertyType.NON_INCREMENTAL) UnitOfWork(org.gradle.internal.execution.UnitOfWork) Nonnull(javax.annotation.Nonnull) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Try(org.gradle.internal.Try) File(java.io.File)

Aggregations

ProjectInternal (org.gradle.api.internal.project.ProjectInternal)58 File (java.io.File)13 Project (org.gradle.api.Project)11 Task (org.gradle.api.Task)6 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)6 Inject (javax.inject.Inject)5 Plugin (org.gradle.api.Plugin)5 ProjectStateRegistry (org.gradle.api.internal.project.ProjectStateRegistry)5 Map (java.util.Map)4 Configuration (org.gradle.api.artifacts.Configuration)4 FileResolver (org.gradle.api.internal.file.FileResolver)4 Lists (com.google.common.collect.Lists)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Callable (java.util.concurrent.Callable)3 Collectors (java.util.stream.Collectors)3 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)3