use of org.gradle.internal.component.model.DefaultIvyArtifactName in project gradle by gradle.
the class IvyModuleDescriptorConverter method addDependency.
private void addDependency(List<IvyDependencyMetadata> result, DependencyDescriptor dependencyDescriptor) {
ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId();
ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(revisionId.getOrganisation(), revisionId.getName(), revisionId.getRevision());
ListMultimap<String, String> configMappings = ArrayListMultimap.create();
for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) {
configMappings.putAll(entry.getKey(), entry.getValue());
}
List<Artifact> artifacts = Lists.newArrayList();
for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) {
IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER));
artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations())));
}
List<Exclude> excludes = Lists.newArrayList();
for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) {
excludes.add(forIvyExclude(excludeRule));
}
result.add(new IvyDependencyMetadata(requested, dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(), false, dependencyDescriptor.isChanging(), dependencyDescriptor.isTransitive(), configMappings, artifacts, excludes));
}
use of org.gradle.internal.component.model.DefaultIvyArtifactName 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.DefaultIvyArtifactName in project gradle by gradle.
the class DependencyResolverIvyPublisher method publish.
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) {
ModuleVersionPublisher publisher = repository.createPublisher();
IvyPublicationIdentity projectIdentity = publication.getProjectIdentity();
ModuleComponentIdentifier moduleVersionIdentifier = DefaultModuleComponentIdentifier.newId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision());
// Use the legacy metadata type so that we can leverage `ModuleVersionPublisher.publish()`
DefaultIvyModulePublishMetadata publishMetaData = new DefaultIvyModulePublishMetadata(moduleVersionIdentifier, "");
for (IvyArtifact publishArtifact : publication.getArtifacts()) {
publishMetaData.addArtifact(createIvyArtifact(publishArtifact), publishArtifact.getFile());
}
IvyArtifactName ivyDescriptor = new DefaultIvyArtifactName("ivy", "ivy", "xml");
publishMetaData.addArtifact(ivyDescriptor, publication.getIvyDescriptorFile());
File gradleModuleDescriptorFile = publication.getGradleModuleDescriptorFile();
if (gradleModuleDescriptorFile != null && gradleModuleDescriptorFile.exists()) {
// may not exist if experimental features are disabled
IvyArtifactName gradleDescriptor = new DefaultIvyArtifactName(projectIdentity.getModule(), "json", "module");
publishMetaData.addArtifact(gradleDescriptor, gradleModuleDescriptorFile);
}
publisher.publish(publishMetaData);
}
use of org.gradle.internal.component.model.DefaultIvyArtifactName in project gradle by gradle.
the class IvyModuleDescriptorConverter method addDependency.
private void addDependency(List<IvyDependencyDescriptor> result, DependencyDescriptor dependencyDescriptor) {
ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId();
ModuleComponentSelector requested = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(revisionId.getOrganisation(), revisionId.getName()), new DefaultImmutableVersionConstraint(revisionId.getRevision()));
ListMultimap<String, String> configMappings = ArrayListMultimap.create();
for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) {
configMappings.putAll(entry.getKey(), entry.getValue());
}
List<Artifact> artifacts = Lists.newArrayList();
for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) {
IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER));
artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations())));
}
List<Exclude> excludes = Lists.newArrayList();
for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) {
excludes.add(forIvyExclude(excludeRule));
}
result.add(new IvyDependencyDescriptor(requested, dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(), dependencyDescriptor.isChanging(), dependencyDescriptor.isTransitive(), false, configMappings, artifacts, excludes));
}
use of org.gradle.internal.component.model.DefaultIvyArtifactName in project gradle by gradle.
the class GradlePomModuleDescriptorBuilder method doAddDependency.
private void doAddDependency(PomDependencyMgt dep, MavenDependencyType dependencyType) {
MavenScope scope;
if (dependencyType == MavenDependencyType.DEPENDENCY_MANAGEMENT) {
scope = MavenScope.Compile;
} else {
String scopeString = dep.getScope();
if (scopeString == null || scopeString.length() == 0) {
scopeString = getDefaultScope(dep);
}
// unknown scope, defaulting to 'compile'
scope = SCOPES.getOrDefault(scopeString, MavenScope.Compile);
}
String version = determineVersion(dep);
String mappedVersion = convertVersionFromMavenSyntax(version);
ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(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.getModuleIdentifier().equals(componentIdentifier.getModuleIdentifier())) {
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, dependencyType, selector, dependencyArtifact, excludes));
}
Aggregations