public void execute() throws MojoExecutionException { getLog().debug("Started maven-jlint-plugin: execute() method"); getLog().info("Running Maven-Jlint-Plugin : "); // Setup ResourceManager locator.addSearchPath( FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath()); locator.addSearchPath("url", ""); locator.setOutputDirectory(new File(project.getBuild().getDirectory())); getLog().info("Configuration File used: " + configLocation); // File f = outputDirectory; JlintViolationHandler violationHandler = new JlintViolationHandler(getLog()); violationHandler.setTargetDir(outputDirectory.toString()); violationHandler.setClassesDir( System.getProperty("file.separator") + Constants.JLINT_CLASSES_DIR); JlintConfiguration jlintConfig = new JlintConfiguration(locator, configLocation, getLog()); String cmdDisableCategories = jlintConfig.getCategoriesToDisable(violationHandler.getDefaultMessageList()); String cmd = Constants.JLINT_CMD + cmdDisableCategories + outputDirectory.toString() + System.getProperty("file.separator") + Constants.JLINT_CLASSES_DIR; getLog() .info( "Classes Directory : " + outputDirectory.toString() + System.getProperty("file.separator") + Constants.JLINT_CLASSES_DIR); getLog().debug("Disabled Categories: " + cmdDisableCategories); getLog().info("Executing Jlint with command : [" + cmd + "]"); // Open output files for writing File xmlFile = new File(outputDirectory, Constants.JLINT_XML_OUTPUT_FILENAME); File txtFile = new File(outputDirectory, Constants.JLINT_TXT_OUTPUT_FILENAME); File errFile = new File(outputDirectory, Constants.JLINT_ERROR_FILENAME); String s = null; try { // run the Jlint command on the "classes" directory getLog().debug("execute: About to execute jlint command"); Process p = Runtime.getRuntime().exec(cmd); /* BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); outputXmlFile = new BufferedWriter(new FileWriter(xmlFile)); outputTxtFile = new BufferedWriter(new FileWriter(txtFile)); errorFile = new BufferedWriter(new FileWriter(errFile)); */ FileOutputStream outputXmlFile = new FileOutputStream(xmlFile); FileOutputStream outputTxtFile = new FileOutputStream(txtFile); FileOutputStream errorFile = new FileOutputStream(errFile); // Create the output file /* outputXmlFile.write(Constants.XML_HEADER); outputXmlFile.newLine(); outputXmlFile.newLine(); outputXmlFile.write(Constants.ROOT_START_TAG); */ StreamGobbler inputGobbler = new StreamGobbler(p.getInputStream(), outputXmlFile, outputTxtFile, "INPUT"); inputGobbler.setViolationHandler(violationHandler); StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), errorFile, "ERROR"); getLog().info("Reading the standard input and error for Jlint"); inputGobbler.start(); errorGobbler.start(); int exitVal = p.waitFor(); getLog().info("Jlint exited with status value: " + String.valueOf(exitVal)); if (exitVal != 0) { getLog() .error( "Jlint did not execute properly. Check " + Constants.JLINT_ERROR_FILENAME + " file."); } inputGobbler.join(); errorGobbler.join(); getLog().info("** Jlint Report: **"); getLog().info("-------------------"); getLog() .info( "JLint Violations (if any): " + String.valueOf(inputGobbler.getNofLines()) + " violations reported."); getLog().info("Jlint Error Messages (if any): "); for (String msg : errorGobbler.getErrorMsgList()) { getLog().error(msg); } getLog().info("----End Report-----"); } catch (IOException e) { System.out.println("JLint: Exception Occured: "); e.printStackTrace(); // System.exit(-1); } catch (InterruptedException e) { System.out.println("JLint: Exception Occured: "); e.printStackTrace(); } }