@Override
 public void execute() throws BuildException {
   CoverageIOUtil.setDestDir(destDir);
   System.out.println("Start merging files");
   if (fileset != null) {
     File file = null;
     for (FileSet fileset : fileSets) {
       file = fileset.getDir(getProject());
       try {
         XSLTCakupanUtil.addCoverageStats(file);
       } catch (XSLTCoverageException e) {
         getProject()
             .log("No coverage files found in [" + file.getPath() + "]!", Project.MSG_WARN);
       }
     }
   } else {
     throw new BuildException("No coverage file directories set!");
   }
   try {
     XSLTCakupanUtil.dumpCoverageStats();
   } catch (XSLTCoverageException e) {
     throw new BuildException("Could not dump the coverage file!");
   }
   System.out.println("End merging files");
   super.execute();
 }
Example #2
0
  public void init() {
    super.init();
    utility = Utility.getInstance(getProject(), this);

    condition = new Conditional(getProject());
    sourceDir = getProject().resolveFile(".");
    createInclude().setName("**/*.java");
  }
  /**
   * Checks if all parameters are correct.
   *
   * @throws BuildException
   */
  protected void checkParameters() throws BuildException {
    if (getProject() == null) {
      throw new BuildException("Project reference is required.");
    }

    if (getEncoding() == null) {
      throw new BuildException("Source file encoding is required (an explicit attribute)");
    } else {
      try {
        /*
         * We log the message and at the same time check if the encoding is all
         * right.
         */
        super.log(
            "Source files encoding is: "
                + new String(getEncoding().getBytes(getEncoding()), getEncoding()),
            Project.MSG_VERBOSE);
      } catch (UnsupportedEncodingException e) {
        throw new BuildException("Encoding not supported: " + getEncoding());
      }
    }
  }