diff --git a/pmd/etc/doing_the_next_pmd_release.txt b/pmd/etc/doing_the_next_pmd_release.txt index 40c8c14690..306f3f4c0f 100644 --- a/pmd/etc/doing_the_next_pmd_release.txt +++ b/pmd/etc/doing_the_next_pmd_release.txt @@ -1,3 +1,4 @@ +--------> Update ant docs - remove verbose attribute and make a note about -verbose update run.bat to point to pmd-1.05.jar update run.sh to point to pmd-1.05.jar update cpdgui.bat to point to pmd-1.05.jar diff --git a/pmd/regress/test/net/sourceforge/pmd/ant/FormatterTest.java b/pmd/regress/test/net/sourceforge/pmd/ant/FormatterTest.java index 29b08197f5..db6373d32c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/ant/FormatterTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/ant/FormatterTest.java @@ -7,6 +7,8 @@ import net.sourceforge.pmd.renderers.TextRenderer; import net.sourceforge.pmd.renderers.XMLRenderer; import org.apache.tools.ant.BuildException; +import java.io.File; + public class FormatterTest extends TestCase { public void testType() { @@ -28,7 +30,7 @@ public class FormatterTest extends TestCase { public void testNull() { Formatter f = new Formatter(); assertTrue("Formatter toFile should start off null!", f.isToFileNull()); - f.setToFile("foo"); + f.setToFile(new File("foo")); assertFalse("Formatter toFile should not be null!", f.isToFileNull()); } diff --git a/pmd/regress/test/net/sourceforge/pmd/ant/PathCheckerTest.java b/pmd/regress/test/net/sourceforge/pmd/ant/PathCheckerTest.java deleted file mode 100644 index 8b38fa5658..0000000000 --- a/pmd/regress/test/net/sourceforge/pmd/ant/PathCheckerTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.net.sourceforge.pmd.ant; - -import junit.framework.TestCase; -import net.sourceforge.pmd.ant.PathChecker; - -public class PathCheckerTest extends TestCase { - - public void testPathCheckerRelativeWin() { - PathChecker pc = new PathChecker("Windows XP"); - assertTrue(!pc.isAbsolute("foo\\bar.html")); - } - - public void testPathCheckerAbsoluteWin() { - PathChecker pc = new PathChecker("Windows XP"); - assertTrue(pc.isAbsolute("c:\\foo\\bar.html")); - } - - public void testPathCheckerRelativeNix() { - PathChecker pc = new PathChecker("Linux"); - assertTrue(!pc.isAbsolute("foo/bar.html")); - } - - public void testPathCheckerAbsoluteNix() { - PathChecker pc = new PathChecker("Linux"); - assertTrue(pc.isAbsolute("/var/www/html/report.html")); - } - -} diff --git a/pmd/src/net/sourceforge/pmd/ant/Formatter.java b/pmd/src/net/sourceforge/pmd/ant/Formatter.java index ad3c4e0d74..2f845d94ec 100644 --- a/pmd/src/net/sourceforge/pmd/ant/Formatter.java +++ b/pmd/src/net/sourceforge/pmd/ant/Formatter.java @@ -15,7 +15,7 @@ import java.io.Writer; public class Formatter { private Renderer renderer; - private String toFile; + private File toFile; public void setType(String type) { if (type.equals("xml")) { @@ -36,7 +36,7 @@ public class Formatter { } } - public void setToFile(String toFile) { + public void setToFile(File toFile) { this.toFile = toFile; } @@ -45,15 +45,17 @@ public class Formatter { } public boolean isToFileNull() { - return this.toFile == null; + return toFile == null; } public Writer getToFileWriter(String baseDir) throws IOException { - String outFile = toFile; - PathChecker pc = new PathChecker(System.getProperty("os.name")); - if (!pc.isAbsolute(toFile)) { - outFile = baseDir + System.getProperty("file.separator") + toFile; + if (!toFile.isAbsolute()) { + return new BufferedWriter(new FileWriter(new File(baseDir + System.getProperty("file.separator") + toFile.getPath()))); } - return new BufferedWriter(new FileWriter(new File(outFile))); + return new BufferedWriter(new FileWriter(toFile)); + } + + public String toString() { + return "file = " + toFile + "; renderer = " + renderer.getClass().getName(); } } diff --git a/pmd/src/net/sourceforge/pmd/ant/PMDTask.java b/pmd/src/net/sourceforge/pmd/ant/PMDTask.java index 155d61de4a..8fb65262fe 100644 --- a/pmd/src/net/sourceforge/pmd/ant/PMDTask.java +++ b/pmd/src/net/sourceforge/pmd/ant/PMDTask.java @@ -131,6 +131,7 @@ public class PMDTask extends Task { if (!ctx.getReport().isEmpty()) { for (Iterator i = formatters.iterator(); i.hasNext();) { Formatter formatter = (Formatter) i.next(); + log("Sending a report to " + formatter, Project.MSG_VERBOSE); String buffer = formatter.getRenderer().render(ctx.getReport()) + EOL; try { Writer writer = formatter.getToFileWriter(project.getBaseDir().toString()); diff --git a/pmd/src/net/sourceforge/pmd/ant/PathChecker.java b/pmd/src/net/sourceforge/pmd/ant/PathChecker.java deleted file mode 100644 index 92dbeeb9a7..0000000000 --- a/pmd/src/net/sourceforge/pmd/ant/PathChecker.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.sourceforge.pmd.ant; - -public class PathChecker { - - private boolean isWindowsVariant; - - public PathChecker(String osNameProperty) { - isWindowsVariant = osNameProperty.toLowerCase().indexOf("windows") != -1; - } - - public boolean isAbsolute(String path) { - if (!isWindowsVariant) { - return path.charAt(0) == '/'; - } - return path.charAt(1) == ':'; - } -}