diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-11-28 23:39:57 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-11-29 04:06:23 +0100 |
commit | 6bc9912d2675fa790b50fefc75027bc2f39f5d58 (patch) | |
tree | 97e0f8497f7d49cb0e7ec4d57d12c3be4078aa2e /src/delombok | |
parent | 2cb1ef66fbb702153199a8b3270087c15162cb80 (diff) | |
download | lombok-6bc9912d2675fa790b50fefc75027bc2f39f5d58.tar.gz lombok-6bc9912d2675fa790b50fefc75027bc2f39f5d58.tar.bz2 lombok-6bc9912d2675fa790b50fefc75027bc2f39f5d58.zip |
The classpath and bootclasspath params passed to delombok did not apply javac’s built-in * unglobbing. Now they do.
Diffstat (limited to 'src/delombok')
-rw-r--r-- | src/delombok/lombok/delombok/Delombok.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 4e1f5a13..609590ec 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -46,6 +46,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; import javax.tools.DiagnosticListener; import javax.tools.JavaFileObject; @@ -487,9 +488,9 @@ public class Delombok { LombokOptions options = LombokOptionsFactory.getDelombokOptions(context); options.deleteLombokAnnotations(); options.putJavacOption("ENCODING", charset.name()); - if (classpath != null) options.putJavacOption("CLASSPATH", classpath); + if (classpath != null) options.putJavacOption("CLASSPATH", unpackClasspath(classpath)); if (sourcepath != null) options.putJavacOption("SOURCEPATH", sourcepath); - if (bootclasspath != null) options.putJavacOption("BOOTCLASSPATH", bootclasspath); + if (bootclasspath != null) options.putJavacOption("BOOTCLASSPATH", unpackClasspath(bootclasspath)); options.setFormatPreferences(new FormatPreferences(formatPrefs)); options.put("compilePolicy", "check"); @@ -570,6 +571,29 @@ public class Delombok { return true; } + private String unpackClasspath(String cp) { + String[] parts = cp.split(Pattern.quote(File.pathSeparator)); + StringBuilder out = new StringBuilder(); + for (String p : parts) { + if (!p.endsWith("*")) { + if (out.length() > 0) out.append(File.pathSeparator); + out.append(p); + continue; + } + File f = new File(p.substring(0, p.length() - 2)); + File[] files = f.listFiles(); + if (files == null) continue; + for (File file : files) { + if (file.isFile()) { + if (out.length() > 0) out.append(File.pathSeparator); + out.append(p, 0, p.length() - 1); + out.append(file.getName()); + } + } + } + return out.toString(); + } + private static Method attributeMethod; /** Method is needed because the call signature has changed between javac6 and javac7; no matter what we compile against, using delombok in the other means VerifyErrors. */ private static Object callAttributeMethodOnJavaCompiler(JavaCompiler compiler, Todo arg) { |