mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 00:16:47 +00:00
Made the createRuntime system more robust in the face of many different plugins. Also fixed an issue with the jar file containing a rooted name, which is generally a bad idea (/lombok/Lombok.class instead of lombok/Lombok.class).
This commit is contained in:
1 parent
e9ae8b0c37
commit
96d83a55e4
3 files changed
+13
-15
No files matched your search
@@ -32,7 +32,7 @@ import org.mangosdk.spi.ProviderFor;
|
||||
public class SneakyThrowsDependencyInfo implements RuntimeDependencyInfo {
|
||||
@Override public List<String> getRuntimeDependencies() {
|
||||
return Arrays.asList(
|
||||
"/lombok/Lombok.class"
|
||||
"lombok/Lombok.class"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,11 +146,11 @@ public class CreateLombokRuntimeApp implements LombokApp {
|
||||
}
|
||||
|
||||
private int writeRuntimeJar(File outFile) throws Exception {
|
||||
Map<Class<?>, List<String>> deps = new LinkedHashMap<Class<?>, List<String>>();
|
||||
Map<String, Class<?>> deps = new LinkedHashMap<String, Class<?>>();
|
||||
for (RuntimeDependencyInfo info : infoObjects) {
|
||||
List<String> depNames = info.getRuntimeDependencies();
|
||||
if (depNames != null && !depNames.isEmpty()) {
|
||||
deps.put(info.getClass(), depNames);
|
||||
if (depNames != null) for (String depName : depNames) {
|
||||
if (!deps.containsKey(depName)) deps.put(depName, info.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,17 +163,15 @@ public class CreateLombokRuntimeApp implements LombokApp {
|
||||
boolean success = false;
|
||||
try {
|
||||
JarOutputStream jar = new JarOutputStream(out);
|
||||
for (Entry<Class<?>, List<String>> dep : deps.entrySet()) {
|
||||
for (String depName : dep.getValue()) {
|
||||
InputStream in = dep.getKey().getResourceAsStream(depName);
|
||||
try {
|
||||
if (in == null) {
|
||||
throw new Fail(String.format("Dependency %s contributed by %s cannot be found", depName, dep.getKey().getName()));
|
||||
}
|
||||
writeIntoJar(jar, depName, in);
|
||||
} finally {
|
||||
if (in != null) in.close();
|
||||
for (Entry<String, Class<?>> dep : deps.entrySet()) {
|
||||
InputStream in = dep.getValue().getResourceAsStream("/" + dep.getKey());
|
||||
try {
|
||||
if (in == null) {
|
||||
throw new Fail(String.format("Dependency %s contributed by %s cannot be found", dep.getKey(), dep.getValue()));
|
||||
}
|
||||
writeIntoJar(jar, dep.getKey(), in);
|
||||
} finally {
|
||||
if (in != null) in.close();
|
||||
}
|
||||
}
|
||||
jar.close();
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface RuntimeDependencyInfo {
|
||||
public List<String> getRuntimeDependentsDescriptions();
|
||||
|
||||
/**
|
||||
* @return A list of files (findable via {@code yourClass.getResourceAsStream(NAME)}) to include in
|
||||
* @return A list of files (findable via {@code yourClass.getResourceAsStream("/" + NAME)}) to include in
|
||||
* {@code lombok-runtime.jar}.
|
||||
*/
|
||||
public List<String> getRuntimeDependencies();
|
||||
|
||||
Reference in new issue
Block a user