Exemple #1
0
 @Override
 public void delete(Project p) throws IOException {
   File root = p.getWorkspace().getFile("pom.xml");
   String rootPom = IO.collect(root);
   if (rootPom.contains(getTag(p))) {
     rootPom = rootPom.replaceAll("\n\\s*" + getTag(p) + "\\s*", "\n");
     IO.store(rootPom, root);
   }
 }
Exemple #2
0
  @Override
  public void execute() throws BuildException {
    // JME add - ensure every required parameter is present
    // handle cases where mutual exclusion live..
    // this is the ANT tradition ..
    validate();
    updateClasspath();
    updateBndFiles();

    if (command == null) {
      executeBackwardCompatible();
      return;
    }

    if (basedir == null) throw new BuildException("No basedir set");

    try {
      Project project = Workspace.getProject(basedir);

      Workspace ws = project.getWorkspace();
      for (Property prop : workspaceProps) {
        ws.setProperty(prop.getName(), prop.getValue());
      }

      project.setProperty("in.ant", "true");
      project.setProperty("environment", "ant");
      project.setExceptions(true);
      project.setTrace(trace);
      project.setPedantic(pedantic);

      for (Property prop : properties) {
        project.setProperty(prop.getName(), prop.getValue());
      }

      if (test) project.action(command, test);
      else project.action(command);

      for (Project p : ws.getCurrentProjects()) ws.getInfo(p, p + ":");

      if (report(ws)) throw new BuildException("Command " + command + " failed");
    } catch (Throwable e) {
      if (exceptions) e.printStackTrace();
      throw new BuildException(e);
    }
  }
Exemple #3
0
  @Override
  public void created(Project p) throws IOException {
    Workspace workspace = p.getWorkspace();

    copy("pom.xml", "pom.xml", p);

    File root = workspace.getFile("pom.xml");

    doRoot(p, root);

    String rootPom = IO.collect(root);
    if (!rootPom.contains(getTag(p))) {
      rootPom =
          rootPom.replaceAll(
              "<!-- DO NOT EDIT MANAGED BY BND MAVEN LIFECYCLE PLUGIN -->\n",
              "$0\n\t\t" + getTag(p) + "\n");
      IO.store(rootPom, root);
    }
  }
Exemple #4
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);
  }