org.gradle.api.artifacts.component.ComponentIdentifier Java Examples

The following examples show how to use org.gradle.api.artifacts.component.ComponentIdentifier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientModuleResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void resolve(DependencyMetaData dependency, ComponentIdentifier identifier, BuildableComponentResolveResult result) {
    resolver.resolve(dependency, identifier, result);

    if (result.getFailure() != null) {
        return;
    }
    if (dependency instanceof DslOriginDependencyMetaData) {
        ModuleDependency maybeClientModule = ((DslOriginDependencyMetaData) dependency).getSource();
        if (maybeClientModule instanceof ClientModule) {
            ClientModule clientModule = (ClientModule) maybeClientModule;

            MutableModuleComponentResolveMetaData clientModuleMetaData = ((MutableModuleComponentResolveMetaData)result.getMetaData()).copy();
            addClientModuleDependencies(clientModule, clientModuleMetaData);

            setClientModuleArtifact(clientModuleMetaData);

            result.setMetaData(clientModuleMetaData);
        }
    }
}
 
Example #2
Source File: ComponentIdentifierSerializer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void write(Encoder encoder, ComponentIdentifier value) throws IOException {
    if(value == null) {
        throw new IllegalArgumentException("Provided component identifier may not be null");
    }

    if(value instanceof DefaultModuleComponentIdentifier) {
        ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier)value;
        encoder.writeByte(Implementation.MODULE.getId());
        encoder.writeString(moduleComponentIdentifier.getGroup());
        encoder.writeString(moduleComponentIdentifier.getModule());
        encoder.writeString(moduleComponentIdentifier.getVersion());
    } else if(value instanceof DefaultProjectComponentIdentifier) {
        ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier)value;
        encoder.writeByte(Implementation.BUILD.getId());
        encoder.writeString(projectComponentIdentifier.getProjectPath());
    } else {
        throw new IllegalArgumentException("Unsupported component identifier class: " + value.getClass());
    }
}
 
Example #3
Source File: ArtifactResolveException.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static String format(ComponentIdentifier component, String message) {
    StringBuilder builder = new StringBuilder();
    builder.append("Could not determine artifacts for component '");
    builder.append(component.getDisplayName());
    builder.append("'");
    if (GUtil.isTrue(message)) {
        builder.append(": ");
        builder.append(message);
    }
    return builder.toString();
}
 
Example #4
Source File: StreamingResolutionResultBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResultBuilder start(final ModuleVersionIdentifier root, final ComponentIdentifier componentIdentifier) {
    store.write(new BinaryStore.WriteAction() {
        public void write(Encoder encoder) throws IOException {
            encoder.writeByte(ROOT);
            moduleVersionIdentifierSerializer.write(encoder, root);
            componentIdentifierSerializer.write(encoder, componentIdentifier);
        }
    });
    return this;
}
 
Example #5
Source File: RepositoryChainAdapter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(DependencyMetaData dependency, ComponentIdentifier identifier, BuildableComponentResolveResult result) {
    if (!(identifier instanceof ModuleComponentIdentifier)) {
        throw new UnsupportedOperationException("Can resolve meta-data for module components only.");
    }

    // Force the requested version
    ModuleComponentIdentifier moduleId = (ModuleComponentIdentifier) identifier;
    dependency = dependency.withRequestedVersion(new DefaultModuleVersionSelector(moduleId.getGroup(), moduleId.getModule(), moduleId.getVersion()));

    metaDataResolver.resolve(dependency, result);
}
 
Example #6
Source File: AtlasDependencyGraph.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static void handleSources(
        @NonNull Project project,
        @NonNull Set<ComponentIdentifier> artifacts,
        @NonNull Consumer<SyncIssue> failureConsumer) {
    final DependencyHandler dependencies = project.getDependencies();

    try {
        ArtifactResolutionQuery query = dependencies.createArtifactResolutionQuery();
        query.forComponents(artifacts);

        @SuppressWarnings("unchecked")
        Class<? extends Artifact>[] artifactTypesArray =
                (Class<? extends Artifact>[]) new Class<?>[] {SourcesArtifact.class};
        query.withArtifacts(JvmLibrary.class, artifactTypesArray);
        query.execute().getResolvedComponents();
    } catch (Throwable t) {
        DependencyFailureHandlerKt.processDependencyThrowable(
                t,
                s -> null,
                (data, messages) ->
                        failureConsumer.accept(
                                new SyncIssueImpl(
                                        SyncIssue.TYPE_GENERIC,
                                        SyncIssue.SEVERITY_WARNING,
                                        null,
                                        String.format(
                                                "Unable to download sources: %s",
                                                messages.get(0)),
                                        messages)));
    }
}
 
Example #7
Source File: ComponentIdentifierSerializer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ComponentIdentifier read(Decoder decoder) throws IOException {
    byte id = decoder.readByte();

    if(Implementation.BUILD.getId() == id) {
        return new DefaultProjectComponentIdentifier(decoder.readString());
    } else if(Implementation.MODULE.getId() == id) {
        return new DefaultModuleComponentIdentifier(decoder.readString(), decoder.readString(), decoder.readString());
    }

    throw new IllegalArgumentException("Unable to find component identifier with id: " + id);
}
 
Example #8
Source File: ComponentIdentifierSerializer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ComponentIdentifier read(Decoder decoder) throws IOException {
    byte id = decoder.readByte();

    if(Implementation.BUILD.getId() == id) {
        return new DefaultProjectComponentIdentifier(decoder.readString());
    } else if(Implementation.MODULE.getId() == id) {
        return new DefaultModuleComponentIdentifier(decoder.readString(), decoder.readString(), decoder.readString());
    }

    throw new IllegalArgumentException("Unable to find component identifier with id: " + id);
}
 
Example #9
Source File: ComponentIdentifierSerializer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ComponentIdentifier read(Decoder decoder) throws IOException {
    byte id = decoder.readByte();

    if(Implementation.BUILD.getId() == id) {
        return new DefaultProjectComponentIdentifier(decoder.readString());
    } else if(Implementation.MODULE.getId() == id) {
        return new DefaultModuleComponentIdentifier(decoder.readString(), decoder.readString(), decoder.readString());
    }

    throw new IllegalArgumentException("Unable to find component identifier with id: " + id);
}
 
Example #10
Source File: DefaultResolvedComponentResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultResolvedComponentResult(ModuleVersionIdentifier id, ComponentSelectionReason selectionReason, ComponentIdentifier componentId) {
    assert id != null;
    assert selectionReason != null;

    this.id = id;
    this.selectionReason = selectionReason;
    this.componentId = componentId;
}
 
Example #11
Source File: DefaultComponentIdentifierFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ComponentIdentifier createComponentIdentifier(ModuleInternal module) {
    String projectPath = module.getProjectPath();

    if(projectPath != null) {
        return new DefaultProjectComponentIdentifier(projectPath);
    }

    return new DefaultModuleComponentIdentifier(module.getGroup(), module.getName(), module.getVersion());
}
 
Example #12
Source File: StreamingResolutionResultBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResultBuilder start(final ModuleVersionIdentifier root, final ComponentIdentifier componentIdentifier) {
    store.write(new BinaryStore.WriteAction() {
        public void write(Encoder encoder) throws IOException {
            encoder.writeByte(ROOT);
            moduleVersionIdentifierSerializer.write(encoder, root);
            componentIdentifierSerializer.write(encoder, componentIdentifier);
        }
    });
    return this;
}
 
Example #13
Source File: DefaultModuleComponentSelector.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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;
}
 
Example #14
Source File: StrictDependencyResultSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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;
}
 
Example #15
Source File: DefaultComponentIdentifierFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ComponentIdentifier createComponentIdentifier(ModuleInternal module) {
    String projectPath = module.getProjectPath();

    if(projectPath != null) {
        return new DefaultProjectComponentIdentifier(projectPath);
    }

    return new DefaultModuleComponentIdentifier(module.getGroup(), module.getName(), module.getVersion());
}
 
Example #16
Source File: InvertedRenderableModuleResult.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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());
}
 
Example #17
Source File: StreamingResolutionResultBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResultBuilder start(final ModuleVersionIdentifier root, final ComponentIdentifier componentIdentifier) {
    store.write(new BinaryStore.WriteAction() {
        public void write(Encoder encoder) throws IOException {
            encoder.writeByte(ROOT);
            moduleVersionIdentifierSerializer.write(encoder, root);
            componentIdentifierSerializer.write(encoder, componentIdentifier);
        }
    });
    return this;
}
 
Example #18
Source File: ShortcircuitEmptyConfigsArtifactDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    ModuleMetadataProcessor metadataProcessor,
                    ResolverResults results) throws ResolveException {
    if (configuration.getAllDependencies().isEmpty()) {
        ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(configuration.getModule());
        ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(configuration.getModule());
        ResolutionResult emptyResult = new DefaultResolutionResultBuilder().start(id, componentIdentifier).complete();
        results.resolved(new EmptyResolvedConfiguration(), emptyResult);
    } else {
        dependencyResolver.resolve(configuration, repositories, metadataProcessor, results);
    }
}
 
Example #19
Source File: DefaultLocalComponentMetaData.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentIdentifier getComponentId() {
    return componentIdentifier;
}
 
Example #20
Source File: DependencyReportHeader.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentIdentifier getId() {
    return dependency.getActual();
}
 
Example #21
Source File: ResolvedDependencyEdge.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentIdentifier getActual() {
    return dependency.getSelected().getId();
}
 
Example #22
Source File: RenderableDependencyResult.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected ComponentIdentifier getActual() {
    return dependency.getSelected().getId();
}
 
Example #23
Source File: RequestedVersion.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RequestedVersion(ComponentSelector requested, ComponentIdentifier actual, boolean resolvable, String description) {
    this.requested = requested;
    this.actual = actual;
    this.resolvable = resolvable;
    this.description = description;
}
 
Example #24
Source File: DefaultModuleComponentArtifactMetaData.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentIdentifier getComponentId() {
    return id.getComponentIdentifier();
}
 
Example #25
Source File: DefaultComponentArtifactsResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultComponentArtifactsResult(ComponentIdentifier componentIdentifier) {
    this.componentIdentifier = componentIdentifier;
}
 
Example #26
Source File: AbstractSoftwareComponent.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentIdentifier getId() {
    return componentId;
}
 
Example #27
Source File: DefaultModuleVersionSelection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultModuleVersionSelection(ModuleVersionIdentifier id, ComponentSelectionReason reason, ComponentIdentifier componentIdentifier) {
    this.id = id;
    this.reason = reason;
    this.componentIdentifier = componentIdentifier;
}
 
Example #28
Source File: DefaultLocalArtifactIdentifier.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentIdentifier getComponentIdentifier() {
    return componentIdentifier;
}
 
Example #29
Source File: ArtifactResolveException.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolveException(ComponentIdentifier component, String message) {
    super(format(component, message));
}
 
Example #30
Source File: DefaultResolvedComponentResult.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ComponentIdentifier getId() {
    return componentId;
}