Search in sources :

Example 6 with DefaultIvyArtifactName

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);
}
Also used : DefaultIvyModulePublishMetadata(org.gradle.internal.component.external.ivypublish.DefaultIvyModulePublishMetadata) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifact(org.gradle.api.publish.ivy.IvyArtifact) File(java.io.File) ModuleVersionPublisher(org.gradle.api.internal.artifacts.ModuleVersionPublisher)

Example 7 with DefaultIvyArtifactName

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

the class IvyBackedArtifactPublisher method publish.

public void publish(final Iterable<? extends PublicationAwareRepository> repositories, final Module module, final Configuration configuration, final File descriptor) throws PublishException {
    Set<ConfigurationInternal> allConfigurations = Cast.uncheckedCast(configuration.getAll());
    Set<ConfigurationInternal> configurationsToPublish = Cast.uncheckedCast(configuration.getHierarchy());
    if (descriptor != null) {
        // Convert once, in order to write the Ivy descriptor with _all_ configurations
        IvyModulePublishMetadata publishMetaData = toPublishMetaData(module, allConfigurations);
        validatePublishMetaData(publishMetaData);
        ivyModuleDescriptorWriter.write(publishMetaData, descriptor);
    }
    // Convert a second time with only the published configurations: this ensures that the correct artifacts are included
    BuildableIvyModulePublishMetadata publishMetaData = toPublishMetaData(module, configurationsToPublish);
    if (descriptor != null) {
        IvyArtifactName artifact = new DefaultIvyArtifactName("ivy", "ivy", "xml");
        publishMetaData.addArtifact(artifact, descriptor);
    }
    List<ModuleVersionPublisher> publishResolvers = new ArrayList<ModuleVersionPublisher>();
    for (PublicationAwareRepository repository : repositories) {
        ModuleVersionPublisher publisher = repository.createPublisher();
        publishResolvers.add(publisher);
    }
    dependencyPublisher.publish(publishResolvers, publishMetaData);
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ArrayList(java.util.ArrayList) BuildableIvyModulePublishMetadata(org.gradle.internal.component.external.model.BuildableIvyModulePublishMetadata) PublicationAwareRepository(org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository) IvyModulePublishMetadata(org.gradle.internal.component.external.model.IvyModulePublishMetadata) BuildableIvyModulePublishMetadata(org.gradle.internal.component.external.model.BuildableIvyModulePublishMetadata) DefaultIvyModulePublishMetadata(org.gradle.internal.component.external.model.DefaultIvyModulePublishMetadata) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) ModuleVersionPublisher(org.gradle.api.internal.artifacts.ModuleVersionPublisher)

Example 8 with DefaultIvyArtifactName

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

the class ExternalResourceResolver method getDependencyArtifactNames.

private Set<IvyArtifactName> getDependencyArtifactNames(String moduleName, Set<IvyArtifactName> artifacts) {
    Set<IvyArtifactName> artifactSet = Sets.newLinkedHashSet();
    artifactSet.addAll(artifacts);
    if (artifactSet.isEmpty()) {
        artifactSet.add(new DefaultIvyArtifactName(moduleName, "jar", "jar"));
    }
    return artifactSet;
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 9 with DefaultIvyArtifactName

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

the class ComponentArtifactMetadataSerializer method read.

public ComponentArtifactMetadata read(Decoder decoder) throws Exception {
    ModuleComponentIdentifier componentIdentifier = (ModuleComponentIdentifier) componentIdentifierSerializer.read(decoder);
    String artifactName = decoder.readString();
    String type = decoder.readString();
    String extension = decoder.readNullableString();
    String classifier = decoder.readNullableString();
    return new DefaultModuleComponentArtifactMetadata(componentIdentifier, new DefaultIvyArtifactName(artifactName, type, extension, classifier));
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata)

Example 10 with DefaultIvyArtifactName

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

the class GradlePomModuleDescriptorBuilder method addDependency.

public void addDependency(PomDependencyData dep) {
    String scopeString = dep.getScope();
    if (scopeString == null || scopeString.length() == 0) {
        scopeString = getDefaultScope(dep);
    }
    MavenScope scope;
    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);
    ModuleVersionSelector selector = DefaultModuleVersionSelector.newSelector(dep.getGroupId(), dep.getArtifactId(), mappedVersion);
    // Example: http://repo2.maven.org/maven2/net/jini/jsk-platform/2.1/jsk-platform-2.1.pom
    if (selector.getGroup().equals(descriptor.getComponentIdentifier().getGroup()) && selector.getName().equals(descriptor.getComponentIdentifier().getModule())) {
        return;
    }
    boolean optional = dep.isOptional();
    List<Artifact> artifacts = Lists.newArrayList();
    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);
        // here we have to assume a type and ext for the artifact, so this is a limitation
        // compared to how m2 behave with classifiers
        String optionalizedScope = optional ? "optional" : scope.toString().toLowerCase();
        IvyArtifactName artifactName = new DefaultIvyArtifactName(selector.getName(), type, ext, classifier);
        artifacts.add(new Artifact(artifactName, Collections.singleton(optionalizedScope)));
    }
    // 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<Exclude> excludes = Lists.newArrayList();
    List<ModuleIdentifier> excluded = dep.getExcludedModules();
    if (excluded.isEmpty()) {
        excluded = getDependencyMgtExclusions(dep);
    }
    for (ModuleIdentifier excludedModule : excluded) {
        DefaultExclude rule = new DefaultExclude(moduleIdentifierFactory.module(excludedModule.getGroup(), excludedModule.getName()), WILDCARD, PatternMatchers.EXACT);
        excludes.add(rule);
    }
    dependencies.add(new MavenDependencyMetadata(scope, optional, selector, artifacts, excludes));
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) Exclude(org.gradle.internal.component.model.Exclude) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) Artifact(org.gradle.internal.component.external.descriptor.Artifact) MavenDependencyMetadata(org.gradle.internal.component.external.model.MavenDependencyMetadata) MavenScope(org.gradle.internal.component.external.descriptor.MavenScope) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Aggregations

DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)15 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)11 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)4 ModuleVersionPublisher (org.gradle.api.internal.artifacts.ModuleVersionPublisher)3 Artifact (org.gradle.internal.component.external.descriptor.Artifact)3 Exclude (org.gradle.internal.component.model.Exclude)3 List (java.util.List)2 Map (java.util.Map)2 DependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)2 ExcludeRule (org.apache.ivy.core.module.descriptor.ExcludeRule)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)2 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)2 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)2 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)2 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)2 ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)2 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)2 PublicationAwareRepository (org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository)2 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)2