protected enableForking(targetNode: any) {
        let _this = this;
        let testNodes = ["junit", "java", "testng", "batchtest"];
        let coverageNode = ccc.jacocoAntCoverageEnable(_this.reportDir);

        if (!str(_this.includeFilter).isEmpty()) {
            coverageNode.$.includes = _this.includeFilterExec;
        }
        if (!str(_this.excludeFilter).isEmpty()) {
            coverageNode.$.excludes = _this.excludeFilterExec;
        }

        if (targetNode.javac) {
            if (targetNode.javac instanceof Array) {
                targetNode.javac.forEach(jn => {
                    jn.$.debug = "true";
                });
            }
        }

        testNodes.forEach(tn => {
            if (!targetNode[tn]) {
                return;
            }
            _this.enableForkOnTestNodes(targetNode[tn], true);
            coverageNode[tn] = targetNode[tn];
            delete targetNode[tn];
            targetNode["jacoco:coverage"] = coverageNode;
        });
    }
    // -----------------------------------------------------
    // Enable code coverage for Cobertura Ant Builds
    // - enableCodeCoverage: CodeCoverageProperties  - ccProps
    // -----------------------------------------------------    
    public enableCodeCoverage(ccProps: { [name: string]: string }): Q.Promise<boolean> {
        let _this = this;

        tl.debug("Input parameters: " + JSON.stringify(ccProps));

        _this.reportDir = "CCReport43F6D5EF";
        _this.reportbuildfile = "CCReportBuildA4D283EG.xml";
        _this.buildFile = ccProps["buildfile"];
        let classFilter = ccProps["classfilter"];
        let srcDirs = ccProps["sourcedirectories"];
        if (str(srcDirs).isEmpty()) {
            srcDirs = ".";
        }
        _this.sourceDirs = srcDirs;
        _this.classDirs = ccProps["classfilesdirectories"];

        let filter = _this.extractFilters(classFilter);
        _this.excludeFilter = _this.applyFilterPattern(filter.excludeFilter).join(",");
        _this.includeFilter = _this.applyFilterPattern(filter.includeFilter).join(",");

        tl.debug("Reading the build file: " + _this.buildFile);

        let buildContent = util.readXmlFileAsDom(_this.buildFile);
        return _this.addCodeCoverageData(buildContent)
            .thenResolve(true);
    }
    protected createMultiModuleReport(reportDir: string): Q.Promise<any> {
        let _this = this;
        let srcDirs = _this.sourceDirs;
        let classDirs = _this.classDirs;
        let includeFilter = _this.includeFilter.join(",");
        let excludeFilter = _this.excludeFilter.join(",");

        if (str(srcDirs).isEmpty()) {
            srcDirs = ".";
        }
        if (str(classDirs).isEmpty()) {
            classDirs = ".";
        }

        return util.writeFile(_this.reportBuildFile, ccc.jacocoMavenMultiModuleReport(reportDir, srcDirs, classDirs, includeFilter, excludeFilter));
    }
Beispiel #4
0
export function writeJsonAsXmlFile(filePath: string, jsonContent: any): Q.Promise<void> {
    let builder = new xml2js.Builder();
    tl.debug("Writing JSON as XML file: " + filePath);
    let xml = builder.buildObject(jsonContent);
    xml = str(xml).replaceAll("&#xD;", "").s;
    return writeFile(filePath, xml);
}
 toView(rgbInt: number)
 {
     if(rgbInt == null){
         return null;
     }
     
     var hex=rgbInt.toString(16);
     hex = S(hex).padLeft(6,'0');
     return '#'+hex;        
 }
export function coberturaMavenEnable(includeFilter: string, excludeFilter: string, aggregate: string): Q.Promise<any> {
    let includeTag = "";
    let excludeTag = "";
    if (!str(excludeFilter).isEmpty()) {
        excludeFilter.split(",").forEach(ex => {
            excludeTag += `<exclude>${ex}</exclude>` + os.EOL;
        });
    }
    if (!str(includeFilter).isEmpty()) {
        includeFilter.split(",").forEach(ex => {
            includeTag += `<include>${ex}</include>` + os.EOL;
        });
    }

    let ccProperty = `
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.7</version>
        <configuration>
          <formats>
            <format>xml</format>
            <format>html</format>
          </formats>
          <instrumentation>
            <includes>${includeTag}</includes>
            <excludes>${excludeTag}</excludes>
          </instrumentation>
          <aggregate>${aggregate}</aggregate>
        </configuration>
        <executions>
          <execution>
            <id>package-9af52907-6506-4b87-b16a-9883edee41bc</id>
            <goals>
              <goal>cobertura</goal>
            </goals>
            <phase>package</phase>
          </execution>
        </executions>
    </plugin>
  `;
    return util.convertXmlStringToJson(ccProperty);
};
Beispiel #7
0
export function trimEnd(data: string, trimChar: string) {
    if (!trimChar || !data) {
        return data;
    }

    if (str(data).endsWith(trimChar)) {
        return data.substring(0, data.length - trimChar.length);
    } else {
        return data;
    }
}
 protected getClassData(): string {
     let classData = "";
     this.classDirs.split(",").forEach(dir => {
         classData += `<fileset dir='${dir}' includes="${this.includeFilter}"  excludes="${this.excludeFilter}" />`;
         classData += os.EOL;
     });
     if (str(classData).isEmpty()) {
         classData += `<fileset dir='.'${this.includeFilter} ${this.excludeFilter} />`;
         classData += os.EOL;
     }
     return classData;
 }
    protected applyFilterPattern(filter: string): string[] {
        let ccfilter = [];

        if (!util.isNullOrWhitespace(filter)) {
            str(util.trimToEmptyString(filter)).replaceAll(".", "/").s.split(":").forEach(exFilter => {
                if (exFilter) {
                    ccfilter.push(str(exFilter).endsWith("*") ? ("**/" + exFilter + "/**") : ("**/" + exFilter + ".class"));
                }
            });
        }

        tl.debug("Applying the filter pattern: " + filter + " op: " + ccfilter);
        return ccfilter;
    }
 protected getSourceFilter(): string {
     let srcData = "";
     this.sourceDirs.split(",").forEach(dir => {
         if (!str(dir).isEmpty()) {
             srcData += `<fileset dir='${dir}'/>`;
             srcData += os.EOL;
         }
     });
     if (str(srcData).isEmpty()) {
         srcData = `<fileset dir='.'/>`;
         srcData += os.EOL;
     }
     return srcData;
 }