org.apache.ivy.core.report.ResolveReport Java Examples

The following examples show how to use org.apache.ivy.core.report.ResolveReport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testLatestTime2() throws Exception {
    ivy = new Ivy();
    ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time.xml"));
    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);

    // set timestamps, because svn is not preserving this information,
    // and the latest time strategy is relying on it
    long time = System.currentTimeMillis() - 10000;
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").setLastModified(time);
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.2.jar")
            .setLastModified(time + 2000);

    ResolveReport report = ivy.resolve(
        LatestConflictManagerTest.class.getResource("ivy-latest-time-2.xml"),
        getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        if (mrid.getName().equals("mod1.1")) {
            assertEquals("1.0", mrid.getRevision());
        } else if (mrid.getName().equals("mod1.2")) {
            assertEquals("2.2", mrid.getRevision());
        }
    }
}
 
Example #2
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveWithVariable() throws Exception {
    // mod1.1 depends on mod1.2
    ivy.setVariable("retrieve.dir", "retrieve");
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/${retrieve.dir}/[module]/[conf]/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    pattern = IvyPatternHelper.substituteVariable(pattern, "retrieve.dir", "retrieve");
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
        "jar", "jar", "default")).exists());

    pattern = "build/test/${retrieve.dir}/[module]/[conf]/[type]s/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    pattern = IvyPatternHelper.substituteVariable(pattern, "retrieve.dir", "retrieve");
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
        "jar", "jar", "default")).exists());
}
 
Example #3
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveSimple() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
        "jar", "jar", "default")).exists());

    pattern = "build/test/retrieve/[module]/[conf]/[type]s/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
        "jar", "jar", "default")).exists());
}
 
Example #4
Source File: XmlReportWriterTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testEscapeXml() throws Exception {
    ivy.configure(new File("test/repositories/IVY-635/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File(
            "test/java/org/apache/ivy/plugins/report/ivy-635.xml"),
        getResolveOptions(new String[] {"default"}));
    assertNotNull(report);

    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    XmlReportWriter writer = new XmlReportWriter();
    writer.output(report.getConfigurationReport("default"), buffer);
    buffer.flush();
    String xml = buffer.toString();

    String expectedArtName = "art1&_.txt";

    assertTrue("XML doesn't contain escaped artifact name", xml.contains(expectedArtName));
}
 
Example #5
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveOverwrite() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";

    // we create a fake old file to see if it is overwritten
    File file = new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0",
        "mod1.2", "jar", "jar", "default")).getCanonicalFile();
    file.getParentFile().mkdirs();
    file.createNewFile();
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setOverwriteMode("always").setDestArtifactPattern(pattern));
    assertEquals(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").lastModified(),
        file.lastModified());
}
 
Example #6
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveSameFileConflict() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.4/ivys/ivy-1.0.1.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[artifact]-[revision].[ext]";
    MockMessageLogger mockLogger = new MockMessageLogger();
    Message.setDefaultLogger(mockLogger);
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.2", "mod1.2",
        "jar", "jar", "default")).exists());
    mockLogger.assertLogDoesntContain("conflict on");
}
 
Example #7
Source File: IvyDependencyUpdateChecker.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void displayMissingDependencyOnLatest(ResolveReport originalReport,
        ResolveReport latestReport) {
    List<ModuleRevisionId> listOfMissingDependencyOnLatest = new ArrayList<>();
    for (IvyNode originalDependency : originalReport.getDependencies()) {
        boolean dependencyFound = false;
        for (IvyNode latest : latestReport.getDependencies()) {
            if (originalDependency.getModuleId().equals(latest.getModuleId())) {
                dependencyFound = true;
            }
        }
        if (!dependencyFound) {
            listOfMissingDependencyOnLatest.add(originalDependency.getId());
        }
    }

    if (listOfMissingDependencyOnLatest.size() > 0) {
        log("List of missing dependency on latest resolve :");
        for (ModuleRevisionId moduleRevisionId : listOfMissingDependencyOnLatest) {
            log("\t" + moduleRevisionId.toString());
        }
    }
}
 
Example #8
Source File: IvyDependencyUpdateChecker.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void displayNewDependencyOnLatest(ResolveReport originalReport,
        ResolveReport latestReport) {
    List<ModuleRevisionId> listOfNewDependencyOnLatest = new ArrayList<>();
    for (IvyNode latest : latestReport.getDependencies()) {
        boolean dependencyFound = false;
        for (IvyNode originalDependency : originalReport.getDependencies()) {
            if (originalDependency.getModuleId().equals(latest.getModuleId())) {
                dependencyFound = true;
            }
        }
        if (!dependencyFound) {
            listOfNewDependencyOnLatest.add(latest.getId());
        }
    }
    if (listOfNewDependencyOnLatest.size() > 0) {
        log("List of new dependency on latest resolve :");
        for (ModuleRevisionId moduleRevisionId : listOfNewDependencyOnLatest) {
            log("\t" + moduleRevisionId.toString());
        }
    }
}
 
Example #9
Source File: InstallTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testMaven() throws Exception {
    Ivy ivy = Ivy.newInstance();
    ivy.configure(new File("test/repositories/ivysettings.xml"));

    @SuppressWarnings("unused")
    ResolveReport rr = ivy.install(ModuleRevisionId.newInstance("org.apache", "test", "1.0"),
        ivy.getSettings().getDefaultResolver().getName(), "install", new InstallOptions());

    assertTrue(new File("build/test/install/org.apache/test/ivy-1.0.xml").exists());
    assertTrue(new File("build/test/install/org.apache/test/test-1.0.jar").exists());

    // the original descriptor is not installed
    assertFalse(new File("build/test/install/org.apache/test/test-1.0.pom").exists());

    ivy.install(ModuleRevisionId.newInstance("org.apache", "test", "1.0"), ivy.getSettings()
            .getDefaultResolver().getName(), "install", new InstallOptions()
            .setInstallOriginalMetadata(true).setOverwrite(true));

    // the original descriptor is installed now, too
    assertTrue(new File("build/test/install/org.apache/test/test-1.0.pom").exists());
}
 
Example #10
Source File: Main.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private static ResolveReport run(String[] args, boolean isCli) throws Exception {
    CommandLineParser parser = getParser();

    // parse the command line arguments
    CommandLine line;
    try {
        line = parser.parse(args);
    } catch (ParseException pe) {
        // display usage and and rethrow
        usage(parser, false);
        throw new ParseException(pe.getMessage());
    }

    if (line.hasOption("?")) {
        usage(parser, line.hasOption("deprecated"));
        return null;
    }

    return run(line, isCli);
}
 
Example #11
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * This test is here to just test the deprecated {@code symlinkmass} option for retrieve task.
 * A version or two down the line, after 2.5 release, we can remove this test and the option
 * altogether.
 *
 * @throws Exception if something goes wrong
 */
@SuppressWarnings("deprecation")
@Test
public void testRetrieveWithSymlinksMass() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setMakeSymlinksInMass(true).setDestArtifactPattern(pattern));
    assertLinkOrExists(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar",
        "jar", "default"));

    pattern = "build/test/retrieve/[module]/[conf]/[type]s/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setMakeSymlinksInMass(true).setDestArtifactPattern(pattern));
    assertLinkOrExists(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar",
        "jar", "default"));
}
 
Example #12
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Test case for IVY-388.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-388">IVY-388</a>
 */
@Test
public void testIvy388() throws Exception {
    ResolveReport report = ivy.resolve(
        LatestConflictManagerTest.class.getResource("ivy-388.xml"), getResolveOptions());

    List<IvyNode> deps = report.getDependencies();
    Iterator<IvyNode> dependencies = deps.iterator();
    String[] confs = report.getConfigurations();
    while (dependencies.hasNext()) {
        IvyNode node = dependencies.next();
        for (String conf : confs) {
            if (!node.isEvicted(conf)) {
                boolean flag1 = report.getConfigurationReport(conf).getDependency(
                    node.getResolvedId()) != null;
                boolean flag2 = report.getConfigurationReport(conf).getModuleRevisionIds()
                        .contains(node.getResolvedId());
                assertEquals("Inconsistent data for node " + node + " in conf " + conf, flag1,
                    flag2);
            }
        }
    }
}
 
Example #13
Source File: AntBuildResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testProject() throws Exception {
    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setFile(new File("test/workspace/project2/ivy.xml"));
    resolve.setKeep(true);
    resolve.execute();

    ResolveReport report = project.getReference("ivy.resolved.report");
    assertEquals(2, report.getDependencies().size());
    assertEquals(MRID_PROJECT1, report.getDependencies().get(0).getResolvedId());
    assertEquals(MRID_MODULE1, report.getDependencies().get(1).getResolvedId());
    assertEquals(1, report.getArtifactsReports(MRID_PROJECT1).length);
    assertEquals(DownloadStatus.NO,
        report.getArtifactsReports(MRID_PROJECT1)[0].getDownloadStatus());
    assertEquals(new File("test/workspace/project1/target/dist/jars/project1.jar").toURI()
            .toURL(), report.getArtifactsReports(MRID_PROJECT1)[0].getArtifact().getUrl());
    assertEquals(
        new File("test/workspace/project1/target/dist/jars/project1.jar").getAbsoluteFile(),
        report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile());
}
 
Example #14
Source File: AntBuildResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testProjectFolder() throws Exception {
    wa.setPath("target/classes");

    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setFile(new File("test/workspace/project2/ivy.xml"));
    resolve.setKeep(true);
    resolve.execute();

    ResolveReport report = project.getReference("ivy.resolved.report");
    assertEquals(2, report.getDependencies().size());
    assertEquals(MRID_PROJECT1, report.getDependencies().get(0).getResolvedId());
    assertEquals(MRID_MODULE1, report.getDependencies().get(1).getResolvedId());
    assertEquals(1, report.getArtifactsReports(MRID_PROJECT1).length);
    assertEquals(DownloadStatus.NO,
        report.getArtifactsReports(MRID_PROJECT1)[0].getDownloadStatus());
    assertEquals(new File("test/workspace/project1/target/classes").toURI().toURL(),
        report.getArtifactsReports(MRID_PROJECT1)[0].getArtifact().getUrl());
    assertEquals(new File("test/workspace/project1/target/classes").getAbsoluteFile(),
        report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile());
}
 
Example #15
Source File: AntBuildResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testDependencyArtifact() throws Exception {
    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setFile(new File("test/workspace/project3/ivy.xml"));
    resolve.setKeep(true);
    resolve.execute();

    ResolveReport report = project.getReference("ivy.resolved.report");
    assertEquals(2, report.getDependencies().size());
    assertEquals(MRID_PROJECT1, report.getDependencies().get(0).getResolvedId());
    assertEquals(MRID_MODULE1, report.getDependencies().get(1).getResolvedId());
    assertEquals(1, report.getArtifactsReports(MRID_PROJECT1).length);
    assertEquals(DownloadStatus.NO,
        report.getArtifactsReports(MRID_PROJECT1)[0].getDownloadStatus());
    assertEquals(new File("test/workspace/project1/target/dist/jars/project1.jar").toURI()
            .toURL(), report.getArtifactsReports(MRID_PROJECT1)[0].getArtifact().getUrl());
    assertEquals(
        new File("test/workspace/project1/target/dist/jars/project1.jar").getAbsoluteFile(),
        report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile());
}
 
Example #16
Source File: IvyPostResolveTaskTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithPreviousResolveInSameBuildAndLessConfs() {
    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml"));
    resolve.setConf("default,compile");
    resolve.execute();

    ResolveReport reportBefore = project.getReference("ivy.resolved.report");

    task.setConf("default");
    task.execute();

    ResolveReport reportAfter = project.getReference("ivy.resolved.report");

    assertSame("IvyPostResolveTask has performed a resolve where it shouldn't", reportBefore,
        reportAfter);
}
 
Example #17
Source File: IvyPostResolveTaskTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithPreviousResolveInSameBuildAndSameConfs() {
    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml"));
    resolve.setConf("default");
    resolve.execute();

    ResolveReport reportBefore = project.getReference("ivy.resolved.report");

    task.setConf("default");
    task.execute();

    ResolveReport reportAfter = project.getReference("ivy.resolved.report");

    assertSame("IvyPostResolveTask has performed a resolve where it shouldn't", reportBefore,
        reportAfter);
}
 
Example #18
Source File: IvyPostResolveTaskTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithPreviousResolveInSameBuildAndWildcard() {
    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml"));
    resolve.setConf("*");
    resolve.execute();

    ResolveReport reportBefore = project.getReference("ivy.resolved.report");

    task.setConf("default");
    task.execute();

    ResolveReport reportAfter = project.getReference("ivy.resolved.report");

    assertSame("IvyPostResolveTask has performed a resolve where it shouldn't", reportBefore,
        reportAfter);
}
 
Example #19
Source File: IvyPostResolveTaskTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithPreviousResolveInSameBuildAndMoreConfs() {
    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml"));
    resolve.setConf("compile");
    resolve.execute();

    ResolveReport reportBefore = project.getReference("ivy.resolved.report");
    assertTrue(getArchiveFileInCache("org1", "mod1.1", "2.0", "mod1.1", "jar", "jar").exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());

    task.setConf("*");
    task.execute();

    ResolveReport reportAfter = project.getReference("ivy.resolved.report");

    assertNotSame("IvyPostResolveTask hasn't performed a resolve where it should have",
        reportBefore, reportAfter);
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
 
Example #20
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveWithSymlinks() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setMakeSymlinks(true).setDestArtifactPattern(pattern));
    assertLinkOrExists(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar",
        "jar", "default"));

    pattern = "build/test/retrieve/[module]/[conf]/[type]s/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setMakeSymlinks(true).setDestArtifactPattern(pattern));
    assertLinkOrExists(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2", "jar",
        "jar", "default"));
}
 
Example #21
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that retrieve, when invoked with "symlink" enabled, creates the necessary symlink
 * when the artifact being retrieved is a directory instead of a regular file
 *
 * @throws Exception
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1594">IVY-1594</a>
 */
@Test
public void testRetrieveZipArtifactWithSymlinks() throws Exception {
    // resolve (inline) with org1:mod1.1:3.0 as a dependency
    final ResolveReport report = ivy.resolve(new ModuleRevisionId(new ModuleId("org1", "mod1.7"), "3.0"),
            getResolveOptions(new String[]{"*"}), false);
    assertNotNull("Resolution report is null", report);
    final ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull("Module descriptor is null", md);

    final String retrievePattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision]";
    ivy.retrieve(md.getModuleRevisionId(),
            getRetrieveOptions().setMakeSymlinks(true).setDestArtifactPattern(retrievePattern));

    final String expectedRetrieveLocation = IvyPatternHelper.substitute(retrievePattern, "org1", "mod1.7",
            "3.0", "zipped-artifact", null, null, "default");
    // make sure it's retrieved as a symlink (on systems that support symlink)
    assertLinkOrExists(expectedRetrieveLocation);
}
 
Example #22
Source File: IvyPostResolveTaskTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testInlineWithKeep() {
    task.setOrganisation("org1");
    task.setModule("mod1.1");
    task.setRevision("2.0");
    task.setInline(true);
    task.setKeep(true);
    task.setConf("*"); // will trigger a resolve
    task.execute();

    ResolveReport reportAfter = project.getReference("ivy.resolved.report");

    assertNotNull("IvyPostResolveTask has kept the resolve report where it should have",
        reportAfter);
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists());
}
 
Example #23
Source File: XmlReportParserTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetResolvedModule() throws Exception {
    ResolveReport report = ivy.resolve(
        new File("test/java/org/apache/ivy/plugins/report/ivy-with-info.xml"),
        getResolveOptions(new String[] {"default"}).setValidate(false).setResolveId(
            "testGetResolvedModule"));
    assertNotNull(report);

    ModuleRevisionId modRevId = report.getModuleDescriptor().getModuleRevisionId();

    XmlReportParser parser = new XmlReportParser();
    parser.parse(ivy.getResolutionCacheManager().getConfigurationResolveReportInCache(
        "testGetResolvedModule", "default"));
    ModuleRevisionId parsedModRevId = parser.getResolvedModule();

    assertEquals("Resolved module doesn't equals parsed module", modRevId, parsedModRevId);
}
 
Example #24
Source File: XmlReportWriterTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteModuleInfo() throws Exception {
    ResolveReport report = ivy.resolve(new File(
            "test/java/org/apache/ivy/plugins/report/ivy-with-info.xml"),
        getResolveOptions(new String[] {"default"}).setValidate(false));
    assertNotNull(report);

    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    XmlReportWriter writer = new XmlReportWriter();
    writer.output(report.getConfigurationReport("default"), buffer);
    buffer.flush();
    String xml = buffer.toString();

    String orgAttribute = "organisation=\"org1\"";
    String modAttribute = "module=\"mod1\"";
    String revAttribute = "revision=\"1.0\"";
    String extra1Attribute = "extra-0.blabla=\"abc\"";
    String extra2Attribute = "extra-0.blabla2=\"123\"";

    assertTrue("XML doesn't contain organisation attribute", xml.contains(orgAttribute));
    assertTrue("XML doesn't contain module attribute", xml.contains(modAttribute));
    assertTrue("XML doesn't contain revision attribute", xml.contains(revAttribute));
    assertTrue("XML doesn't contain extra attribute 1", xml.contains(extra1Attribute));
    assertTrue("XML doesn't contain extra attribute 2", xml.contains(extra2Attribute));
}
 
Example #25
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Test case for IVY-1478.
 * {@link RetrieveEngine} must retrieve artifacts with the correct extension if the artifact
 * is unpacked.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1478">IVY-1478</a>
 */
@Test
public void testUnpackExt() throws Exception {
    final ResolveOptions roptions = getResolveOptions(new String[] {"*"});

    final URL url = new File("test/repositories/1/packaging/module10/ivys/ivy-1.0.xml").toURI()
            .toURL();

    // normal resolve, the file goes in the cache
    final ResolveReport report = ivy.resolve(url, roptions);
    assertFalse("Resolution report has errors", report.hasError());
    final ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull("Module descriptor from report was null", md);

    final String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])";

    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));

    final File dest = new File("build/test/retrieve/packaging/module9/default/jars/module9-1.0.jar");
    assertTrue("Retrieved artifact is missing at " + dest.getAbsolutePath(), dest.exists());
    assertTrue("Retrieved artifact at " + dest.getAbsolutePath() + " is not a file", dest.isFile());
}
 
Example #26
Source File: DependenciesManager.java    From restcommander with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        // Paths
        File application = new File(System.getProperty("application.path"));
        File framework = new File(System.getProperty("framework.path"));
        File userHome  = new File(System.getProperty("user.home"));

        DependenciesManager deps = new DependenciesManager(application, framework, userHome);

        ResolveReport report = deps.resolve();
            if(report != null) {
            deps.report();
            List<File> installed = deps.retrieve(report);
            deps.sync(installed);
        }

        if (deps.problems()) {
            System.out.println("~");
            System.out.println("~ Some dependencies are still missing.");
            System.out.println("~");
        } else {
            System.out.println("~");
            System.out.println("~ Done!");
            System.out.println("~");
        }
    }
 
Example #27
Source File: IvyDependencyTree.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public void doExecute() throws BuildException {
    prepareAndCheck();
    ResolveReport report = getResolvedReport();
    if (report == null) {
        throw new BuildException("No resolution report was available to run the post-resolve task. Make sure resolve was done before this task");
    }
    log("Dependency tree for " + report.getResolveId());
    ModuleRevisionId mrid = report.getModuleDescriptor().getModuleRevisionId();
    // make dependency tree easier to fetch information
    for (IvyNode dependency : report.getDependencies()) {
        populateDependencyTree(dependency);
    }
    final List<IvyNode> dependencyList = dependencies.get(mrid);
    if (dependencyList != null) {
        printDependencies(mrid, dependencyList, 0, new HashSet<ModuleRevisionId>());
    }
}
 
Example #28
Source File: IvyAntSettingsBuildFileTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Test case for IVY-925.
 *
 * @see <a href="https://issues.apache.org/jira/browse/IVY-925">IVY-925</a>
 */
@Test
public void testSettingsWithIdIvyInstance() {
    buildRule.executeTarget("testSettingsWithPropertyAsId");
    ResolveReport report = buildRule.getProject().getReference("ivy.resolved.report");
    assertNotNull(report);
    assertFalse(report.hasError());
    assertEquals(1, report.getDependencies().size());
}
 
Example #29
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Test case for IVY-407 (with transitivity). There are 5 modules A, B, C, D and E.
 * <ol>
 * <li>publish C-1.0.0, C-1.0.1 and C-1.0.2</li>
 * <li>B needs C-1.0.0 : retrieve ok and publish B-1.0.0</li>
 * <li>A needs B-1.0.0 and C-1.0.2 : retrieve ok and publish A-1.0.0</li>
 * <li>D needs C-1.0.1 : retrieve ok and publish D-1.0.0</li>
 * <li>E needs D-1.0.0 and A-1.0.0 (D before A in ivy file) :
 * retrieve failed to get C-1.0.2 from A (get apparently C-1.0.1 from D)</li>
 * </ol>
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-407">IVY-407</a>
 */
@Test
public void testLatestTimeTransitivity() throws Exception {
    ivy = new Ivy();
    ivy.configure(LatestConflictManagerTest.class
            .getResource("ivysettings-latest-time-transitivity.xml"));
    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);

    // set timestamps, because svn is not preserving this information,
    // and the latest time strategy is relying on it
    long time = System.currentTimeMillis() - 10000;
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.0.xml").setLastModified(time);
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.1.xml")
            .setLastModified(time + 2000);
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.2.xml")
            .setLastModified(time + 4000);

    ResolveReport report = ivy.resolve(
        LatestConflictManagerTest.class.getResource("ivy-latest-time-transitivity.xml"),
        getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        switch (mrid.getName()) {
            case "A":
                assertEquals("A revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
            case "B":
                // by transitivity
                assertEquals("B revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
            case "C":
                assertEquals("C revision should be 1.0.2", "1.0.2", mrid.getRevision());
                break;
            case "D":
                assertEquals("D revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
        }
    }
}
 
Example #30
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnpack() throws Exception {
    ResolveOptions roptions = getResolveOptions(new String[] {"*"});

    URL url = new File("test/repositories/1/packaging/module1/ivys/ivy-1.0.xml").toURI()
            .toURL();

    // normal resolve, the file goes in the cache
    ResolveReport report = ivy.resolve(url, roptions);
    assertFalse(report.hasError());
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[organization]/[module]/[conf]/[type]s/[artifact]-[revision](.[ext])";

    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));

    File dest = new File("build/test/retrieve/packaging/module2/default/jars/module2-1.0");
    assertTrue(dest.exists());
    assertTrue(dest.isDirectory());
    File[] jarContents = dest.listFiles();
    Arrays.sort(jarContents);
    assertEquals(new File(dest, "META-INF"), jarContents[0]);
    assertEquals(new File(dest, "test.txt"), jarContents[1]);
    assertEquals(new File(dest, "META-INF/MANIFEST.MF"), jarContents[0].listFiles()[0]);
}