MPJCOVERAGE-8. Fixed report generation fails when no java source present.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115416 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -159,60 +159,67 @@
|
||||
description="Generate HTML test coverage reports with JCoverage"
|
||||
prereqs="jcoverage:on,test:test">
|
||||
|
||||
<j:catch var="ex">
|
||||
|
||||
<j:set var="sourceDir" value="${context.getAntProject().getReferences().get('maven.compile.src.set')}" />
|
||||
<u:tokenize var="sourceDirList" delim="${path.separator}">${sourceDir}</u:tokenize>
|
||||
<j:if test="${size(sourceDirList) != 1}">
|
||||
<!-- Copy multiple source directories to one: jcoverage doesn't handle multiple source directories -->
|
||||
<echo>Copying ${size(sourceDirList)} source directories into one for jcoverage</echo>
|
||||
<j:set var="sourceDir" value="${maven.jcoverage.dir}/sources" />
|
||||
<ant:copy todir="${sourceDir}">
|
||||
<j:forEach var="dir" items="${sourceDirList}">
|
||||
<ant:fileset dir="${dir}" />
|
||||
</j:forEach>
|
||||
</ant:copy>
|
||||
</j:if>
|
||||
|
||||
<j:set var="template" value="${maven.jcoverage.report.template}"/>
|
||||
<j:choose>
|
||||
<j:when test="${template == 'jcoverage'}">
|
||||
<report srcdir="${sourceDir}" destdir="${maven.coverage.dir}">
|
||||
<ant:classpath>
|
||||
<ant:path refid="jcoverage.classpath"/>
|
||||
</ant:classpath>
|
||||
</report>
|
||||
<j:choose>
|
||||
<j:when test="${unitTestSourcesPresent == 'true'}">
|
||||
<j:catch var="ex">
|
||||
|
||||
<log:info>jcoverage reports have been generated.</log:info>
|
||||
<log:info>The HTML report is ${maven.build.coverage.dir}/index.html</log:info>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
<report srcdir="${sourceDir}" destdir="${maven.jcoverage.dir}" format="xml">
|
||||
<ant:classpath>
|
||||
<ant:path refid="jcoverage.classpath"/>
|
||||
</ant:classpath>
|
||||
</report>
|
||||
<j:set var="stylesheet" value="${maven.jcoverage.report.stylesheet}"/>
|
||||
<ant:copy file="${stylesheet}" tofile="${maven.coverage.dir}/style.css"/>
|
||||
<jcoverage:report
|
||||
dataFile="${maven.jcoverage.dir}/coverage.xml"
|
||||
outputDir="${maven.coverage.dir}"/>
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
|
||||
<!--
|
||||
restore the maven.junit.fork property
|
||||
-->
|
||||
${pom.getPluginContext('maven-test-plugin').setVariable('maven.junit.fork', oldfork)}
|
||||
<!--
|
||||
restore the maven.build.dest property
|
||||
-->
|
||||
${pom.getPluginContext('maven-test-plugin').setVariable('maven.build.dest', oldBuildDest)}
|
||||
</j:catch>
|
||||
<j:if test="${ex != null}">
|
||||
<log:error>${ex}</log:error>
|
||||
<ant:fail message="${ex}" />
|
||||
</j:if>
|
||||
<j:set var="sourceDir" value="${context.getAntProject().getReferences().get('maven.compile.src.set')}" />
|
||||
<u:tokenize var="sourceDirList" delim="${path.separator}">${sourceDir}</u:tokenize>
|
||||
<j:if test="${size(sourceDirList) != 1}">
|
||||
<!-- Copy multiple source directories to one: jcoverage doesn't handle multiple source directories -->
|
||||
<echo>Copying ${size(sourceDirList)} source directories into one for jcoverage</echo>
|
||||
<j:set var="sourceDir" value="${maven.jcoverage.dir}/sources" />
|
||||
<ant:copy todir="${sourceDir}">
|
||||
<j:forEach var="dir" items="${sourceDirList}">
|
||||
<ant:fileset dir="${dir}" />
|
||||
</j:forEach>
|
||||
</ant:copy>
|
||||
</j:if>
|
||||
|
||||
<j:set var="template" value="${maven.jcoverage.report.template}"/>
|
||||
<j:choose>
|
||||
<j:when test="${template == 'jcoverage'}">
|
||||
<report srcdir="${sourceDir}" destdir="${maven.coverage.dir}">
|
||||
<ant:classpath>
|
||||
<ant:path refid="jcoverage.classpath"/>
|
||||
</ant:classpath>
|
||||
</report>
|
||||
|
||||
<log:info>jcoverage reports have been generated.</log:info>
|
||||
<log:info>The HTML report is ${maven.build.coverage.dir}/index.html</log:info>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
<report srcdir="${sourceDir}" destdir="${maven.jcoverage.dir}" format="xml">
|
||||
<ant:classpath>
|
||||
<ant:path refid="jcoverage.classpath"/>
|
||||
</ant:classpath>
|
||||
</report>
|
||||
<j:set var="stylesheet" value="${maven.jcoverage.report.stylesheet}"/>
|
||||
<ant:copy file="${stylesheet}" tofile="${maven.coverage.dir}/style.css"/>
|
||||
<jcoverage:report
|
||||
dataFile="${maven.jcoverage.dir}/coverage.xml"
|
||||
outputDir="${maven.coverage.dir}"/>
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
|
||||
<!--
|
||||
restore the maven.junit.fork property
|
||||
-->
|
||||
${pom.getPluginContext('maven-test-plugin').setVariable('maven.junit.fork', oldfork)}
|
||||
<!--
|
||||
restore the maven.build.dest property
|
||||
-->
|
||||
${pom.getPluginContext('maven-test-plugin').setVariable('maven.build.dest', oldBuildDest)}
|
||||
</j:catch>
|
||||
<j:if test="${ex != null}">
|
||||
<log:error>${ex}</log:error>
|
||||
<ant:fail message="${ex}" />
|
||||
</j:if>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
<ant:echo>No tests to run JCoverage on.</ant:echo>
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
|
||||
</goal>
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
</properties>
|
||||
<body>
|
||||
<release version="1.0.5-SNAPSHOT" date="in CVS">
|
||||
<action dev="evenisse" type="fix" issue="MPJCOVERAGE-8">Fixed report generation fails when no java source present.</action>
|
||||
<action dev="brett" type="fix" issue="MPJCOVERAGE-1">Handle multiple source directories correctly</action>
|
||||
<action dev="brett" type="fix">Copy all of maven.build.dest, excluding the class files, into the instrumentation directory, as some people hook into the resources copying themselves without adding them to the POM</action>
|
||||
</release>
|
||||
|
||||
Reference in New Issue
Block a user