Java Code Examples for org.apache.ivy.Ivy#setVariable()

The following examples show how to use org.apache.ivy.Ivy#setVariable() . 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: ConfigureTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testTypedefWithCustomClasspath() throws Exception {
    Ivy ivy = new Ivy();
    ivy.setVariable("ivy.custom.test.dir", new File("test/java/org/apache/ivy/core/settings")
            .toURI().toURL().toString());
    ivy.configure(ConfigureTest.class.getResource("ivysettings-custom-typedef.xml"));

    DependencyResolver custom = ivy.getSettings().getResolver("custom");
    assertNotNull(custom);
    assertEquals("org.apache.ivy.plugins.resolver.CustomResolver", custom.getClass().getName());
}
 
Example 2
Source File: ConfigureTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testTypedefWithCustomClasspathWithFile() throws Exception {
    Ivy ivy = new Ivy();
    ivy.setVariable("ivy.custom.test.dir",
        new File("test/java/org/apache/ivy/core/settings").getAbsolutePath());
    ivy.configure(ConfigureTest.class.getResource("ivysettings-custom-typedef2.xml"));

    DependencyResolver custom = ivy.getSettings().getResolver("custom");
    assertNotNull(custom);
    assertEquals("org.apache.ivy.plugins.resolver.CustomResolver", custom.getClass().getName());
}
 
Example 3
Source File: XmlModuleUpdaterTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdate() throws Exception {
    /*
     * For updated file to be equals to updated.xml, we have to fix the line separator to the
     * one used in updated.xml, in order for this test to works in all platforms (default line
     * separator used in updater being platform dependent
     */
    XmlModuleDescriptorUpdater.LINE_SEPARATOR = "\n";
    File dest = new File("build/updated-test.xml");
    dest.deleteOnExit();
    Map<ModuleRevisionId, String> resolvedRevisions = new HashMap<>();
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), "2.5");
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule6", "trunk", "latest.integration"),
        "6.3");

    Map<ModuleRevisionId, String> resolvedBranches = new HashMap<>();
    resolvedBranches.put(ModuleRevisionId.newInstance("yourorg", "yourmodule3", "3.1"),
        "branch1");
    resolvedBranches.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), null);

    GregorianCalendar cal = new GregorianCalendar();
    cal.set(2005, 2, 22, 14, 32, 54);

    Ivy ivy = Ivy.newInstance();
    ivy.setVariable("myvar", "myconf1");
    XmlModuleDescriptorUpdater.update(
        XmlModuleUpdaterTest.class.getResource("test-update.xml"),
        dest,
        getUpdateOptions(ivy.getSettings(), resolvedRevisions, "release", "mynewrev",
            cal.getTime()).setResolvedBranches(resolvedBranches));

    assertTrue(dest.exists());
    String expected = FileUtil.readEntirely(new BufferedReader(new InputStreamReader(
            XmlModuleUpdaterTest.class.getResourceAsStream("updated.xml"))));
    String updated = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)));
    assertEquals(expected, updated);
}
 
Example 4
Source File: XmlModuleUpdaterTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
@Test
public void testVariableReplacement() throws Exception {
    /*
     * For updated file to be equals to updated.xml, we have to fix the line separator to the
     * one used in updated.xml, in order for this test to works in all platforms (default line
     * separator used in updater being platform dependent
     */
    XmlModuleDescriptorUpdater.LINE_SEPARATOR = "\n";
    File dest = new File("build/updated-test2.xml");
    dest.deleteOnExit();
    Map<ModuleRevisionId, String> resolvedRevisions = new HashMap<>();
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), "2.5");
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule6", "trunk", "latest.integration"),
        "6.3");

    Map<ModuleRevisionId, String> resolvedBranches = new HashMap<>();
    resolvedBranches.put(ModuleRevisionId.newInstance("yourorg", "yourmodule3", "3.1"),
        "branch1");
    resolvedBranches.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), null);

    GregorianCalendar cal = new GregorianCalendar();
    cal.set(2005, 2, 22, 14, 32, 54);

    Ivy ivy = Ivy.newInstance();
    ivy.setVariable("myorg", "myorg");
    ivy.setVariable("mymodule", "mymodule");
    ivy.setVariable("myrev", "myrev");
    ivy.setVariable("mystatus", "integration");
    ivy.setVariable("mypubdate", "20050322143254");
    ivy.setVariable("mylicense", "MyLicense");
    ivy.setVariable("mylicenseurl", "http://www.my.org/mymodule/mylicense.html");
    ivy.setVariable("myorgurl", "http://www.myorg.org/");
    ivy.setVariable("ivyrep", "ivyrep");
    ivy.setVariable("ivyrepurl", "http://www.jayasoft.fr/org/ivyrep/");
    ivy.setVariable("ivyreppattern", "[organisation]/[module]/ivy-[revision].xml");
    ivy.setVariable("ivys", "true");
    ivy.setVariable("artifacts", "false");
    ivy.setVariable("homepage", "http://www.my.org/mymodule/");
    ivy.setVariable("includefile", "imported-configurations-with-mapping.xml");
    ivy.setVariable("mydesc", "desc 1");
    ivy.setVariable("visibility", "public");
    ivy.setVariable("myvar", "myconf1");
    ivy.setVariable("deprecated", "20050115");
    ivy.setVariable("myartifact1", "myartifact1");
    ivy.setVariable("mytype", "jar");
    ivy.setVariable("mymodule2", "mymodule2");
    ivy.setVariable("mymodule2rev", "2.0");
    ivy.setVariable("changing", "true");
    ivy.setVariable("transitive", "false");
    ivy.setVariable("targetconf", "yourconf1");
    ivy.setVariable("art9-1", "yourartifact9-1");
    ivy.setVariable("conf3", "myconf3");
    ivy.setVariable("includename", "your.*");
    ivy.setVariable("includeext", "xml");
    ivy.setVariable("excludename", "toexclude");
    ivy.setVariable("excludemodule", "*servlet*");
    ivy.setVariable("excludematcher", "glob");
    ivy.setVariable("excludeorg", "acme");
    ivy.setVariable("excludeartifact", "test");
    ivy.setVariable("excludetype", "source");
    ivy.setVariable("yourorg", "yourorg");
    ivy.setVariable("yourmodule", ".*");
    ivy.setVariable("all", "all");
    ivy.setVariable("regexp", "regexp");
    ivy.setVariable("theirrev", "1.0, 1.1");

    XmlModuleDescriptorUpdater.update(
        XmlModuleUpdaterTest.class.getResource("test-update-withvar.xml"),
        dest,
        getUpdateOptions(ivy.getSettings(), resolvedRevisions, "release", "mynewrev",
            cal.getTime()).setResolvedBranches(resolvedBranches));

    assertTrue(dest.exists());
    String expected = FileUtil.readEntirely(new BufferedReader(new InputStreamReader(
            XmlModuleUpdaterTest.class.getResourceAsStream("updated.xml"))));
    String updated = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)));
    assertEquals(expected, updated);
}