Ejemplo n.º 1
0
  @SuppressWarnings("unchecked")
  public void execute() throws MojoExecutionException, MojoFailureException {
    try {
      if (failOnWarning) {
        jswarn = true;
      }

      jsErrorReporter_ = new ErrorReporter4Mojo(getLog(), jswarn);
      beforeProcess();
      processDir(sourceDirectory, outputDirectory, null, null, true);

      for (Resource resource : resources) {
        File destRoot = outputDirectory;

        if (resource.getTargetPath() != null) {
          destRoot = new File(outputDirectory, resource.getTargetPath());
        }

        processDir(
            new File(resource.getDirectory()),
            destRoot,
            resource.getIncludes(),
            resource.getExcludes(),
            true);
      }

      processDir(warSourceDirectory, webappDirectory, null, null, false);
      afterProcess();
      getLog()
          .info(
              String.format(
                  "nb warnings: %d, nb errors: %d",
                  jsErrorReporter_.getWarningCnt(), jsErrorReporter_.getErrorCnt()));

      if (failOnWarning && (jsErrorReporter_.getWarningCnt() > 0)) {
        throw new MojoFailureException(
            "warnings on " + this.getClass().getSimpleName() + "=> failure ! (see log)");
      }
    } catch (RuntimeException exc) {
      throw exc;
    } catch (MojoFailureException exc) {
      throw exc;
    } catch (MojoExecutionException exc) {
      throw exc;
    } catch (Exception exc) {
      throw new MojoExecutionException("wrap: " + exc.getMessage(), exc);
    }
  }