diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-11-28 09:42:51 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-11-28 09:42:51 +0100 |
commit | 96d83a55e44e6e574d42db4d72b23e0afe39fa79 (patch) | |
tree | 1f9b48ed726bd59a9884f0cd8f2ef08c9cbd4028 | |
parent | e9ae8b0c37e1346a010db8cae0e648039944630c (diff) | |
download | lombok-96d83a55e44e6e574d42db4d72b23e0afe39fa79.tar.gz lombok-96d83a55e44e6e574d42db4d72b23e0afe39fa79.tar.bz2 lombok-96d83a55e44e6e574d42db4d72b23e0afe39fa79.zip |
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).
3 files changed, 13 insertions, 15 deletions
diff --git a/src/core/lombok/core/handlers/SneakyThrowsDependencyInfo.java b/src/core/lombok/core/handlers/SneakyThrowsDependencyInfo.java index 1b860f6d..20615183 100644 --- a/src/core/lombok/core/handlers/SneakyThrowsDependencyInfo.java +++ b/src/core/lombok/core/handlers/SneakyThrowsDependencyInfo.java @@ -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" ); } diff --git a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java index 6f39082e..3a83bea1 100644 --- a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java +++ b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java @@ -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(); diff --git a/src/core/lombok/core/runtimeDependencies/RuntimeDependencyInfo.java b/src/core/lombok/core/runtimeDependencies/RuntimeDependencyInfo.java index e83332c8..63c04fca 100644 --- a/src/core/lombok/core/runtimeDependencies/RuntimeDependencyInfo.java +++ b/src/core/lombok/core/runtimeDependencies/RuntimeDependencyInfo.java @@ -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(); |