Search in sources :

Example 6 with PublishArtifact

use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.

the class EclipsePlugin method createArtifact.

private static LocalComponentArtifactMetadata createArtifact(String extension, ProjectComponentIdentifier projectId, String projectName, Project project) {
    File projectFile = new File(project.getProjectDir(), "." + extension);
    Task byName = project.getTasks().getByName("eclipseProject");
    String type = "eclipse." + extension;
    PublishArtifact publishArtifact = new DefaultPublishArtifact(projectName, extension, type, null, null, projectFile, byName);
    return new PublishArtifactLocalArtifactMetadata(projectId, publishArtifact);
}
Also used : Task(org.gradle.api.Task) DefaultPublishArtifact(org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact) PublishArtifactLocalArtifactMetadata(org.gradle.internal.component.local.model.PublishArtifactLocalArtifactMetadata) DefaultPublishArtifact(org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) File(java.io.File)

Example 7 with PublishArtifact

use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.

the class JvmLocalLibraryMetaDataAdapter method createResolvedMetaData.

private DefaultLibraryLocalComponentMetadata createResolvedMetaData(BinarySpecInternal selectedBinary, String projectPath, EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage, EnumMap<UsageKind, List<PublishArtifact>> artifacts) {
    DefaultLibraryLocalComponentMetadata metadata = newResolvedLibraryMetadata(selectedBinary.getId(), toStringMap(dependenciesPerUsage), projectPath);
    for (Map.Entry<UsageKind, List<PublishArtifact>> entry : artifacts.entrySet()) {
        UsageKind usage = entry.getKey();
        final List<PublishArtifact> publishArtifacts = entry.getValue();
        metadata.addArtifacts(usage.getConfigurationName(), publishArtifacts);
        metadata.addVariant(usage.getConfigurationName(), new OutgoingVariant() {

            @Override
            public AttributeContainerInternal getAttributes() {
                return ImmutableAttributes.EMPTY;
            }

            @Override
            public Set<? extends PublishArtifact> getArtifacts() {
                return new LinkedHashSet<PublishArtifact>(publishArtifacts);
            }

            @Override
            public Set<? extends OutgoingVariant> getChildren() {
                return ImmutableSet.of();
            }
        });
    }
    return metadata;
}
Also used : OutgoingVariant(org.gradle.api.internal.artifacts.configurations.OutgoingVariant) LinkedHashSet(java.util.LinkedHashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DefaultLibraryLocalComponentMetadata(org.gradle.language.base.internal.model.DefaultLibraryLocalComponentMetadata) LinkedList(java.util.LinkedList) List(java.util.List) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) DefaultPublishArtifact(org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact) HashMap(java.util.HashMap) Map(java.util.Map) EnumMap(java.util.EnumMap) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal)

Example 8 with PublishArtifact

use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.

the class JvmLocalLibraryMetaDataAdapter method createLocalComponentMetaData.

@Override
@SuppressWarnings("unchecked")
public DefaultLibraryLocalComponentMetadata createLocalComponentMetaData(Binary selectedBinary, String projectPath, boolean toAssembly) {
    EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage = new EnumMap<UsageKind, Iterable<DependencySpec>>(UsageKind.class);
    EnumMap<UsageKind, List<PublishArtifact>> artifacts = new EnumMap<UsageKind, List<PublishArtifact>>(UsageKind.class);
    initializeUsages(dependenciesPerUsage, artifacts);
    if (selectedBinary instanceof JarBinarySpecInternal) {
        JarBinarySpecInternal jarBinarySpec = (JarBinarySpecInternal) selectedBinary;
        createJarBinarySpecLocalComponentMetaData(artifacts, jarBinarySpec, dependenciesPerUsage, toAssembly);
    }
    if (selectedBinary instanceof WithJvmAssembly) {
        // a local component that provides a JVM assembly
        JvmAssembly assembly = ((WithJvmAssembly) selectedBinary).getAssembly();
        createJvmAssemblyLocalComponentMetaData(artifacts, assembly, dependenciesPerUsage, toAssembly);
    }
    return createResolvedMetaData((BinarySpecInternal) selectedBinary, projectPath, dependenciesPerUsage, artifacts);
}
Also used : JarBinarySpecInternal(org.gradle.jvm.internal.JarBinarySpecInternal) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) JvmAssembly(org.gradle.jvm.internal.JvmAssembly) DependencySpec(org.gradle.platform.base.DependencySpec) LinkedList(java.util.LinkedList) List(java.util.List) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) DefaultPublishArtifact(org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact) EnumMap(java.util.EnumMap)

Example 9 with PublishArtifact

use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.

the class DefaultConfiguration method dump.

/**
     * Print a formatted representation of a Configuration
     */
public String dump() {
    StringBuilder reply = new StringBuilder();
    reply.append("\nConfiguration:");
    reply.append("  class='" + this.getClass() + "'");
    reply.append("  name='" + this.getName() + "'");
    reply.append("  hashcode='" + this.hashCode() + "'");
    reply.append("\nLocal Dependencies:");
    if (getDependencies().size() > 0) {
        for (Dependency d : getDependencies()) {
            reply.append("\n   " + d);
        }
    } else {
        reply.append("\n   none");
    }
    reply.append("\nLocal Artifacts:");
    if (getArtifacts().size() > 0) {
        for (PublishArtifact a : getArtifacts()) {
            reply.append("\n   " + a);
        }
    } else {
        reply.append("\n   none");
    }
    reply.append("\nAll Dependencies:");
    if (getAllDependencies().size() > 0) {
        for (Dependency d : getAllDependencies()) {
            reply.append("\n   " + d);
        }
    } else {
        reply.append("\n   none");
    }
    reply.append("\nAll Artifacts:");
    if (getAllArtifacts().size() > 0) {
        for (PublishArtifact a : getAllArtifacts()) {
            reply.append("\n   " + a);
        }
    } else {
        reply.append("\n   none");
    }
    return reply.toString();
}
Also used : TaskDependency(org.gradle.api.tasks.TaskDependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) AbstractTaskDependency(org.gradle.api.internal.tasks.AbstractTaskDependency) Dependency(org.gradle.api.artifacts.Dependency) ConfigurablePublishArtifact(org.gradle.api.artifacts.ConfigurablePublishArtifact) PublishArtifact(org.gradle.api.artifacts.PublishArtifact)

Example 10 with PublishArtifact

use of org.gradle.api.artifacts.PublishArtifact in project gradle by gradle.

the class Sign method sign.

/**
     * Configures the task to sign every artifact of the given configurations
     */
public void sign(Configuration... configurations) {
    for (Configuration configuration : configurations) {
        configuration.getAllArtifacts().all(new Action<PublishArtifact>() {

            @Override
            public void execute(PublishArtifact artifact) {
                if (artifact instanceof Signature) {
                    return;
                }
                signArtifact(artifact);
            }
        });
        configuration.getAllArtifacts().whenObjectRemoved(new Action<PublishArtifact>() {

            @Override
            public void execute(final PublishArtifact publishArtifact) {
                signatures.remove(Iterables.find(signatures, new Predicate<Signature>() {

                    @Override
                    public boolean apply(Signature input) {
                        return input.getToSignArtifact().equals(publishArtifact);
                    }
                }));
            }
        });
    }
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) PublishArtifact(org.gradle.api.artifacts.PublishArtifact)

Aggregations

PublishArtifact (org.gradle.api.artifacts.PublishArtifact)20 File (java.io.File)8 DefaultPublishArtifact (org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact)5 Test (org.junit.Test)4 Artifact (org.apache.ivy.core.module.descriptor.Artifact)3 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)3 InvalidUserDataException (org.gradle.api.InvalidUserDataException)3 Configuration (org.gradle.api.artifacts.Configuration)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 EnumMap (java.util.EnumMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Task (org.gradle.api.Task)2 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)2 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)2 UsageContext (org.gradle.api.internal.component.UsageContext)2 PublishArtifactLocalArtifactMetadata (org.gradle.internal.component.local.model.PublishArtifactLocalArtifactMetadata)2 FileOutputStream (java.io.FileOutputStream)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1