PR: 14849 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274387 13f79535-47bb-0310-9956-ffa450edef68master
@@ -216,6 +216,8 @@ Other changes: | |||||
<exclude> elements can be used to exclude certain packages from | <exclude> elements can be used to exclude certain packages from | ||||
being parsed. Bugzilla Report 17134. | being parsed. Bugzilla Report 17134. | ||||
* The JProbe tasks now also work with JProbe 4.x. Bugzilla Report 14849. | |||||
Changes from Ant 1.5.2 to Ant 1.5.3 | Changes from Ant 1.5.2 to Ant 1.5.3 | ||||
=================================== | =================================== | ||||
@@ -56,6 +56,7 @@ package org.apache.tools.ant.taskdefs.optional.sitraka; | |||||
import java.io.File; | import java.io.File; | ||||
import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
import org.apache.tools.ant.taskdefs.condition.Os; | |||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
/** | /** | ||||
@@ -68,6 +69,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
public abstract class CovBase extends Task { | public abstract class CovBase extends Task { | ||||
private File home; | private File home; | ||||
private static FileUtils fu = FileUtils.newFileUtils(); | private static FileUtils fu = FileUtils.newFileUtils(); | ||||
private boolean isJProbe4 = false; | |||||
private static boolean isDos = Os.isFamily("dos"); | |||||
/** | /** | ||||
* The directory where JProbe is installed. | * The directory where JProbe is installed. | ||||
@@ -80,12 +83,43 @@ public abstract class CovBase extends Task { | |||||
return home; | return home; | ||||
} | } | ||||
protected File findJar(String relativePath) { | |||||
return fu.resolveFile(home, relativePath); | |||||
protected File findCoverageJar() { | |||||
File loc = null; | |||||
if (isJProbe4) { | |||||
loc = fu.resolveFile(home, "lib/coverage.jar"); | |||||
} else { | |||||
loc = fu.resolveFile(home, "coverage/coverage.jar"); | |||||
if (!loc.canRead()) { | |||||
File newLoc = fu.resolveFile(home, "lib/coverage.jar"); | |||||
if (newLoc.canRead()) { | |||||
isJProbe4 = true; | |||||
loc = newLoc; | |||||
} | |||||
} | |||||
} | |||||
return loc; | |||||
} | } | ||||
protected String findExecutable(String relativePath) { | protected String findExecutable(String relativePath) { | ||||
return fu.resolveFile(home, relativePath).getAbsolutePath(); | |||||
if (isDos) { | |||||
relativePath += ".exe"; | |||||
} | |||||
File loc = null; | |||||
if (isJProbe4) { | |||||
loc = fu.resolveFile(home, "bin/" + relativePath); | |||||
} else { | |||||
loc = fu.resolveFile(home, relativePath); | |||||
if (!loc.canRead()) { | |||||
File newLoc = fu.resolveFile(home, "bin/" + relativePath); | |||||
if (newLoc.canRead()) { | |||||
isJProbe4 = true; | |||||
loc = newLoc; | |||||
} | |||||
} | |||||
} | |||||
return loc.getAbsolutePath(); | |||||
} | } | ||||
protected File createTempFile(String prefix) { | protected File createTempFile(String prefix) { | ||||
@@ -93,6 +127,6 @@ public abstract class CovBase extends Task { | |||||
} | } | ||||
protected String getParamFileArgument() { | protected String getParamFileArgument() { | ||||
return "-jp_paramfile="; | |||||
return (!isJProbe4 ? "-jp_" : "") + "paramfile="; | |||||
} | } | ||||
} | } |
@@ -154,7 +154,7 @@ public class CovMerge extends CovBase { | |||||
if (getHome() == null || !getHome().isDirectory()) { | if (getHome() == null || !getHome().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"); | ||||
} | } | ||||
File jar = findJar("coverage/coverage.jar"); | |||||
File jar = findCoverageJar(); | |||||
if (!jar.exists()) { | if (!jar.exists()) { | ||||
throw new BuildException("Cannot find Coverage directory: " + getHome()); | throw new BuildException("Cannot find Coverage directory: " + getHome()); | ||||
} | } | ||||
@@ -271,7 +271,7 @@ public class CovReport extends CovBase { | |||||
if (getHome() == null) { | if (getHome() == 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"); | ||||
} | } | ||||
File jar = findJar("coverage/coverage.jar"); | |||||
File jar = findCoverageJar(); | |||||
if (!jar.exists()) { | if (!jar.exists()) { | ||||
throw new BuildException("Cannot find Coverage directory: " + getHome()); | throw new BuildException("Cannot find Coverage directory: " + getHome()); | ||||
} | } | ||||
@@ -351,7 +351,7 @@ public class Coverage extends CovBase { | |||||
if (getHome() == null || !getHome().isDirectory()) { | if (getHome() == null || !getHome().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"); | ||||
} | } | ||||
File jar = findJar("coverage/coverage.jar"); | |||||
File jar = findCoverageJar(); | |||||
if (!jar.exists()) { | if (!jar.exists()) { | ||||
throw new BuildException("Cannot find Coverage directory: " + getHome()); | throw new BuildException("Cannot find Coverage directory: " + getHome()); | ||||
} | } | ||||