Search in sources :

Example 1 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 2 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 3 with PublishArtifact

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

the class IdeaPlugin method createImlArtifact.

private static LocalComponentArtifactMetadata createImlArtifact(ProjectComponentIdentifier projectId, Project project) {
    String moduleName = project.getExtensions().getByType(IdeaModel.class).getModule().getName();
    File imlFile = new File(project.getProjectDir(), moduleName + ".iml");
    Task byName = project.getTasks().getByName("ideaModule");
    PublishArtifact publishArtifact = new DefaultPublishArtifact(moduleName, "iml", "iml", null, null, imlFile, 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 4 with PublishArtifact

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

the class DefaultArtifactPom method addArtifact.

public void addArtifact(Artifact artifact, File src) {
    throwExceptionIfArtifactOrSrcIsNull(artifact, src);
    PublishArtifact publishArtifact = new MavenArtifact(artifact, src);
    ArtifactKey artifactKey = new ArtifactKey(publishArtifact);
    if (this.artifacts.containsKey(artifactKey)) {
        throw new InvalidUserDataException(String.format("A POM cannot have multiple artifacts with the same type and classifier. Already have %s, trying to add %s.", this.artifacts.get(artifactKey), publishArtifact));
    }
    if (publishArtifact.getClassifier() != null) {
        addArtifact(publishArtifact);
        assignArtifactValuesToPom(artifact, pom, false);
        return;
    }
    if (this.artifact != null) {
        // Choose the 'main' artifact based on its type.
        if (!PACKAGING_TYPES.contains(artifact.getType())) {
            addArtifact(publishArtifact);
            return;
        }
        if (PACKAGING_TYPES.contains(this.artifact.getType())) {
            throw new InvalidUserDataException("A POM can not have multiple main artifacts. " + "Already have " + this.artifact + ", trying to add " + publishArtifact);
        }
        addArtifact(this.artifact);
    }
    this.artifact = publishArtifact;
    this.artifacts.put(artifactKey, publishArtifact);
    assignArtifactValuesToPom(artifact, pom, true);
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) AbstractPublishArtifact(org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact)

Example 5 with PublishArtifact

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

the class DefaultArtifactPomContainer method createDeployableFilesInfos.

public Set<MavenDeployment> createDeployableFilesInfos() {
    Set<MavenDeployment> mavenDeployments = new HashSet<MavenDeployment>();
    for (String activeArtifactPomName : artifactPoms.keySet()) {
        ArtifactPom activeArtifactPom = artifactPoms.get(activeArtifactPomName);
        File pomFile = createPomFile(activeArtifactPomName);
        PublishArtifact pomArtifact = activeArtifactPom.writePom(pomFile);
        mavenDeployments.add(new DefaultMavenDeployment(pomArtifact, activeArtifactPom.getArtifact(), activeArtifactPom.getAttachedArtifacts()));
    }
    return mavenDeployments;
}
Also used : MavenDeployment(org.gradle.api.artifacts.maven.MavenDeployment) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

PublishArtifact (org.gradle.api.artifacts.PublishArtifact)30 File (java.io.File)9 DefaultPublishArtifact (org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact)5 Configuration (org.gradle.api.artifacts.Configuration)4 UsageContext (org.gradle.api.internal.component.UsageContext)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 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)3 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)3 LazyPublishArtifact (org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact)3 DefaultArtifactPublicationSet (org.gradle.api.internal.plugins.DefaultArtifactPublicationSet)3 Test (org.junit.Test)3 ImmutableList (com.google.common.collect.ImmutableList)2 EnumMap (java.util.EnumMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Task (org.gradle.api.Task)2 Dependency (org.gradle.api.artifacts.Dependency)2 DependencyConstraint (org.gradle.api.artifacts.DependencyConstraint)2