Search in sources :

Example 1 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project gradle by gradle.

the class DefaultArtifactPomTest method initWithCustomPomSettings.

@Test
public void initWithCustomPomSettings() {
    Artifact mainArtifact = createTestArtifact("someName", null, "mainPackaging");
    File mainFile = new File("someFile");
    testPom.setArtifactId("customArtifactId");
    testPom.setGroupId("customGroupId");
    testPom.setVersion("customVersion");
    testPom.setPackaging("customPackaging");
    artifactPom.addArtifact(mainArtifact, mainFile);
    assertThat(artifactPom.getArtifact().getName(), equalTo("customArtifactId"));
    assertThat(artifactPom.getArtifact().getExtension(), equalTo("mainPackaging"));
    assertThat(artifactPom.getArtifact().getType(), equalTo("mainPackaging"));
    assertThat(artifactPom.getArtifact().getClassifier(), nullValue());
    assertThat(artifactPom.getArtifact().getFile(), equalTo(mainFile));
    assertThat(artifactPom.getPom().getGroupId(), equalTo("customGroupId"));
    assertThat(artifactPom.getPom().getArtifactId(), equalTo("customArtifactId"));
    assertThat(artifactPom.getPom().getVersion(), equalTo("customVersion"));
    assertThat(artifactPom.getPom().getPackaging(), equalTo("mainPackaging"));
}
Also used : File(java.io.File) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 2 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project gradle by gradle.

the class DefaultArtifactPomTest method pomWithMainArtifact.

@Test
public void pomWithMainArtifact() {
    Artifact mainArtifact = createTestArtifact("someName", null, "mainPackaging");
    File mainFile = new File("someFile");
    artifactPom.addArtifact(mainArtifact, mainFile);
    assertThat(artifactPom.getArtifact().getName(), equalTo("someName"));
    assertThat(artifactPom.getArtifact().getExtension(), equalTo("mainPackaging"));
    assertThat(artifactPom.getArtifact().getType(), equalTo("mainPackaging"));
    assertThat(artifactPom.getArtifact().getClassifier(), nullValue());
    assertThat(artifactPom.getArtifact().getFile(), equalTo(mainFile));
    assertThat(artifactPom.getPom().getGroupId(), equalTo("org"));
    assertThat(artifactPom.getPom().getArtifactId(), equalTo("someName"));
    assertThat(artifactPom.getPom().getVersion(), equalTo("1.0"));
    assertThat(artifactPom.getPom().getPackaging(), equalTo("mainPackaging"));
}
Also used : File(java.io.File) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 3 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project gradle by gradle.

the class DefaultArtifactPomTest method pomWithMainArtifactAndClassifierArtifacts.

@Test
public void pomWithMainArtifactAndClassifierArtifacts() {
    Artifact mainArtifact = createTestArtifact("someName", null, "mainPackaging");
    File mainFile = new File("someFile");
    Artifact classifierArtifact = createTestArtifact("otherName", "javadoc", "zip");
    File classifierFile = new File("someClassifierFile");
    artifactPom.addArtifact(mainArtifact, mainFile);
    artifactPom.addArtifact(classifierArtifact, classifierFile);
    assertThat(artifactPom.getArtifact().getName(), equalTo("someName"));
    assertThat(artifactPom.getArtifact().getExtension(), equalTo("mainPackaging"));
    assertThat(artifactPom.getArtifact().getType(), equalTo("mainPackaging"));
    assertThat(artifactPom.getArtifact().getClassifier(), nullValue());
    assertThat(artifactPom.getArtifact().getFile(), equalTo(mainFile));
    PublishArtifact artifact = singleItem(artifactPom.getAttachedArtifacts());
    assertThat(artifact.getName(), equalTo("someName"));
    assertThat(artifact.getExtension(), equalTo("zip"));
    assertThat(artifact.getType(), equalTo("zip"));
    assertThat(artifact.getClassifier(), equalTo("javadoc"));
    assertThat(artifact.getFile(), equalTo(classifierFile));
    assertThat(artifactPom.getPom().getGroupId(), equalTo("org"));
    assertThat(artifactPom.getPom().getArtifactId(), equalTo("someName"));
    assertThat(artifactPom.getPom().getVersion(), equalTo("1.0"));
    assertThat(artifactPom.getPom().getPackaging(), equalTo("mainPackaging"));
}
Also used : PublishArtifact(org.gradle.api.artifacts.PublishArtifact) File(java.io.File) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 4 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project gradle by gradle.

the class DefaultArtifactPomTest method addClassifierTwiceShouldThrowInvalidUserDataEx.

@Test(expected = InvalidUserDataException.class)
public void addClassifierTwiceShouldThrowInvalidUserDataEx() {
    File classifierFile = new File("someClassifierFile");
    Artifact classifierArtifact = createTestArtifact("someName", "javadoc");
    artifactPom.addArtifact(classifierArtifact, classifierFile);
    artifactPom.addArtifact(classifierArtifact, classifierFile);
}
Also used : File(java.io.File) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 5 with Artifact

use of org.apache.ivy.core.module.descriptor.Artifact in project gradle by gradle.

the class AbstractMavenResolver method publish.

public void publish(IvyModulePublishMetadata moduleVersion) {
    for (IvyModuleArtifactPublishMetadata artifactMetadata : moduleVersion.getArtifacts()) {
        IvyArtifactName artifact = artifactMetadata.getArtifactName();
        ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(artifactMetadata.getId().getComponentIdentifier());
        Map<String, String> attributes = Collections.singletonMap("classifier", artifact.getClassifier());
        Artifact ivyArtifact = new DefaultArtifact(moduleRevisionId, null, artifact.getName(), artifact.getType(), artifact.getExtension(), attributes);
        collectArtifact(ivyArtifact, artifactMetadata.getFile());
    }
    publish();
}
Also used : IvyModuleArtifactPublishMetadata(org.gradle.internal.component.external.ivypublish.IvyModuleArtifactPublishMetadata) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact)

Aggregations

Artifact (org.apache.ivy.core.module.descriptor.Artifact)106 Test (org.junit.Test)68 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)59 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)55 File (java.io.File)53 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)31 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)30 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)28 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)25 Date (java.util.Date)22 DownloadReport (org.apache.ivy.core.report.DownloadReport)20 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)15 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)13 Configuration (org.apache.ivy.core.module.descriptor.Configuration)10 IOException (java.io.IOException)9 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)9 ParseException (java.text.ParseException)8 XmlModuleDescriptorParserTest (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest)8 ResolveReport (org.apache.ivy.core.report.ResolveReport)7 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)7