Search in sources :

Example 6 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class RejectedModuleMessageBuilder method pathTo.

private static Collection<String> pathTo(EdgeState edge) {
    List<List<EdgeState>> acc = Lists.newArrayListWithExpectedSize(1);
    pathTo(edge, Lists.<EdgeState>newArrayList(), acc, Sets.<NodeState>newHashSet());
    List<String> result = Lists.newArrayListWithCapacity(acc.size());
    for (List<EdgeState> path : acc) {
        EdgeState target = Iterators.getLast(path.iterator());
        StringBuilder sb = new StringBuilder();
        if (target.getSelector().getDependencyMetadata().isPending()) {
            sb.append("Constraint path ");
        } else {
            sb.append("Dependency path ");
        }
        for (EdgeState e : path) {
            ModuleVersionIdentifier id = e.getFrom().getResolvedConfigurationId().getId();
            sb.append('\'').append(id).append('\'');
            sb.append(" --> ");
        }
        ModuleIdentifier moduleId = edge.getTargetComponent().getModule().getId();
        sb.append('\'').append(moduleId.getGroup()).append(':').append(moduleId.getName()).append('\'');
        result.add(sb.toString());
    }
    return result;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) List(java.util.List) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 7 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class GradlePomModuleDescriptorBuilder method doAddDependency.

private void doAddDependency(PomDependencyMgt dep, boolean optional, boolean useCompileScope) {
    MavenScope scope;
    if (useCompileScope) {
        scope = MavenScope.Compile;
    } else {
        String scopeString = dep.getScope();
        if (scopeString == null || scopeString.length() == 0) {
            scopeString = getDefaultScope(dep);
        }
        if (SCOPES.containsKey(scopeString)) {
            scope = SCOPES.get(scopeString);
        } else {
            // unknown scope, defaulting to 'compile'
            scope = MavenScope.Compile;
        }
    }
    String version = determineVersion(dep);
    String mappedVersion = convertVersionFromMavenSyntax(version);
    ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(dep.getGroupId(), dep.getArtifactId(), new DefaultImmutableVersionConstraint(mappedVersion));
    // Example: http://repo2.maven.org/maven2/net/jini/jsk-platform/2.1/jsk-platform-2.1.pom
    if (selector.getGroup().equals(componentIdentifier.getGroup()) && selector.getModule().equals(componentIdentifier.getModule())) {
        return;
    }
    IvyArtifactName dependencyArtifact = null;
    boolean hasClassifier = dep.getClassifier() != null && dep.getClassifier().length() > 0;
    boolean hasNonJarType = dep.getType() != null && !"jar".equals(dep.getType());
    if (hasClassifier || hasNonJarType) {
        String type = "jar";
        if (dep.getType() != null) {
            type = dep.getType();
        }
        String ext = determineExtension(type);
        String classifier = hasClassifier ? dep.getClassifier() : getClassifierForType(type);
        dependencyArtifact = new DefaultIvyArtifactName(selector.getModule(), type, ext, classifier);
    }
    // experimentation shows the following, excluded modules are
    // inherited from parent POMs if either of the following is true:
    // the <exclusions> element is missing or the <exclusions> element
    // is present, but empty.
    List<ExcludeMetadata> excludes = Lists.newArrayList();
    List<ModuleIdentifier> excluded = dep.getExcludedModules();
    if (excluded.isEmpty()) {
        excluded = getDependencyMgtExclusions(dep);
    }
    for (ModuleIdentifier excludedModule : excluded) {
        DefaultExclude rule = new DefaultExclude(excludedModule);
        excludes.add(rule);
    }
    dependencies.add(new MavenDependencyDescriptor(scope, optional, selector, dependencyArtifact, excludes));
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) MavenScope(org.gradle.internal.component.external.descriptor.MavenScope) MavenDependencyDescriptor(org.gradle.internal.component.external.model.MavenDependencyDescriptor) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 8 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project atlas by alibaba.

the class ApDependency method addDependency.

// ----- PRIVATE TASK API -----
private void addDependency(String dependencyString, Map<ModuleIdentifier, String> awb) {
    ParsedModuleStringNotation parsedNotation = new ParsedModuleStringNotation(dependencyString, dependencyString.split("@")[1]);
    ModuleIdentifier moduleIdentifier = DefaultModuleIdentifier.newId(parsedNotation.getGroup(), parsedNotation.getName());
    String version = parsedNotation.getVersion();
    awb.put(moduleIdentifier, version);
    mFlatDependenciesMap.put(moduleIdentifier, version);
}
Also used : ParsedModuleStringNotation(org.gradle.api.internal.artifacts.dsl.ParsedModuleStringNotation) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) DefaultModuleIdentifier(org.gradle.api.internal.artifacts.DefaultModuleIdentifier)

Example 9 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project atlas by alibaba.

the class ApDependency method getAwbDependencies.

private Map<ModuleIdentifier, String> getAwbDependencies(String awb) {
    ParsedModuleStringNotation parsedNotation = new ParsedModuleStringNotation(awb, "awb");
    String group = parsedNotation.getGroup();
    String name = parsedNotation.getName();
    ModuleIdentifier moduleIdentifier = DefaultModuleIdentifier.newId(group, name);
    Map<ModuleIdentifier, String> awbDependencies = mAwbDependenciesMap.get(moduleIdentifier);
    if (awbDependencies == null) {
        awbDependencies = Maps.newHashMap();
        mAwbDependenciesMap.put(moduleIdentifier, awbDependencies);
    }
    return awbDependencies;
}
Also used : ParsedModuleStringNotation(org.gradle.api.internal.artifacts.dsl.ParsedModuleStringNotation) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) DefaultModuleIdentifier(org.gradle.api.internal.artifacts.DefaultModuleIdentifier)

Example 10 with ModuleIdentifier

use of org.gradle.api.artifacts.ModuleIdentifier in project gradle by gradle.

the class RepositoryChainDependencyToComponentIdResolver method resolve.

@Override
public void resolve(DependencyMetadata dependency, VersionSelector acceptor, @Nullable VersionSelector rejector, BuildableComponentIdResolveResult result) {
    ComponentSelector componentSelector = dependency.getSelector();
    if (componentSelector instanceof ModuleComponentSelector) {
        ModuleComponentSelector module = (ModuleComponentSelector) componentSelector;
        if (acceptor.isDynamic()) {
            dynamicRevisionResolver.resolve(toModuleDependencyMetadata(dependency), acceptor, rejector, consumerAttributes, result);
        } else {
            String version = acceptor.getSelector();
            ModuleIdentifier moduleId = module.getModuleIdentifier();
            ModuleComponentIdentifier id = DefaultModuleComponentIdentifier.newId(moduleId, version);
            ModuleVersionIdentifier mvId = DefaultModuleVersionIdentifier.newId(moduleId, version);
            if (rejector != null && rejector.accept(version)) {
                result.rejected(id, mvId);
            } else {
                result.resolved(id, mvId);
            }
        }
    }
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultModuleVersionIdentifier(org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Aggregations

ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)46 DefaultModuleIdentifier (org.gradle.api.internal.artifacts.DefaultModuleIdentifier)8 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)7 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)5 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 ExcludeSpec (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ExcludeSpec)4 GroupExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupExclude)4 GroupSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.GroupSetExclude)4 ModuleExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleExclude)4 ModuleIdExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdExclude)4 ModuleIdSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleIdSetExclude)4 ModuleSetExclude (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.specs.ModuleSetExclude)4 LinkedHashSet (java.util.LinkedHashSet)3 Action (org.gradle.api.Action)3 InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)3 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)3 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)3 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)3