Java 类org.gradle.api.artifacts.component.ComponentIdentifier 实例源码

项目:Reer    文件:DefaultLenientConfiguration.java   
@Override
public void visitFiles(@Nullable ComponentIdentifier componentIdentifier, Iterable<File> files) {
    try {
        for (File file : files) {
            if (seenFiles.add(file)) {
                ComponentArtifactIdentifier artifactIdentifier;
                if (componentIdentifier == null) {
                    artifactIdentifier = new OpaqueComponentArtifactIdentifier(file);
                } else {
                    artifactIdentifier = new ComponentFileArtifactIdentifier(componentIdentifier, file.getName());
                }
                artifacts.add(new DefaultResolvedArtifactResult(artifactIdentifier, Artifact.class, file));
            }
        }
    } catch (Throwable t) {
        failures.add(t);
    }
}
项目:Reer    文件:ClientModuleResolver.java   
public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, BuildableComponentResolveResult result) {
    resolver.resolve(identifier, componentOverrideMetadata, result);

    if (result.getFailure() != null) {
        return;
    }
    ClientModule clientModule = componentOverrideMetadata.getClientModule();
    if (clientModule != null) {
        MutableModuleComponentResolveMetadata clientModuleMetaData = ((ModuleComponentResolveMetadata)result.getMetaData()).asMutable();
        addClientModuleDependencies(clientModule, clientModuleMetaData);

        setClientModuleArtifact(clientModuleMetaData);

        result.setMetaData(clientModuleMetaData.asImmutable());
    }
}
项目:Reer    文件:AbstractRenderableDependencyResult.java   
@Override
public String getName() {
    ComponentSelector requested = getRequested();
    ComponentIdentifier selected = getActual();

    if(requested.matchesStrictly(selected)) {
        return getSimpleName();
    }

    if(requested instanceof ModuleComponentSelector && selected instanceof ModuleComponentIdentifier) {
        ModuleComponentSelector requestedModuleComponentSelector = (ModuleComponentSelector)requested;
        ModuleComponentIdentifier selectedModuleComponentedIdentifier = (ModuleComponentIdentifier)selected;

        if(isSameGroupAndModuleButDifferentVersion(requestedModuleComponentSelector, selectedModuleComponentedIdentifier)) {
            return getSimpleName() + " -> " + selectedModuleComponentedIdentifier.getVersion();
        }
    }

    return getSimpleName() + " -> " + selected.getDisplayName();
}
项目:Reer    文件:LocalLibraryDependencyResolver.java   
@Override
public void resolveArtifacts(ComponentResolveMetadata component, BuildableComponentArtifactsResolveResult result) {
    ComponentIdentifier componentId = component.getComponentId();
    if (isLibrary(componentId)) {
        result.resolved(new MetadataSourcedComponentArtifacts());
    }
}
项目:Reer    文件:DefaultLenientConfiguration.java   
@Override
public void visitFiles(@Nullable ComponentIdentifier componentIdentifier, Iterable<File> files) {
    try {
        for (File file : files) {
            this.files.add(file);
        }
    } catch (Throwable t) {
        failures.add(t);
    }
}
项目:Reer    文件:ShortCircuitEmptyConfigurationResolver.java   
private void emptyGraph(ConfigurationInternal configuration, ResolverResults results) {
    Module module = configuration.getModule();
    ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(module);
    ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module);
    ResolutionResult emptyResult = DefaultResolutionResultBuilder.empty(id, componentIdentifier);
    ResolvedLocalComponentsResult emptyProjectResult = new ResolvedLocalComponentsResultGraphVisitor();
    results.graphResolved(emptyResult, emptyProjectResult, new EmptyResults());
}
项目:Reer    文件:ProjectDependencyResolver.java   
@Override
public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, BuildableComponentResolveResult result) {
    if (identifier instanceof ProjectComponentIdentifier) {
        ProjectComponentIdentifier projectId = (ProjectComponentIdentifier) identifier;
        LocalComponentMetadata componentMetaData = localComponentRegistry.getComponent(projectId);
        if (componentMetaData == null) {
            result.failed(new ModuleVersionResolveException(DefaultProjectComponentSelector.newSelector(projectId), projectId + " not found."));
        } else {
            result.resolved(componentMetaData);
        }
    }
}
项目:Reer    文件:DefaultProjectLocalComponentProvider.java   
private LocalComponentMetadata getLocalComponentMetaData(ProjectInternal project) {
    Module module = project.getModule();
    ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(module);
    ComponentIdentifier componentIdentifier = newProjectId(project);
    DefaultLocalComponentMetadata metaData = new DefaultLocalComponentMetadata(moduleVersionIdentifier, componentIdentifier, module.getStatus(), project.getAttributesSchema());
    metaDataBuilder.addConfigurations(metaData, project.getConfigurations().withType(ConfigurationInternal.class));
    return metaData;
}
项目:Reer    文件:ResolveIvyFactory.java   
@Override
public void resolve(final ComponentIdentifier identifier, final ComponentOverrideMetadata componentOverrideMetadata, final BuildableComponentResolveResult result) {
    cacheLockingManager.useCache("Resolve " + identifier, new Runnable() {
        public void run() {
            delegate.getComponentResolver().resolve(identifier, componentOverrideMetadata, result);
        }
    });
}
项目:Reer    文件:RepositoryChainComponentMetaDataResolver.java   
public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, BuildableComponentResolveResult result) {
    if (!(identifier instanceof ModuleComponentIdentifier)) {
        throw new UnsupportedOperationException("Can resolve meta-data for module components only.");
    }

    resolveModule((ModuleComponentIdentifier) identifier, componentOverrideMetadata, result);
}
项目:Reer    文件:InMemoryArtifactsCache.java   
public boolean supplyArtifacts(ComponentIdentifier component, ArtifactType type, BuildableArtifactSetResolveResult result) {
    Set<ComponentArtifactMetadata> artifacts = typedArtifacts.get(new TypedArtifactsKey(component, type));
    if (artifacts != null) {
        result.resolved(artifacts);
        return true;
    }
    return false;
}
项目:Reer    文件:InMemoryArtifactsCache.java   
public boolean supplyArtifacts(ComponentIdentifier component, BuildableComponentArtifactsResolveResult result) {
    ComponentArtifacts artifacts = this.componentArtifacts.get(component);
    if (artifacts != null) {
        result.resolved(artifacts);
        return true;
    }
    return false;
}
项目:Reer    文件:DefaultModuleArtifactsCache.java   
public CachedArtifacts getCachedArtifacts(ModuleComponentRepository repository, ComponentIdentifier componentId, String context) {
    ModuleArtifactsKey key = new ModuleArtifactsKey(repository.getId(), componentId, context);
    ModuleArtifactsCacheEntry entry = getCache().get(key);
    if (entry == null) {
        return null;
    }
    return createCacheArtifacts(entry);
}
项目:Reer    文件:ComponentResolversChain.java   
@Override
public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, BuildableComponentResolveResult result) {
    for (ComponentMetaDataResolver resolver : resolvers) {
        if (result.hasResult()) {
            return;
        }
        resolver.resolve(identifier, componentOverrideMetadata, result);
    }
}
项目:Reer    文件:ComponentIdentifierSerializer.java   
public void write(Encoder encoder, ComponentIdentifier value) throws IOException {
    if (value == null) {
        throw new IllegalArgumentException("Provided component identifier may not be null");
    }

    Implementation implementation = resolveImplementation(value);

    encoder.writeByte(implementation.getId());

    if (implementation == Implementation.MODULE) {
        ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) value;
        encoder.writeString(moduleComponentIdentifier.getGroup());
        encoder.writeString(moduleComponentIdentifier.getModule());
        encoder.writeString(moduleComponentIdentifier.getVersion());
    } else if (implementation == Implementation.BUILD) {
        ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) value;
        BuildIdentifier build = projectComponentIdentifier.getBuild();
        buildIdentifierSerializer.write(encoder, build);
        encoder.writeString(projectComponentIdentifier.getProjectPath());
    } else if (implementation == Implementation.LIBRARY) {
        LibraryBinaryIdentifier libraryIdentifier = (LibraryBinaryIdentifier) value;
        encoder.writeString(libraryIdentifier.getProjectPath());
        encoder.writeString(libraryIdentifier.getLibraryName());
        encoder.writeString(libraryIdentifier.getVariant());
    } else {
        throw new IllegalStateException("Unsupported implementation type: " + implementation);
    }
}
项目:Reer    文件:ComponentIdentifierSerializer.java   
private Implementation resolveImplementation(ComponentIdentifier value) {
    Implementation implementation;
    if (value instanceof ModuleComponentIdentifier) {
        implementation = Implementation.MODULE;
    } else if (value instanceof ProjectComponentIdentifier) {
        implementation = Implementation.BUILD;
    } else if (value instanceof LibraryBinaryIdentifier) {
        implementation = Implementation.LIBRARY;
    } else {
        throw new IllegalArgumentException("Unsupported component identifier class: " + value.getClass());
    }
    return implementation;
}
项目:Reer    文件:IdeDependenciesExtractor.java   
private static void downloadAuxiliaryArtifacts(DependencyHandler dependencyHandler, Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> dependencies, List<Class<? extends Artifact>> artifactTypes) {
    if (artifactTypes.isEmpty()) {
        return;
    }

    ArtifactResolutionQuery query = dependencyHandler.createArtifactResolutionQuery();
    query.forComponents(dependencies.keySet());

    @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) artifactTypes.toArray(new Class<?>[0]);
    query.withArtifacts(JvmLibrary.class, artifactTypesArray);
    Set<ComponentArtifactsResult> componentResults = query.execute().getResolvedComponents();
    for (ComponentArtifactsResult componentResult : componentResults) {
        for (IdeExtendedRepoFileDependency dependency : dependencies.get(componentResult.getId())) {
            for (ArtifactResult sourcesResult : componentResult.getArtifacts(SourcesArtifact.class)) {
                if (sourcesResult instanceof ResolvedArtifactResult) {
                    dependency.addSourceFile(((ResolvedArtifactResult) sourcesResult).getFile());
                }
            }

            for (ArtifactResult javadocResult : componentResult.getArtifacts(JavadocArtifact.class)) {
                if (javadocResult instanceof ResolvedArtifactResult) {
                    dependency.addJavadocFile(((ResolvedArtifactResult) javadocResult).getFile());
                }
            }
        }
    }
}
项目:Reer    文件:ComponentResultSerializer.java   
public ComponentResult read(Decoder decoder) throws IOException {
    long resultId = decoder.readSmallLong();
    ModuleVersionIdentifier id = idSerializer.read(decoder);
    ComponentSelectionReason reason = reasonSerializer.read(decoder);
    ComponentIdentifier componentId = componentIdSerializer.read(decoder);
    return new DefaultComponentResult(resultId, id, reason, componentId);
}
项目:Reer    文件:ResolvedLocalComponentsResultGraphVisitor.java   
@Override
public void visitNode(DependencyGraphNode resolvedConfiguration) {
    ComponentIdentifier componentId = resolvedConfiguration.getOwner().getComponentId();
    if (!rootId.equals(componentId) && componentId instanceof ProjectComponentIdentifier) {
        resolvedProjectConfigurations.add(new DefaultResolvedProjectConfiguration((ProjectComponentIdentifier) componentId, resolvedConfiguration.getResolvedConfigurationId().getConfiguration()));
    }
}
项目:Reer    文件:DefaultArtifactResolutionQuery.java   
private ComponentArtifactsResult buildComponentResult(ComponentIdentifier componentId, ComponentMetaDataResolver componentMetaDataResolver, ArtifactResolver artifactResolver) {
    BuildableComponentResolveResult moduleResolveResult = new DefaultBuildableComponentResolveResult();
    componentMetaDataResolver.resolve(componentId, new DefaultComponentOverrideMetadata(), moduleResolveResult);
    ComponentResolveMetadata component = moduleResolveResult.getMetaData();
    DefaultComponentArtifactsResult componentResult = new DefaultComponentArtifactsResult(component.getComponentId());
    for (Class<? extends Artifact> artifactType : artifactTypes) {
        addArtifacts(componentResult, artifactType, component, artifactResolver);
    }
    return componentResult;
}
项目:Reer    文件:DefaultConfiguration.java   
public ComponentResolveMetadata toRootComponentMetaData() {
    Module module = getModule();
    ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module);
    ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(module);
    ProjectInternal project = projectFinder.findProject(module.getProjectPath());
    AttributesSchema schema = project == null ? null : project.getAttributesSchema();
    DefaultLocalComponentMetadata metaData = new DefaultLocalComponentMetadata(moduleVersionIdentifier, componentIdentifier, module.getStatus(), schema);
    configurationComponentMetaDataBuilder.addConfigurations(metaData, configurationsProvider.getAll());
    return metaData;
}
项目:Reer    文件:DefaultComponentIdentifierFactory.java   
public ComponentIdentifier createComponentIdentifier(Module module) {
    String projectPath = module.getProjectPath();

    if(projectPath != null) {
        return new DefaultProjectComponentIdentifier(buildIdentity.getCurrentBuild(), projectPath);
    }

    return new DefaultModuleComponentIdentifier(module.getGroup(), module.getName(), module.getVersion());
}
项目:Reer    文件:DefaultResolvedComponentResult.java   
public DefaultResolvedComponentResult(ModuleVersionIdentifier moduleVersion, ComponentSelectionReason selectionReason, ComponentIdentifier componentId) {
    assert moduleVersion != null;
    assert selectionReason != null;

    this.moduleVersion = moduleVersion;
    this.selectionReason = selectionReason;
    this.componentId = componentId;
}
项目:Reer    文件:InvertedRenderableModuleResult.java   
@Override
public Set<RenderableDependency> getChildren() {
    Map<ComponentIdentifier, RenderableDependency> children = new LinkedHashMap<ComponentIdentifier, RenderableDependency>();
    for (ResolvedDependencyResult dependent : module.getDependents()) {
        InvertedRenderableModuleResult child = new InvertedRenderableModuleResult(dependent.getFrom());
        if (!children.containsKey(child.getId())) {
            children.put(child.getId(), child);
        }
    }
    return new LinkedHashSet<RenderableDependency>(children.values());
}
项目:Reer    文件:ModuleVersionResolveException.java   
@Override
public String getMessage() {
    if (paths.isEmpty()) {
        return super.getMessage();
    }
    Formatter formatter = new Formatter();
    formatter.format("%s%nRequired by:", super.getMessage());
    for (List<? extends ComponentIdentifier> path : paths) {
        formatter.format("%n    %s", toString(path.get(0)));
        for (int i = 1; i < path.size(); i++) {
            formatter.format(" > %s", toString(path.get(i)));
        }
    }
    return formatter.toString();
}
项目:Reer    文件:ArtifactResolveException.java   
private static String format(ComponentIdentifier component, String message) {
    StringBuilder builder = new StringBuilder();
    builder.append("Could not determine artifacts for ");
    builder.append(component.getDisplayName());
    if (GUtil.isTrue(message)) {
        builder.append(": ");
        builder.append(message);
    }
    return builder.toString();
}
项目:Reer    文件:DefaultLibraryComponentSelector.java   
public boolean matchesStrictly(ComponentIdentifier identifier) {
    assert identifier != null : "identifier cannot be null";

    if (identifier instanceof LibraryBinaryIdentifier) {
        LibraryBinaryIdentifier projectComponentIdentifier = (LibraryBinaryIdentifier) identifier;
        return Objects.equal(projectComponentIdentifier.getProjectPath(), projectPath)
            && Objects.equal(projectComponentIdentifier.getLibraryName(), libraryName)
            && Objects.equal(projectComponentIdentifier.getVariant(), variant);
    }

    return false;
}
项目:Reer    文件:IdeDependenciesExtractor.java   
public Collection<IdeExtendedRepoFileDependency> extractRepoFileDependencies(DependencyHandler dependencyHandler, Collection<Configuration> plusConfigurations, Collection<Configuration> minusConfigurations, boolean downloadSources, boolean downloadJavadoc) {
    // can have multiple IDE dependencies with same component identifier (see GRADLE-1622)
    Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> resolvedDependenciesComponentMap = LinkedHashMultimap.create();
    for (IdeExtendedRepoFileDependency dep : resolvedExternalDependencies(plusConfigurations, minusConfigurations)) {
        resolvedDependenciesComponentMap.put(toComponentIdentifier(dep.getId()), dep);
    }

    List<Class<? extends Artifact>> artifactTypes = new ArrayList<Class<? extends Artifact>>(2);
    if (downloadSources) {
        artifactTypes.add(SourcesArtifact.class);
    }

    if (downloadJavadoc) {
        artifactTypes.add(JavadocArtifact.class);
    }

    downloadAuxiliaryArtifacts(dependencyHandler, resolvedDependenciesComponentMap, artifactTypes);

    Collection<UnresolvedIdeRepoFileDependency> unresolvedDependencies = unresolvedExternalDependencies(plusConfigurations, minusConfigurations);
    Collection<IdeExtendedRepoFileDependency> resolvedDependencies = resolvedDependenciesComponentMap.values();

    Collection<IdeExtendedRepoFileDependency> resolvedAndUnresolved = new ArrayList<IdeExtendedRepoFileDependency>(unresolvedDependencies.size() + resolvedDependencies.size());
    resolvedAndUnresolved.addAll(resolvedDependencies);
    resolvedAndUnresolved.addAll(unresolvedDependencies);

    return resolvedAndUnresolved;
}
项目:Reer    文件:DefaultModuleComponentSelector.java   
public boolean matchesStrictly(ComponentIdentifier identifier) {
    assert identifier != null : "identifier cannot be null";

    if(identifier instanceof ModuleComponentIdentifier) {
        ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier)identifier;
        return module.equals(moduleComponentIdentifier.getModule())
                && group.equals(moduleComponentIdentifier.getGroup())
                && version.equals(moduleComponentIdentifier.getVersion());
    }

    return false;
}
项目:Reer    文件:JsonProjectDependencyRenderer.java   
private void populateModulesWithChildDependencies(RenderableDependency dependency, Set<ComponentIdentifier> visited, Set<ModuleIdentifier> modules) {
    for (RenderableDependency childDependency : dependency.getChildren()) {
        ModuleIdentifier moduleId = getModuleIdentifier(childDependency);
        if (moduleId == null) {
            continue;
        }
        modules.add(moduleId);
        boolean alreadyVisited = !visited.add((ComponentIdentifier) childDependency.getId());
        if (!alreadyVisited) {
            populateModulesWithChildDependencies(childDependency, visited, modules);
        }
    }
}
项目:Reer    文件:StrictDependencyResultSpec.java   
private boolean matchesSelected(ResolvedDependencyResult candidate) {
    ComponentIdentifier selected = candidate.getSelected().getId();

    if (moduleIdentifier != null && selected instanceof ModuleComponentIdentifier) {
        ModuleComponentIdentifier selectedModule = (ModuleComponentIdentifier) selected;
        return selectedModule.getGroup().equals(moduleIdentifier.getGroup())
                && selectedModule.getModule().equals(moduleIdentifier.getName());
    }

    return false;
}
项目:Reer    文件:DependencyInsightReporter.java   
public Collection<RenderableDependency> prepare(Collection<DependencyResult> input, VersionSelectorScheme versionSelectorScheme, VersionComparator versionComparator) {
    LinkedList<RenderableDependency> out = new LinkedList<RenderableDependency>();
    List<DependencyEdge> dependencies = CollectionUtils.collect(input, new Transformer<DependencyEdge, DependencyResult>() {
        @Override
        public DependencyEdge transform(DependencyResult result) {
            if (result instanceof UnresolvedDependencyResult) {
                return new UnresolvedDependencyEdge((UnresolvedDependencyResult) result);
            } else {
                return new ResolvedDependencyEdge((ResolvedDependencyResult) result);
            }
        }
    });
    Collection<DependencyEdge> sorted = DependencyResultSorter.sort(dependencies, versionSelectorScheme, versionComparator);

    //remember if module id was annotated
    HashSet<ComponentIdentifier> annotated = new HashSet<ComponentIdentifier>();
    RequestedVersion current = null;

    for (DependencyEdge dependency : sorted) {
        //add description only to the first module
        if (annotated.add(dependency.getActual())) {
            //add a heading dependency with the annotation if the dependency does not exist in the graph
            if (!dependency.getRequested().matchesStrictly(dependency.getActual())) {
                out.add(new DependencyReportHeader(dependency));
                current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), null);
                out.add(current);
            } else {
                current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), getReasonDescription(dependency.getReason()));
                out.add(current);
            }
        } else if (!current.getRequested().equals(dependency.getRequested())) {
            current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), null);
            out.add(current);
        }

        current.addChild(dependency);
    }

    return out;
}
项目:Reer    文件:ResolvedDependencyEdge.java   
@Override
public ComponentIdentifier getActual() {
    return dependency.getSelected().getId();
}
项目:Reer    文件:LocalLibraryDependencyResolver.java   
@Override
public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, BuildableComponentResolveResult result) {
    if (isLibrary(identifier)) {
        throw new RuntimeException("Not yet implemented");
    }
}
项目:Reer    文件:LocalLibraryDependencyResolver.java   
private boolean isLibrary(ComponentIdentifier identifier) {
    return identifier instanceof LibraryBinaryIdentifier;
}
项目:Reer    文件:DefaultLibraryLocalComponentMetadata.java   
private DefaultLibraryLocalComponentMetadata(ModuleVersionIdentifier id, ComponentIdentifier componentIdentifier) {
    super(id, componentIdentifier, Project.DEFAULT_STATUS, new DefaultAttributesSchema());
}
项目:Reer    文件:DefaultLenientConfiguration.java   
@Override
public void visitFiles(@Nullable ComponentIdentifier componentIdentifier, Iterable<File> files) {
    CollectionUtils.addAll(this.files, files);
}
项目:Reer    文件:ProjectDependencyResolver.java   
private boolean isProjectModule(ComponentIdentifier componentId) {
    return componentId instanceof ProjectComponentIdentifier;
}
项目:Reer    文件:UnversionedModuleComponentSelector.java   
@Override
public boolean matchesStrictly(ComponentIdentifier identifier) {
    return false;
}
项目:Reer    文件:NoRepositoriesResolver.java   
@Override
public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, BuildableComponentResolveResult result) {
    throw new UnsupportedOperationException();
}