Search in sources :

Example 1 with ExcludeMetadata

use of org.gradle.internal.component.model.ExcludeMetadata in project gradle by gradle.

the class ModuleExclusions method excludeAny.

/**
 * Returns a spec that excludes those modules and artifacts that are excluded by _any_ of the given exclude rules.
 */
public ModuleExclusion excludeAny(ImmutableList<ExcludeMetadata> excludes) {
    if (excludes.isEmpty()) {
        return EXCLUDE_NONE;
    }
    AbstractModuleExclusion exclusion = excludeAnyCache.get(excludes);
    if (exclusion != null) {
        return exclusion;
    }
    ImmutableSet.Builder<AbstractModuleExclusion> exclusions = ImmutableSet.builder();
    for (ExcludeMetadata exclude : excludes) {
        exclusions.add(forExclude(exclude));
    }
    exclusion = asIntersection(exclusions.build());
    excludeAnyCache.put(excludes, exclusion);
    return exclusion;
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 2 with ExcludeMetadata

use of org.gradle.internal.component.model.ExcludeMetadata in project gradle by gradle.

the class EdgeState method getExclusions.

@Override
public ModuleExclusion getExclusions() {
    List<ExcludeMetadata> excludes = dependencyMetadata.getExcludes();
    if (excludes.isEmpty()) {
        return transitiveExclusions;
    }
    ModuleExclusion edgeExclusions = resolveState.getModuleExclusions().excludeAny(ImmutableList.copyOf(excludes));
    return resolveState.getModuleExclusions().intersect(edgeExclusions, transitiveExclusions);
}
Also used : ModuleExclusion(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 3 with ExcludeMetadata

use of org.gradle.internal.component.model.ExcludeMetadata 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 4 with ExcludeMetadata

use of org.gradle.internal.component.model.ExcludeMetadata in project gradle by gradle.

the class ExternalModuleIvyDependencyDescriptorFactory method createDependencyDescriptor.

public LocalOriginDependencyMetadata createDependencyDescriptor(ComponentIdentifier componentId, String clientConfiguration, AttributeContainer clientAttributes, ModuleDependency dependency) {
    ExternalModuleDependency externalModuleDependency = (ExternalModuleDependency) dependency;
    boolean force = externalModuleDependency.isForce();
    boolean changing = externalModuleDependency.isChanging();
    boolean transitive = externalModuleDependency.isTransitive();
    ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(nullToEmpty(dependency.getGroup()), nullToEmpty(dependency.getName()), ((VersionConstraintInternal) externalModuleDependency.getVersionConstraint()).asImmutable());
    List<ExcludeMetadata> excludes = convertExcludeRules(clientConfiguration, dependency.getExcludeRules());
    LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata(componentId, selector, clientConfiguration, clientAttributes, dependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), excludes, force, changing, transitive, false, dependency.getReason());
    return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency);
}
Also used : DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DslOriginDependencyMetadataWrapper(org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper) ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata) LocalComponentDependencyMetadata(org.gradle.internal.component.model.LocalComponentDependencyMetadata)

Example 5 with ExcludeMetadata

use of org.gradle.internal.component.model.ExcludeMetadata in project gradle by gradle.

the class DefaultIvyModuleDescriptorWriter method printAllExcludes.

private static void printAllExcludes(IvyModulePublishMetadata metadata, SimpleXmlWriter writer) throws IOException {
    for (Pair<ExcludeMetadata, String> excludePair : metadata.getExcludes()) {
        ExcludeMetadata exclude = excludePair.getLeft();
        writer.startElement("exclude");
        writer.attribute("org", exclude.getModuleId().getGroup());
        writer.attribute("module", exclude.getModuleId().getName());
        IvyArtifactName artifact = exclude.getArtifact();
        if (artifact != null) {
            writer.attribute("artifact", artifact.getName());
            writer.attribute("type", artifact.getType());
            writer.attribute("ext", artifact.getExtension());
        }
        writer.attribute("conf", excludePair.getRight());
        writer.endElement();
    }
}
Also used : IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Aggregations

ExcludeMetadata (org.gradle.internal.component.model.ExcludeMetadata)9 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)3 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)2 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)2 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)2 DslOriginDependencyMetadataWrapper (org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper)2 LocalComponentDependencyMetadata (org.gradle.internal.component.model.LocalComponentDependencyMetadata)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 ExternalModuleDependency (org.gradle.api.artifacts.ExternalModuleDependency)1 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)1 VersionConstraint (org.gradle.api.artifacts.VersionConstraint)1 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)1 ImmutableVersionConstraint (org.gradle.api.internal.artifacts.ImmutableVersionConstraint)1 ProjectDependencyInternal (org.gradle.api.internal.artifacts.dependencies.ProjectDependencyInternal)1 ModuleExclusion (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusion)1 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)1 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)1 MavenDependencyDescriptor (org.gradle.internal.component.external.model.MavenDependencyDescriptor)1