Search in sources :

Example 26 with Macro

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

the class MacroTest method testFindPath.

public static void testFindPath() throws IOException {
    try (Analyzer analyzer = new Analyzer()) {
        analyzer.setJar(IO.getFile("jar/asm.jar"));
        Macro m = new Macro(analyzer);
        assertTrue(m.process("${findname;(.*)\\.class;$1.xyz}").indexOf("FieldVisitor.xyz,") >= 0);
        assertTrue(m.process("${findname;(.*)\\.class;$1.xyz}").indexOf("MethodVisitor.xyz,") >= 0);
        assertTrue(m.process("${findpath;(.*)\\.class}").indexOf("org/objectweb/asm/AnnotationVisitor.class,") >= 0);
        assertTrue(m.process("${findpath;(.*)\\.class}").indexOf("org/objectweb/asm/ByteVector.class, org/objectweb/asm/ClassAdapter.class,") >= 0);
        assertEquals("META-INF/MANIFEST.MF", m.process("${findpath;META-INF/MANIFEST.MF}"));
        assertEquals("Label.class", m.process("${findname;Label\\..*}"));
        assertEquals("Adapter, Visitor, Writer", m.process("${findname;Method(.*)\\.class;$1}"));
    }
}
Also used : Macro(aQute.bnd.osgi.Macro) Analyzer(aQute.bnd.osgi.Analyzer)

Example 27 with Macro

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

the class MacroTest method testDef.

/**
	 * Check if we can check for the defintion of a variable
	 */
public static void testDef() {
    Processor p = new Processor();
    p.setProperty("set.1", "1");
    p.setProperty("set.2", "2");
    Macro m = new Macro(p);
    assertEquals("NO", m.process("${if;${def;set.3};YES;NO}"));
    assertEquals("YES", m.process("${if;${def;set.1};YES;NO}"));
    assertEquals("YES", m.process("${if;${def;set.2};YES;NO}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 28 with Macro

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

the class MacroTest method testParentheses.

public static void testParentheses() {
    Processor p = new Processor();
    Macro m = new Macro(p);
    String value = m.process("$(replace;();(\\(\\));$1)");
    assertEquals("()", value);
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 29 with Macro

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

the class MacroTest method testReplace.

/**
	 * NEW
	 */
public static void testReplace() {
    Processor p = new Processor();
    p.setProperty("specs", "a,b, c,    d");
    Macro m = new Macro(p);
    assertEquals("xay, xby, xcy, xdy", m.process("${replace;${specs};([^\\s]+);x$1y}"));
}
Also used : Processor(aQute.bnd.osgi.Processor) Macro(aQute.bnd.osgi.Macro)

Example 30 with Macro

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

the class MacroTest method testSort.

public static void testSort() {
    Processor p = new Processor();
    p.setProperty("a", "aaaa");
    Macro m = new Macro(p);
    assertEquals("aa,bb,cc,dd,ee,ff", m.process("${sort;aa,bb,cc,dd,ee,ff}"));
    assertEquals("aa,bb,cc,dd,ee,ff", m.process("${sort;ff,ee,cc,bb,dd,aa}"));
    assertEquals("aaaa,bb,cc,dd,ee,ff", m.process("${sort;ff,ee,cc,bb,dd,$<a>}"));
}
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