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
  public void _sign(SignOptions options) throws Exception {
    String password = null;
    if (options.password() == null) {
      Console console = System.console();
      if (console == null) {
        error("No -p/--password set for PGP key and no console to ask");
      } else {
        char[] pw = console.readPassword("Passsword: ");
        if (pw == null || pw.length == 0) {
          error("Password not entered");
        }
        password = new String(pw);
      }
    } else password = options.password();

    Signer signer =
        new Signer(new String(password), options.command(getProperty("gpg", System.getenv("GPG"))));

    if (signer == null || password == null || !isOk()) return;

    List<String> args = options._arguments();

    if (args.isEmpty()) {
      List<URI> files = nexus.files();
      for (URI uri : files) {
        try {
          trace("signing %s", relative(uri));
          File f = nexus.download(uri);
          byte[] signature = signer.sign(f);
          if (options.show()) show(signature);
          else nexus.upload(new URI(uri + ".asc"), signature);
        } catch (Exception e) {
          exception(e, "could not download/sign/upload %s", relative(uri));
        }
      }
    } else {
      for (String arg : args) {
        File f = getFile(arg);
        if (!f.isFile()) {
          error("Can't find file %s", f);
        } else {
          byte[] signature = signer.sign(f);
          if (options.show()) show(signature);
          else {
            File out = new File(f.getParentFile(), f.getName() + ".asc");
            IO.store(signature, out);
          }
        }
      }
    }
  }
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);
  }