Search in sources :

Example 6 with Artifact

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

the class DefaultArtifactPomTest method cannotAddMultipleArtifactsWithTheSameTypeAndClassifier.

@Test
public void cannotAddMultipleArtifactsWithTheSameTypeAndClassifier() {
    // No classifier
    Artifact mainArtifact = createTestArtifact("someName", null);
    artifactPom.addArtifact(mainArtifact, new File("someFile"));
    assertIsDuplicate(mainArtifact, new File("someFile"));
    assertIsDuplicate(mainArtifact, new File("otherFile"));
    assertIsDuplicate(createTestArtifact("otherName", null), new File("otherFile"));
    // Classifier
    Artifact classifierArtifact = createTestArtifact("someName", "classifier");
    artifactPom.addArtifact(classifierArtifact, new File("classifierFile"));
    assertIsDuplicate(classifierArtifact, new File("someFile"));
    assertIsDuplicate(classifierArtifact, new File("otherFile"));
    assertIsDuplicate(createTestArtifact("otherName", "classifier"), new File("otherFile"));
}
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 7 with Artifact

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

the class DefaultArtifactPomTest method pomWithMainArtifactAndMetadataArtifacts.

@Test
public void pomWithMainArtifactAndMetadataArtifacts() {
    Artifact mainArtifact = createTestArtifact("someName", null, "mainPackaging");
    File mainFile = new File("someFile");
    File metadataFile = new File("someMetadataFile");
    Artifact metadataArtifact = createTestArtifact("otherName", null, "sometype");
    artifactPom.addArtifact(mainArtifact, mainFile);
    artifactPom.addArtifact(metadataArtifact, metadataFile);
    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("sometype"));
    assertThat(artifact.getType(), equalTo("sometype"));
    assertThat(artifact.getClassifier(), nullValue());
    assertThat(artifact.getFile(), equalTo(metadataFile));
    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 8 with Artifact

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

the class DefaultArtifactPomTest method addMainArtifactTwiceShouldThrowInvalidUserDataEx.

@Test(expected = InvalidUserDataException.class)
public void addMainArtifactTwiceShouldThrowInvalidUserDataEx() {
    Artifact mainArtifact = createTestArtifact("someName", null, "mainPackaging");
    File mainFile = new File("someFile");
    artifactPom.addArtifact(mainArtifact, mainFile);
    artifactPom.addArtifact(mainArtifact, mainFile);
}
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 9 with Artifact

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

the class DefaultArtifactPomTest method pomWithClassifierArtifactsOnly.

@Test
public void pomWithClassifierArtifactsOnly() {
    File classifierFile = new File("someClassifierFile");
    Artifact classifierArtifact = createTestArtifact("someName", "javadoc", "zip");
    artifactPom.addArtifact(classifierArtifact, classifierFile);
    assertThat(artifactPom.getArtifact(), nullValue());
    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("jar"));
}
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)

Aggregations

Artifact (org.apache.ivy.core.module.descriptor.Artifact)9 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)9 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)9 File (java.io.File)8 Test (org.junit.Test)8 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)1 IvyModuleArtifactPublishMetadata (org.gradle.internal.component.external.ivypublish.IvyModuleArtifactPublishMetadata)1 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)1