- SourceFile attribute does not always exists in the bytecode, so take care of it. PR: 5217 Submitted by: garrick.olson@aceva.com (Garrick Olson) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270060 13f79535-47bb-0310-9956-ffa450edef68master
@@ -160,7 +160,7 @@ public class CovMerge extends Task { | |||||
if (home == null || !home.isDirectory()) { | if (home == null || !home.isDirectory()) { | ||||
throw new BuildException("Invalid home directory. Must point to JProbe home directory"); | throw new BuildException("Invalid home directory. Must point to JProbe home directory"); | ||||
} | } | ||||
home = new File(home, "Coverage"); | |||||
home = new File(home, "coverage"); | |||||
File jar = new File(home, "coverage.jar"); | File jar = new File(home, "coverage.jar"); | ||||
if (!jar.exists()) { | if (!jar.exists()) { | ||||
throw new BuildException("Cannot find Coverage directory: " + home); | throw new BuildException("Cannot find Coverage directory: " + home); | ||||
@@ -207,16 +207,17 @@ public class CovMerge extends Task { | |||||
// last file is the output snapshot | // last file is the output snapshot | ||||
pw.println(project.resolveFile(tofile.getPath())); | pw.println(project.resolveFile(tofile.getPath())); | ||||
pw.flush(); | pw.flush(); | ||||
return file; | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new BuildException("I/O error while writing to " + file, e); | |||||
} finally { | |||||
if (fw != null) { | if (fw != null) { | ||||
try { | try { | ||||
fw.close(); | fw.close(); | ||||
} catch (IOException ignored) { | } catch (IOException ignored) { | ||||
} | } | ||||
} | } | ||||
throw new BuildException("I/O error while writing to " + file, e); | |||||
} | } | ||||
return file; | |||||
} | } | ||||
/** create a temporary file in the current dir (For JDK1.1 support) */ | /** create a temporary file in the current dir (For JDK1.1 support) */ | ||||
@@ -256,7 +256,7 @@ public class CovReport extends Task { | |||||
if (home == null) { | if (home == null) { | ||||
throw new BuildException("'home' attribute must be set to JProbe home directory"); | throw new BuildException("'home' attribute must be set to JProbe home directory"); | ||||
} | } | ||||
home = new File(home, "Coverage"); | |||||
home = new File(home, "coverage"); | |||||
File jar = new File(home, "coverage.jar"); | File jar = new File(home, "coverage.jar"); | ||||
if (!jar.exists()) { | if (!jar.exists()) { | ||||
throw new BuildException("Cannot find Coverage directory: " + home); | throw new BuildException("Cannot find Coverage directory: " + home); | ||||
@@ -297,7 +297,7 @@ public class Coverage extends Task { | |||||
if (home == null || !home.isDirectory()) { | if (home == null || !home.isDirectory()) { | ||||
throw new BuildException("Invalid home directory. Must point to JProbe home directory"); | throw new BuildException("Invalid home directory. Must point to JProbe home directory"); | ||||
} | } | ||||
home = new File(home, "Coverage"); | |||||
home = new File(home, "coverage"); | |||||
File jar = new File(home, "coverage.jar"); | File jar = new File(home, "coverage.jar"); | ||||
if (!jar.exists()) { | if (!jar.exists()) { | ||||
throw new BuildException("Cannot find Coverage directory: " + home); | throw new BuildException("Cannot find Coverage directory: " + home); | ||||
@@ -210,7 +210,7 @@ public class XMLReport { | |||||
DocumentBuilder dbuilder = newBuilder(); | DocumentBuilder dbuilder = newBuilder(); | ||||
InputSource is = new InputSource(new FileInputStream(file)); | InputSource is = new InputSource(new FileInputStream(file)); | ||||
if (jprobeHome != null) { | if (jprobeHome != null) { | ||||
File dtdDir = new File(jprobeHome, "Dtd"); | |||||
File dtdDir = new File(jprobeHome, "dtd"); | |||||
is.setSystemId("file:///" + dtdDir.getAbsolutePath() + "/"); | is.setSystemId("file:///" + dtdDir.getAbsolutePath() + "/"); | ||||
} | } | ||||
report = dbuilder.parse(is); | report = dbuilder.parse(is); | ||||
@@ -324,7 +324,10 @@ public class XMLReport { | |||||
// create the class element | // create the class element | ||||
Element classElem = report.createElement("class"); | Element classElem = report.createElement("class"); | ||||
classElem.setAttribute("name", classFile.getName()); | classElem.setAttribute("name", classFile.getName()); | ||||
classElem.setAttribute("source", classFile.getSourceFile()); | |||||
// source file possibly does not exist in the bytecode | |||||
if ( null != classFile.getSourceFile() ){ | |||||
classElem.setAttribute("source", classFile.getSourceFile()); | |||||
} | |||||
// create the cov.data elem | // create the cov.data elem | ||||
Element classData = report.createElement("cov.data"); | Element classData = report.createElement("cov.data"); | ||||
classElem.appendChild(classData); | classElem.appendChild(classData); | ||||