Search in sources :

Example 61 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testRange.

public static void testRange() throws Exception {
    Processor proc = new Processor();
    Macro macro = new Macro(proc);
    assertEquals("[1.0,1.0]", macro.process("${range;[==,==];1.0.0}"));
    assertEquals("[1.0.0,1.0.1]", macro.process("${range;[===,==+];1.0.0}"));
    assertEquals("[0.1.0,0.1.2)", macro.process("${range;[=+0,=++);0.0.1}"));
    assertEquals("[0.0.9,0.1.2)", macro.process("${range;[==9,=++);0.0.1}"));
    assertEquals(0, proc.getErrors().size());
    assertEquals(0, proc.getWarnings().size());
    proc.setProperty("@", "1.2.3");
    assertEquals("[1.0.0,2)", macro.process("${range;[=00,+)}"));
    proc.clear();
    macro.process("${range;=+0,=++;0.0.1}");
    assertEquals(1, proc.getErrors().size());
    assertEquals(1, proc.getWarnings().size());
    proc.clear();
    macro.process("${range;[+,=)}");
    assertEquals(1, proc.getErrors().size());
    assertEquals(1, proc.getWarnings().size());
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 62 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testBasename.

public static void testBasename() {
    Processor p = new Processor();
    Macro m = new Macro(p);
    assertEquals("biz.aQute.bndlib.tests", m.process("${basename;${dir;.project}}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 63 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method assertTemplate.

void assertTemplate(String result, String template, String params) {
    Processor top = new Processor();
    top.setProperty("template", template);
    top.setProperty("macro", "${template;" + params + "}");
    String expanded = top.getProperty("macro");
    assertEquals(result, expanded);
}
Also used : Processor(aQute.bnd.osgi.Processor)

Example 64 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testVersion.

public static void testVersion() throws Exception {
    Processor proc = new Processor();
    Macro macro = new Macro(proc);
    assertEquals("1.0.0", macro.process("${version;===;1.0.0}"));
    assertEquals("1.0.1", macro.process("${version;==+;1.0.0}"));
    assertEquals("1.1.1", macro.process("${version;=++;1.0.0}"));
    assertEquals("2.1.1", macro.process("${version;+++;1.0.0}"));
    assertEquals("0.1.1", macro.process("${version;-++;1.0.0}"));
    assertEquals("0.1.1", macro.process("${version;-++;1.0.0}"));
    assertEquals("0.0.0", macro.process("${version;---;1.1.1}"));
    assertEquals("0.0", macro.process("${version;--;1.1.1}"));
    assertEquals("1", macro.process("${version;=;1.1.1}"));
    assertEquals("[1.1,1.2)", macro.process("[${version;==;1.1.1},${version;=+;1.1.1})"));
    assertEquals("1.1", macro.process("${version;==;1.1.1}"));
    assertEquals("0.1.0", macro.process("${version;=+0;0.0.1}"));
    assertEquals("1.0.0", macro.process("${version;+00;0.1.1}"));
    // Test implicit version
    proc.setProperty("@", "1.2.3");
    assertEquals("[1.2,1.3)", macro.process("[${version;==},${version;=+})"));
    assertEquals("1.2", macro.process("${version;==}"));
    assertEquals("1.3.0", macro.process("${version;=+0}"));
    assertEquals("2.0.0", macro.process("${version;+00}"));
    assertEquals(0, proc.getErrors().size());
    assertEquals(0, proc.getWarnings().size());
    //
    // Add the S modifier. If qualifier is SNAPSHOT, it will return a
    // maven version
    //
    assertEquals("1.2.3-SNAPSHOT", macro.process("${version;===S;1.2.3.SNAPSHOT}"));
    assertEquals("1.2.3-SNAPSHOT", macro.process("${version;===s;1.2.3.SNAPSHOT}"));
    assertEquals("1.2.3.SNAPSHOT", macro.process("${version;====;1.2.3.SNAPSHOT}"));
    assertEquals("1.2.3-SNAPSHOT", macro.process("${version;===S;1.2.3.BUILD-SNAPSHOT}"));
    assertEquals("1.2.3-SNAPSHOT", macro.process("${version;===s;1.2.3.BUILD-SNAPSHOT}"));
    assertEquals("1.2.3.BUILD-SNAPSHOT", macro.process("${version;====;1.2.3.BUILD-SNAPSHOT}"));
    assertEquals("1.2.3.X", macro.process("${version;===S;1.2.3.X}"));
    assertEquals("1.2.3", macro.process("${version;===s;1.2.3.X}"));
    assertEquals("1.2.3.X", macro.process("${version;====;1.2.3.X}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 65 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MacroTest method testVersionMaskWithSetExplicitTarget.

public void testVersionMaskWithSetExplicitTarget() throws IOException {
    Processor p = new Processor();
    p.setProperty("@", "1.2.3");
    assertEquals("1.2.3", p.getReplacer().process("${version;===;${@}}"));
    assertTrue(p.check());
}
Also used : Processor(aQute.bnd.osgi.Processor)

Aggregations

Processor (aQute.bnd.osgi.Processor)185 HashMap (java.util.HashMap)43 File (java.io.File)37 Macro (aQute.bnd.osgi.Macro)29 Workspace (aQute.bnd.build.Workspace)27 Jar (aQute.bnd.osgi.Jar)17 HttpClient (aQute.bnd.http.HttpClient)14 Baseline (aQute.bnd.differ.Baseline)12 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)12 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)10 IOException (java.io.IOException)10 Resource (org.osgi.resource.Resource)10 Info (aQute.bnd.differ.Baseline.Info)8 Version (aQute.bnd.version.Version)8 ArrayList (java.util.ArrayList)8 List (java.util.List)7 ProgressPlugin (aQute.bnd.service.progress.ProgressPlugin)6 Collection (java.util.Collection)6 Properties (java.util.Properties)6 Parameters (aQute.bnd.header.Parameters)5