Search in sources :

Example 1 with Macro

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);
}
Also used : Processor(aQute.bnd.osgi.Processor) Capability(org.osgi.resource.Capability) Version(aQute.bnd.version.Version) VersionedClause(aQute.bnd.build.model.clauses.VersionedClause) Macro(aQute.bnd.osgi.Macro) Attrs(aQute.bnd.header.Attrs)

Example 2 with Macro

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 + "}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 3 with Macro

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"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 4 with Macro

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}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 5 with Macro

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]+}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Aggregations

Macro (aQute.bnd.osgi.Macro)32 Processor (aQute.bnd.osgi.Processor)29 Project (aQute.bnd.build.Project)1 VersionedClause (aQute.bnd.build.model.clauses.VersionedClause)1 Attrs (aQute.bnd.header.Attrs)1 Analyzer (aQute.bnd.osgi.Analyzer)1 Version (aQute.bnd.version.Version)1 Description (aQute.lib.getopt.Description)1 Replacer (aQute.libg.sed.Replacer)1 Sed (aQute.libg.sed.Sed)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 Field (java.lang.reflect.Field)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 Proxy (java.lang.reflect.Proxy)1 URL (java.net.URL)1