The delombok task now works!

This commit is contained in:
Reinier Zwitserloot committed 2009-11-27 14:08:50 +01:00
1 parent 4eaf936df5
commit 3919e192f1
3 files changed
+51 -14

No files matched your search

+15 -9
View File
@@ -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);
}
}
@@ -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());
}
}
}
+13
View File
@@ -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>