Search in sources :

Example 46 with IvyArtifactName

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

the class DefaultArtifactPublisher method isValidToPublish.

private boolean isValidToPublish(PublishArtifact artifact) {
    File artifactFile = artifact.getFile();
    if (artifactFile.isDirectory()) {
        throw new IllegalArgumentException("Cannot publish a directory (" + artifactFile + ")");
    }
    if (artifactFile.exists()) {
        return true;
    }
    IvyArtifactName ivyArtifactName = DefaultIvyArtifactName.forPublishArtifact(artifact);
    if (!isSigningArtifact(ivyArtifactName)) {
        throw new PublishException(String.format("Cannot publish artifact '%s' (%s) as it does not exist.", ivyArtifactName, artifactFile));
    }
    return false;
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) PublishException(org.gradle.api.artifacts.PublishException) File(java.io.File)

Example 47 with IvyArtifactName

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

the class DefaultIvyModuleDescriptorWriter method printDependency.

protected void printDependency(LocalOriginDependencyMetadata dep, SimpleXmlWriter writer) throws IOException {
    writer.startElement("dependency");
    ModuleVersionSelector requested = componentSelectorConverter.getSelector(dep.getSelector());
    writer.attribute("org", requested.getGroup());
    writer.attribute("name", requested.getName());
    writer.attribute("rev", requested.getVersion());
    if (dep.isForce()) {
        writer.attribute("force", "true");
    }
    if (dep.isChanging()) {
        writer.attribute("changing", "true");
    }
    if (!dep.isTransitive()) {
        writer.attribute("transitive", "false");
    }
    writer.attribute("conf", getConfMapping(dep));
    for (IvyArtifactName dependencyArtifact : dep.getArtifacts()) {
        printDependencyArtifact(writer, dependencyArtifact, dep.getModuleConfiguration());
    }
    printDependencyExcludeRules(writer, dep.getExcludes());
    writer.endElement();
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 48 with IvyArtifactName

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

the class DefaultIvyModuleDescriptorWriter method printDependencyExcludeRules.

private static void printDependencyExcludeRules(SimpleXmlWriter writer, Collection<ExcludeMetadata> excludes) throws IOException {
    for (ExcludeMetadata exclude : excludes) {
        writer.startElement("exclude");
        writer.attribute("org", exclude.getModuleId().getGroup());
        writer.attribute("module", exclude.getModuleId().getName());
        IvyArtifactName artifact = exclude.getArtifact();
        if (artifact != null) {
            writer.attribute("name", artifact.getName());
            writer.attribute("type", artifact.getType());
            writer.attribute("ext", artifact.getExtension());
        }
        writer.endElement();
    }
}
Also used : IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 49 with IvyArtifactName

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

the class AbstractRealisedModuleResolveMetadataSerializationHelper method readDependencyMetadata.

protected GradleDependencyMetadata readDependencyMetadata(Decoder decoder) throws IOException {
    ModuleComponentSelector selector = componentSelectorSerializer.read(decoder);
    List<ExcludeMetadata> excludes = readMavenExcludes(decoder);
    boolean constraint = decoder.readBoolean();
    boolean endorsing = decoder.readBoolean();
    boolean force = decoder.readBoolean();
    String reason = decoder.readNullableString();
    IvyArtifactName artifact = readNullableArtifact(decoder);
    return new GradleDependencyMetadata(selector, excludes, constraint, endorsing, reason, force, artifact);
}
Also used : ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 50 with IvyArtifactName

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

the class AbstractRealisedModuleResolveMetadataSerializationHelper method writeFiles.

protected void writeFiles(Encoder encoder, ImmutableList<? extends ComponentArtifactMetadata> artifacts) throws IOException {
    int fileArtifactsCount = (int) artifacts.stream().filter(a -> a instanceof UrlBackedArtifactMetadata).count();
    int ivyArtifactsCount = artifacts.size() - fileArtifactsCount;
    encoder.writeSmallInt(ivyArtifactsCount);
    for (ComponentArtifactMetadata artifact : artifacts) {
        if (!(artifact instanceof UrlBackedArtifactMetadata)) {
            IvyArtifactName artifactName = artifact.getName();
            writeIvyArtifactName(encoder, artifactName);
            ComponentIdentifier componentId = artifact.getComponentId();
            if (componentId instanceof MavenUniqueSnapshotComponentIdentifier) {
                MavenUniqueSnapshotComponentIdentifier uid = (MavenUniqueSnapshotComponentIdentifier) componentId;
                encoder.writeNullableString(uid.getTimestamp());
                encoder.writeString(uid.getVersion());
            } else {
                encoder.writeNullableString(null);
            }
            encoder.writeBoolean(artifact.getAlternativeArtifact().isPresent());
            if (artifact.getAlternativeArtifact().isPresent()) {
                writeIvyArtifactName(encoder, artifact.getAlternativeArtifact().get().getName());
            }
            encoder.writeBoolean(artifact.isOptionalArtifact());
        }
    }
    encoder.writeSmallInt(fileArtifactsCount);
    for (ComponentArtifactMetadata file : artifacts) {
        if (file instanceof UrlBackedArtifactMetadata) {
            encoder.writeString(((UrlBackedArtifactMetadata) file).getFileName());
            encoder.writeString(((UrlBackedArtifactMetadata) file).getRelativeUrl());
        }
    }
}
Also used : ComponentArtifactMetadata(org.gradle.internal.component.model.ComponentArtifactMetadata) MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) MavenUniqueSnapshotComponentIdentifier(org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier)

Aggregations

IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)52 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)28 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)7 ExcludeMetadata (org.gradle.internal.component.model.ExcludeMetadata)7 File (java.io.File)6 Artifact (org.gradle.internal.component.external.descriptor.Artifact)6 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)5 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)5 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 ImmutableList (com.google.common.collect.ImmutableList)4 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)4 ComponentArtifactMetadata (org.gradle.internal.component.model.ComponentArtifactMetadata)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 List (java.util.List)3 Map (java.util.Map)3 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)3 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)3 DefaultResolvedArtifact (org.gradle.api.internal.artifacts.DefaultResolvedArtifact)3 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)3 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)3