use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class ResourceUtils method toVersionClause.
/**
* Create a VersionedClause by applying a version range mask to the
* resource! Masks are defined by
* {@link aQute.bnd.osgi.Macro#_range(String[])}. If the resource should
* represent a project in the bnd workspace, then instead the VersionClause
* will refer to it as a snapshot version: e.g. <bsn>;version=snapshot
*/
public static VersionedClause toVersionClause(Resource resource, String mask) {
Capability idCap = getIdentityCapability(resource);
String identity = getIdentity(idCap);
String versionString;
if (resource.getCapabilities(WORKSPACE_NAMESPACE).isEmpty()) {
Macro macro = new Macro(new Processor());
Version version = getVersion(idCap);
versionString = macro._range(new String[] { "range", mask, version.toString() });
} else {
versionString = "snapshot";
}
Attrs attribs = new Attrs();
attribs.put(Constants.VERSION_ATTRIBUTE, versionString);
return new VersionedClause(identity, attribs);
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testTstamp.
public static void testTstamp() {
String aug152008 = "1218810097322";
Processor p = new Processor();
Macro m = new Macro(p);
assertEquals("200808151421", m.process("${tstamp;yyyyMMddHHmm;UTC;" + aug152008 + "}"));
assertEquals("200808151521", m.process("${tstamp;yyyyMMddHHmm;GMT+01;" + aug152008 + "}"));
assertEquals("2008", m.process("${tstamp;yyyy;UTC;" + aug152008 + "}"));
// Why Tokyo? Japan doesn't use daylight savings, so the test shouldn't
// break when clocks change.
assertEquals("200808152321", m.process("${tstamp;yyyyMMddHHmm;Asia/Tokyo;" + aug152008 + "}"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testWc.
/**
* Test the wc function
*/
public static void testWc() {
Processor p = new Processor();
Macro macro = new Macro(p);
String a = macro.process("${lsr;src/test;*.java}");
assertTrue(a.contains("MacroTest.java"));
assertTrue(a.contains("ManifestTest.java"));
assertFalse(a.contains("bnd.info"));
assertFalse(a.contains("com.acme"));
assertFalse(a.contains("src/test/MacroTest.java"));
assertFalse(a.contains("src/test/ManifestTest.java"));
String b = macro.process("${lsa;src/test;*.java}");
assertTrue(b.contains("src/test/MacroTest.java"));
assertTrue(b.contains("src/test/ManifestTest.java"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testSystemAllowFail.
/**
* Verify system-allow-fail command
*/
public static void testSystemAllowFail() throws Exception {
Processor p = new Processor();
Macro macro = new Macro(p);
assertEquals("", macro.process("${system-allow-fail;mostidioticcommandthatwillsurelyfail}"));
}
use of aQute.bnd.osgi.Macro in project bnd by bndtools.
the class MacroTest method testFilter.
public static void testFilter() {
Processor p = new Processor();
p.setProperty("a", "aaaa");
Macro m = new Macro(p);
assertEquals("aa,cc,ee", m.process("${filter;aa,bb,cc,dd,ee,ff;[ace]+}"));
assertEquals("aaaa,cc,ee", m.process("${filter;${a},bb,cc,dd,ee,ff;[ace]+}"));
assertEquals("bb,dd,ff", m.process("${filter;${a},bb,cc,dd,ee,ff;[^ace]+}"));
}
Aggregations