use of org.gradle.internal.component.model.IvyArtifactName 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.IvyArtifactName in project gradle by gradle.
the class ArtifactTransformingVisitor method visitArtifact.
@Override
public void visitArtifact(String variantName, AttributeContainer variantAttributes, ResolvableArtifact artifact) {
TransformArtifactOperation operation = artifactResults.get(artifact);
if (operation.getFailure() != null) {
visitor.visitFailure(operation.getFailure());
return;
}
ResolvedArtifact sourceArtifact = artifact.toPublicView();
List<File> transformedFiles = operation.getResult();
TaskDependency buildDependencies = ((Buildable) artifact).getBuildDependencies();
for (File output : transformedFiles) {
IvyArtifactName artifactName = DefaultIvyArtifactName.forFile(output, sourceArtifact.getClassifier());
ComponentArtifactIdentifier newId = new ComponentFileArtifactIdentifier(sourceArtifact.getId().getComponentIdentifier(), artifactName);
DefaultResolvedArtifact resolvedArtifact = new DefaultResolvedArtifact(sourceArtifact.getModuleVersion().getId(), artifactName, newId, buildDependencies, output);
visitor.visitArtifact(variantName, target, resolvedArtifact);
}
}
use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.
the class IvyDependencyDescriptor method getConfigurationArtifacts.
public ImmutableList<IvyArtifactName> getConfigurationArtifacts(ConfigurationMetadata fromConfiguration) {
if (dependencyArtifacts.isEmpty()) {
return ImmutableList.of();
}
Collection<String> includedConfigurations = fromConfiguration.getHierarchy();
ImmutableList.Builder<IvyArtifactName> artifacts = ImmutableList.builder();
for (Artifact depArtifact : dependencyArtifacts) {
Set<String> artifactConfigurations = depArtifact.getConfigurations();
if (include(artifactConfigurations, includedConfigurations)) {
IvyArtifactName ivyArtifactName = depArtifact.getArtifactName();
artifacts.add(ivyArtifactName);
}
}
return artifacts.build();
}
use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.
the class AbstractDependencyDescriptorFactoryInternalTest method assertDependencyDescriptorHasArtifacts.
private void assertDependencyDescriptorHasArtifacts(DependencyMetadata dependencyMetadata) {
List<IvyArtifactName> artifactDescriptors = WrapUtil.toList(dependencyMetadata.getArtifacts());
assertThat(artifactDescriptors.size(), equalTo(2));
IvyArtifactName artifactDescriptorWithoutClassifier = findDescriptor(artifactDescriptors, artifact);
assertEquals(null, artifactDescriptorWithoutClassifier.getClassifier());
compareArtifacts(artifact, artifactDescriptorWithoutClassifier);
assertEquals(artifact.getType(), artifactDescriptorWithoutClassifier.getExtension());
IvyArtifactName artifactDescriptorWithClassifierAndConfs = findDescriptor(artifactDescriptors, artifactWithClassifiers);
assertEquals(artifactWithClassifiers.getClassifier(), artifactDescriptorWithClassifierAndConfs.getClassifier());
compareArtifacts(artifactWithClassifiers, artifactDescriptorWithClassifierAndConfs);
assertEquals(artifactWithClassifiers.getExtension(), artifactDescriptorWithClassifierAndConfs.getExtension());
}
use of org.gradle.internal.component.model.IvyArtifactName 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);
}
Aggregations