mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 14:16:11 +00:00
The classpath and bootclasspath params passed to delombok did not apply javac’s built-in * unglobbing. Now they do.
This commit is contained in:
1 parent
2cb1ef66fb
commit
6bc9912d26
1 file changed
+26
-2
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user