Ejemplo n.º 1
0
  public static void main(String[] args) throws Exception {
    // findbugs
    // mvn clean compile findbugs:findbugs -Dbuildtime.output.csv=true
    // -Dbuildtime.output.csv.file=classes\out.csv
    // pmd
    // mvn pmd:pmd -Dbuildtime.output.csv=true
    // -Dbuildtime.output.csv.file=classes\out.csv
    // findbugs
    // mvn clean compile -Pfindsecbugs -Dbuildtime.output.csv=true
    // -Dbuildtime.output.csv.file=classes\out.csv
    // sonar
    // mvn sonar:sonar -Dbuildtime.output.csv=true
    // -Dbuildtime.output.csv.file=classes\out.csv
    // rewrite results file name with times and version
    // String toolName = "sonar";
    String toolName = "";
    String csvToolName = "";
    if (args.length < 1) {
      System.out.println(
          "Please provide the name of the tool.\n"
              + "Currently supported: PMD (pmd), FindBugs (findbugs), FindSecBugs (findbugs) and SonarQube (sonar).");
    } else {
      toolName = args[0];
    }
    // System.out.println("Tool: " + toolName);

    PropertiesManager propM = new PropertiesManager();
    WriteFiles wf = new WriteFiles();
    if (toolName.contains("sonar")) { // We need to generate the results
      // file from the webService
      wf.writeSonarResults();
    }

    if (toolName.equals("findsecbugs")) {
      csvToolName = "findbugs";
    } else if (toolName.equals("crawler")) {
      csvToolName = "exec-maven-plugin:java";
    } else {
      csvToolName = toolName;
    }

    propM.saveProperty(toolName, wf.getToolTime(csvToolName));
    propM.saveProperty("benchmark-version", wf.getbenchmarkVersion()); //
    // propM.displayProperties();

    wf.deletePreviousResults(
        toolName, wf.getVersionNumber(toolName), propM.getProperty("benchmark-version", ""));

    wf.resultsFileName(
        toolName,
        propM.getProperty("benchmark-version", ""),
        propM.getProperty(toolName, ""),
        wf.getVersionNumber(toolName));
  }