diff options
-rw-r--r-- | src/delombok/lombok/delombok/Delombok.java | 24 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/ant/DelombokTask.java | 28 | ||||
-rw-r--r-- | test/delombok/resource/anttest.xml | 13 |
3 files changed, 51 insertions, 14 deletions
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 990267a2..2daa9af7 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -203,9 +203,22 @@ public class Delombok { delombok0(base, "", 0); } + public void process(File base, String name) throws IOException { + File f = new File(base, name); + if (f.isFile()) { + String extension = getExtension(f); + if (extension.equals("java")) delombok(base, name); + else if (extension.equals("class")) skipClass(name); + else copy(base, name); + } else if (!f.exists()) { + feedback.printf("Skipping %s because it does not exist.\n", canonical(f)); + } else if (!f.isDirectory()) { + feedback.printf("Skipping %s because it is a special file type.\n", canonical(f)); + } + } + private void delombok0(File base, String suffix, int loop) throws IOException { File dir = suffix.isEmpty() ? base : new File(base, suffix); - String name = suffix; if (dir.isDirectory()) { if (loop >= 100) { @@ -215,15 +228,8 @@ public class Delombok { delombok0(base, suffix + (suffix.isEmpty() ? "" : File.separator) + f.getName(), loop + 1); } } - } else if (dir.isFile()) { - String extension = getExtension(dir); - if (extension.equals("java")) delombok(base, name); - else if (extension.equals("class")) skipClass(name); - else copy(base, name); - } else if (!dir.exists()) { - feedback.printf("Skipping %s because it does not exist.\n", canonical(dir)); } else { - feedback.printf("Skipping %s because it is a special file type.\n", canonical(dir)); + process(base, suffix); } } diff --git a/src/delombok/lombok/delombok/ant/DelombokTask.java b/src/delombok/lombok/delombok/ant/DelombokTask.java index 89ea7c4d..7a674910 100644 --- a/src/delombok/lombok/delombok/ant/DelombokTask.java +++ b/src/delombok/lombok/delombok/ant/DelombokTask.java @@ -1,3 +1,24 @@ +/* + * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.delombok.ant; import java.io.File; @@ -64,12 +85,9 @@ public class DelombokTask extends Task { File baseDir = fileResource.getBaseDir(); if (baseDir == null) { File file = fileResource.getFile(); - System.out.printf("Processing raw file: %s\n", file); - delombok.delombok(file.getParentFile(), file.getName()); + delombok.process(file.getParentFile(), file.getName()); } else { - System.out.printf("Processing based file: %s -- %s\n", baseDir, fileResource.getName()); - delombok.delombok(baseDir, fileResource.getName()); - + delombok.process(baseDir, fileResource.getName()); } } } diff --git a/test/delombok/resource/anttest.xml b/test/delombok/resource/anttest.xml new file mode 100644 index 00000000..4372e094 --- /dev/null +++ b/test/delombok/resource/anttest.xml @@ -0,0 +1,13 @@ +<project name="testDelombokAntTask" basedir="../../.." default="test"> + <taskdef classname="lombok.delombok.ant.DelombokTask" classpath="dist/lombok.jar" name="delombok" /> + <target name="test"> + <mkdir dir="build/testResult" /> + <delombok verbose="true" encoding="UTF-8" to="build/testResult"> + <fileset dir="test/lombok/resource" /> + <fileset dir="test/delombok/resource" /> + </delombok> + </target> + <target name="clean"> + <delete quiet="true" dir="build/testResult" /> + </target> +</project> |