예제 #1
0
  public void execute() throws MojoExecutionException, MojoFailureException {

    try {

      WindupEnvironment settings = new WindupEnvironment();

      if (targetPlatform != null) {
        settings.setTargetPlatform(targetPlatform);
      }

      if (fetchRemote != null) {
        settings.setFetchRemote(fetchRemote);
      }

      if (excludePackages != null) {
        settings.setExcludeJavaPackageSignature(Arrays.asList(excludePackages));
      }

      settings.setCaptureLog(captureLog);

      settings.setLogLevel(logLevel);

      settings.setIncludeJavaPackageSignature(Arrays.asList(packages));

      settings.setSource(source);

      settings.setInputPath(inputDirectory);
      settings.setOutputPath(outputDirectory);

      // Run Windup.
      ReportEngine engine = new ReportEngine(settings);
      engine.process();
    } catch (IOException e) {
      getLog().error(e.getMessage(), e);
    }
  }
예제 #2
0
  public void processInput(CommandLine line, Options options) {
    // automatically generate the help statement

    try {
      // parse the command line arguments

      if (line.getOptions().length < 1) {
        HELP_FORMATTER.printHelp(WINDUP_COMMAND, options);
      } else {
        // Map the environment settings from the input arguments.
        WindupEnvironment settings = new WindupEnvironment();
        if (line.hasOption("javaPkgs")) {
          String javaPkgs = line.getOptionValue("javaPkgs");
          if (javaPkgs != null) {
            String[] javaPkgsArr = javaPkgs.split(":");
            settings.setIncludeJavaPackageSignature(Arrays.asList(javaPkgsArr));
          }
        }
        if (line.hasOption("excludePkgs")) {
          String excludeJavaPkgs = line.getOptionValue("excludePkgs");
          if (excludeJavaPkgs != null) {
            String[] excludeJavaPkgsArr = excludeJavaPkgs.split(":");
            settings.setExcludeJavaPackageSignature(Arrays.asList(excludeJavaPkgsArr));
          }
        }

        if (line.hasOption("targetPlatform")) {
          settings.setTargetPlatform(line.getOptionValue("targetPlatform"));
        }

        if (line.hasOption("fetchRemote")) {
          String fetchRemoteString = line.getOptionValue("fetchRemote");
          if (StringUtils.isBlank(fetchRemoteString)) {
            settings.setFetchRemote(false);
          } else {
            boolean fetchRemote = Boolean.parseBoolean(fetchRemoteString);
            settings.setFetchRemote(fetchRemote);
          }
        }

        String inputLocation = line.getOptionValue("input");
        inputLocation = StringUtils.trim(inputLocation);
        File inputPath = new File(inputLocation);

        File outputPath = null;
        String outputLocation = line.getOptionValue("output");
        outputLocation = StringUtils.trim(outputLocation);
        if (StringUtils.isNotBlank(outputLocation)) {
          outputPath = new File(outputLocation);
        }

        boolean isSource = false;
        if (BooleanUtils.toBoolean(line.getOptionValue("source"))) {
          isSource = true;
        }
        settings.setSource(isSource);

        boolean captureLog = false;
        if (BooleanUtils.toBoolean(line.getOptionValue("captureLog"))) {
          captureLog = true;
        }

        String logLevel = line.getOptionValue("logLevel");
        logLevel = StringUtils.trim(logLevel);

        settings.setCaptureLog(captureLog);
        settings.setLogLevel(logLevel);

        settings.setInputPath(inputPath);
        settings.setOutputPath(outputPath);

        // Run Windup.
        ReportEngine engine = new ReportEngine(settings);
        engine.process();
      }
    } catch (FileNotFoundException e) {
      LOG.error("Input does not exist:" + e.getMessage(), e);
      HELP_FORMATTER.printHelp(WINDUP_COMMAND, options);
    } catch (IOException e) {
      LOG.error("Exception while writing report: " + e.getMessage(), e);
      HELP_FORMATTER.printHelp(WINDUP_COMMAND, options);
    }
  }