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