use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testWarning.
public static void testWarning() {
Processor p = new Processor();
p.setProperty("three", "333");
p.setProperty("empty", "");
p.setProperty("real", "true");
Macro m = new Macro(p);
m.process(" ${warning;xw;1;2;3 ${three}}");
m.process(" ${error;xe;1;2;3 ${three}}");
m.process(" ${if;1;$<a>}");
assertTrue("xw", p.getWarnings().get(0).endsWith("xw"));
assertTrue("1", p.getWarnings().get(1).endsWith("1"));
assertTrue("2", p.getWarnings().get(2).endsWith("2"));
assertTrue("3 333", p.getWarnings().get(3).endsWith("3 333"));
assertTrue("xw", p.getErrors().get(0).endsWith("xe"));
assertTrue("1", p.getErrors().get(1).endsWith("1"));
assertTrue("2", p.getErrors().get(2).endsWith("2"));
assertTrue("3 333", p.getErrors().get(3).endsWith("3 333"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testJoin.
public static void testJoin() {
Processor p = new Processor();
p.setProperty("a", "aaaa");
Macro m = new Macro(p);
assertEquals("aa,bb,cc,dd,ee,ff", m.process("${join;aa,bb,cc,dd,ee,ff}"));
assertEquals("aa,bb,cc,dd,ee,ff", m.process("${join;aa,bb,cc;dd,ee,ff}"));
assertEquals("aa,bb,cc,dd,ee,ff", m.process("${join;aa;bb;cc;dd;ee,ff}"));
assertEquals("aaXbbXccXddXeeXff", m.process("${sjoin;X;aa,bb,cc,dd,ee,ff}"));
assertEquals("aa\nbb\ncc\ndd\nee\nff", m.process("${sjoin;\n;aa,bb,cc;dd,ee,ff}"));
assertEquals("aa\nbb\ncc\ndd\nee\nff", m.process("${unescape;${sjoin;\\n;aa,bb,cc;dd,ee,ff}}"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testParentFile.
public static void testParentFile() {
Processor p = new Processor();
Macro m = new Macro(p);
assertTrue(m.process("${dir;.project}").endsWith("biz.aQute.bndlib.tests"));
}
use of aQute.bnd.osgi.Macro in project karaf by apache.
the class VerifyMojo method getMetadata.
public static Map<String, Map<VersionRange, Map<String, String>>> getMetadata(Map<String, String> properties, String prefix) {
Map<String, Map<VersionRange, Map<String, String>>> result = new HashMap<>();
for (String key : properties.keySet()) {
if (key.startsWith(prefix)) {
String val = properties.get(key);
key = key.substring(prefix.length());
String[] parts = key.split("#");
if (parts.length == 3) {
Map<VersionRange, Map<String, String>> ranges = result.computeIfAbsent(parts[0], k -> new HashMap<>());
String version = parts[1];
if (!version.startsWith("[") && !version.startsWith("(")) {
Processor processor = new Processor();
processor.setProperty("@", VersionTable.getVersion(version).toString());
Macro macro = new Macro(processor);
version = macro.process("${range;[==,=+)}");
}
VersionRange range = new VersionRange(version);
ranges.computeIfAbsent(range, k -> new HashMap<>()).put(parts[2], val);
}
}
}
return result;
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class bnd method _macro.
/**
* Show the value of a macro
*
* @throws Exception
*/
@Description("Show macro value")
public void _macro(macroOptions options) throws Exception {
Project project = getProject(options.project());
if (project == null) {
messages.NoProject();
return;
}
StringBuilder sb = new StringBuilder();
Macro r = project.getReplacer();
getInfo(project);
String del = "";
for (String s : options._arguments()) {
if (!s.startsWith("${")) {
s = "${" + s;
}
if (!s.endsWith("}")) {
s += "}";
}
s = s.replace(':', ';');
String p = r.process(s);
sb.append(del);
sb.append(p);
del = " ";
}
getInfo(project);
err.println(sb);
}
Aggregations