Search in sources :

Example 56 with ProjectInternal

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

the class TaskPathResolver method resolvePath.

/**
 * @param path the task path, e.g. 'someTask', 'sT', ':sT', ':foo:bar:sT'
 * @param startFrom the starting project the task should be found recursively
 * @return resolved task path
 */
public ResolvedTaskPath resolvePath(String path, ProjectInternal startFrom) {
    ProjectInternal project;
    // eg. 'someTask' or 'sT'
    String taskName;
    // eg. '', ':' or ':foo:bar'
    String prefix;
    if (path.contains(Project.PATH_SEPARATOR)) {
        int idx = path.lastIndexOf(Project.PATH_SEPARATOR);
        taskName = path.substring(idx + 1);
        prefix = path.substring(0, idx + 1);
        String projectPath = Project.PATH_SEPARATOR.equals(prefix) ? prefix : path.substring(0, idx);
        project = projectFinder.findProject(projectPath, startFrom);
    } else {
        project = startFrom;
        taskName = path;
        prefix = "";
    }
    return new ResolvedTaskPath(prefix, taskName, project);
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 57 with ProjectInternal

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

the class InstantiatingBuildLoader method createProjects.

private void createProjects(GradleInternal gradle, DefaultProjectDescriptor rootProjectDescriptor) {
    ClassLoaderScope baseProjectClassLoaderScope = gradle.baseProjectClassLoaderScope();
    ClassLoaderScope rootProjectClassLoaderScope = baseProjectClassLoaderScope.createChild("root-project[" + gradle.getIdentityPath() + "]");
    ProjectState projectState = gradle.getOwner().getProjects().getProject(rootProjectDescriptor.path());
    projectState.createMutableModel(rootProjectClassLoaderScope, baseProjectClassLoaderScope);
    ProjectInternal rootProject = projectState.getMutableModel();
    gradle.setRootProject(rootProject);
    createChildProjectsRecursively(gradle.getOwner(), rootProjectDescriptor, rootProjectClassLoaderScope, baseProjectClassLoaderScope);
}
Also used : ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ProjectState(org.gradle.api.internal.project.ProjectState)

Example 58 with ProjectInternal

use of org.gradle.api.internal.project.ProjectInternal in project wildfly-swarm by wildfly-swarm.

the class GradleArtifactResolvingHelper method doResolve.

private Collection<ResolvedArtifact> doResolve(final Collection<ArtifactSpec> deps, boolean transitive) {
    final Configuration config = this.project.getConfigurations().detachedConfiguration().setTransitive(transitive);
    final DependencySet dependencySet = config.getDependencies();
    deps.forEach(spec -> {
        if (projects.containsKey(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version())) {
            dependencySet.add(new DefaultProjectDependency((ProjectInternal) projects.get(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version()), new DefaultProjectAccessListener(), false));
        } else {
            final DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(spec.groupId(), spec.artifactId(), spec.version());
            final DefaultDependencyArtifact da = new DefaultDependencyArtifact(spec.artifactId(), spec.type(), spec.type(), spec.classifier(), null);
            d.addArtifact(da);
            dependencySet.add(d);
        }
    });
    if (transitive) {
        return config.getResolvedConfiguration().getResolvedArtifacts();
    }
    return config.getResolvedConfiguration().getFirstLevelModuleDependencies().stream().map(dep -> dep.getModuleArtifacts()).flatMap(artifacts -> artifacts.stream()).collect(Collectors.toList());
}
Also used : Iterator(java.util.Iterator) Project(org.gradle.api.Project) DefaultProjectDependency(org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) Collection(java.util.Collection) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) Set(java.util.Set) DefaultProjectAccessListener(org.gradle.api.internal.project.DefaultProjectAccessListener) DependencySet(org.gradle.api.artifacts.DependencySet) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) DefaultDependencyArtifact(org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact) ArtifactResolvingHelper(org.wildfly.swarm.tools.ArtifactResolvingHelper) Configuration(org.gradle.api.artifacts.Configuration) Map(java.util.Map) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Collections(java.util.Collections) ArtifactSpec(org.wildfly.swarm.tools.ArtifactSpec) DefaultDependencyArtifact(org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact) Configuration(org.gradle.api.artifacts.Configuration) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) DefaultProjectDependency(org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) DependencySet(org.gradle.api.artifacts.DependencySet) DefaultProjectAccessListener(org.gradle.api.internal.project.DefaultProjectAccessListener)

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