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;
}
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);
}
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));
}
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);
}
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();
}
}
Aggregations