Ejemplo n.º 1
0
  public static void testRepoMacro() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("test/ws"));
    Project project = ws.getProject("p2");
    System.err.println(project.getPlugins(FileRepo.class));
    String s = project.getReplacer().process(("${repo;libtest}"));
    System.err.println(s);
    assertTrue(
        s.contains(
            "org.apache.felix.configadmin"
                + File.separator
                + "org.apache.felix.configadmin-1.2.0"));
    assertTrue(
        s.contains("org.apache.felix.ipojo" + File.separator + "org.apache.felix.ipojo-1.0.0.jar"));

    s = project.getReplacer().process(("${repo;libtestxyz}"));
    assertTrue(s.matches("<<[^>]+>>"));

    s = project.getReplacer().process("${repo;org.apache.felix.configadmin;1.0.0;highest}");
    assertTrue(s.endsWith("org.apache.felix.configadmin-1.2.0.jar"));
    s = project.getReplacer().process("${repo;org.apache.felix.configadmin;1.0.0;lowest}");
    assertTrue(s.endsWith("org.apache.felix.configadmin-1.0.1.jar"));
  }
Ejemplo n.º 2
0
  private void copy(String source, String dest, Project p) throws IOException {

    File f = p.getWorkspace().getFile("maven/" + source + ".tmpl");
    InputStream in;

    if (f.isFile()) {
      in = new FileInputStream(f);
    } else {
      in = MavenPlugin.class.getResourceAsStream(source);
      if (in == null) {
        p.error("Cannot find Maven default for %s", source);
        return;
      }
    }

    String s = IO.collect(in);
    String process = p.getReplacer().process(s);

    File d = p.getFile(dest);
    d.getParentFile().mkdirs();
    IO.store(process, d);
  }