Search in sources :

Example 81 with Artifact

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

the class PomModuleDescriptorParserTest method testSimple.

@Test
public void testSimple() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-simple.pom"), false);
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    assertNotNull(md.getConfigurations());
    assertEquals(Arrays.asList(PomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS), Arrays.asList(md.getConfigurations()));
    Artifact[] artifact = md.getArtifacts("master");
    assertEquals(1, artifact.length);
    assertEquals(mrid, artifact[0].getModuleRevisionId());
    assertEquals("test", artifact[0].getName());
    assertEquals("jar", artifact[0].getExt());
    assertEquals("jar", artifact[0].getType());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) Artifact(org.apache.ivy.core.module.descriptor.Artifact) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 82 with Artifact

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

the class PomModuleDescriptorParserTest method testParent2.

@Test
public void testParent2() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-parent2.pom"), false);
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    Artifact[] artifact = md.getArtifacts("master");
    assertEquals(1, artifact.length);
    assertEquals(mrid, artifact[0].getModuleRevisionId());
    assertEquals("test", artifact[0].getName());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) Artifact(org.apache.ivy.core.module.descriptor.Artifact) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 83 with Artifact

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

the class PomModuleDescriptorParserTest method testPropertiesDefinedInProfiles.

/**
 * Tests that the {@code properties} setup in the Maven {@code profiles} that are conditionally activated,
 * become available to the module being parsed and such properties can be used as references within the pom
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1577">IVY-1577</a> for more details
 */
@Test
public void testPropertiesDefinedInProfiles() throws Exception {
    final String[] packagingTypesToTest = new String[] { "bundle", "jar" };
    for (final String expectedPackagingType : packagingTypesToTest) {
        String sysPropToSet = null;
        switch(expectedPackagingType) {
            case "bundle":
                {
                    sysPropToSet = "PomModuleDescriptorParserTest.some-other-test-prop";
                    break;
                }
            case "jar":
                {
                    sysPropToSet = "PomModuleDescriptorParserTest.some-test-prop";
                    break;
                }
            default:
                {
                    fail("Unexpected packaging type");
                }
        }
        // activate the relevant profile, based on a system property
        System.setProperty(sysPropToSet, "foo");
        try {
            // now parse the pom
            final ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-properties-in-profile.pom"), false);
            assertNotNull("Parsed module descriptor was null", md);
            assertEquals("Unexpected module descriptor", ModuleRevisionId.newInstance("org.apache", "test", "5.0.1"), md.getModuleRevisionId());
            final Artifact[] artifacts = md.getAllArtifacts();
            assertNotNull("No artifacts found for module", artifacts);
            assertEquals("Unexpected number of artifacts for module", 1, artifacts.length);
            final Artifact mainArtifact = artifacts[0];
            // make sure that the main artifact which references a conditionally set property (via a Maven profile)
            // is indeed using the right value
            assertEquals("Unexpected artifact type", expectedPackagingType, mainArtifact.getType());
            // some other basic tests
            final DependencyDescriptor[] dds = md.getDependencies();
            assertNotNull(dds);
            assertEquals(1, dds.length);
            assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
        } finally {
            if (sysPropToSet != null) {
                // reset the system prop that we had set
                System.clearProperty(sysPropToSet);
            }
        }
    }
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) Artifact(org.apache.ivy.core.module.descriptor.Artifact) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 84 with Artifact

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

the class PomModuleDescriptorParserTest method testEjbPackaging.

@Test
public void testEjbPackaging() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-ejb-packaging.pom"), false);
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    Artifact[] artifact = md.getArtifacts("master");
    assertEquals(1, artifact.length);
    assertEquals(mrid, artifact[0].getModuleRevisionId());
    assertEquals("test", artifact[0].getName());
    assertEquals("jar", artifact[0].getExt());
    assertEquals("ejb", artifact[0].getType());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) Artifact(org.apache.ivy.core.module.descriptor.Artifact) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 85 with Artifact

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

the class PomModuleDescriptorParserTest method testParentVersion.

@Test
public void testParentVersion() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-parent.version.pom"), false);
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    Artifact[] artifact = md.getArtifacts("master");
    assertEquals(1, artifact.length);
    assertEquals(mrid, artifact[0].getModuleRevisionId());
    assertEquals("test", artifact[0].getName());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) Artifact(org.apache.ivy.core.module.descriptor.Artifact) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

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