diff options
-rw-r--r-- | doc/changelog.markdown | 1 | ||||
-rw-r--r-- | lib/lombok/com.zwitserloot.cmdreader.jar | bin | 19507 -> 19082 bytes | |||
-rw-r--r-- | src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java | 2 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/Delombok.java | 4 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/DelombokApp.java | 65 | ||||
-rw-r--r-- | src/installer/lombok/installer/Installer.java | 2 | ||||
-rw-r--r-- | website/mavenrepo/index.html | 1 |
7 files changed, 56 insertions, 19 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown index e09b9c33..a63759ef 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -6,6 +6,7 @@ Lombok Changelog * Eclipse: `@Data` and other annotations now don't throw errors when you include fields with bounded wildcard generics, such as `List<? extends Number>`. [Issue #84](http://code.google.com/p/projectlombok/issues/detail?id=84) * plugins and `@SneakyThrows`: Resolving types in annotations now works better especially for classes that aren't in the core java libraries. [Issue #88](http://code.google.com/p/projectlombok/issues/detail?id=88) * BUGFIX: complex enums didn't get delomboked properly. [Issue #96](http://code.google.com/p/projectlombok/issues/detail?id=96) +* FEATURE: If `tools.jar` isn't found (required when running _delombok_), now a useful error message is generated. The search for `tools.jar` now also looks in `JAVA_HOME`. ### v0.9.2 "Hailbunny" (December 15th, 2009) * preliminary support for lombok on NetBeans! - thanks go to Jan Lahoda from NetBeans. [Issue #20](http://code.google.com/p/projectlombok/issues/detail?id=20) diff --git a/lib/lombok/com.zwitserloot.cmdreader.jar b/lib/lombok/com.zwitserloot.cmdreader.jar Binary files differindex dade537a..7eb37b5a 100644 --- a/lib/lombok/com.zwitserloot.cmdreader.jar +++ b/lib/lombok/com.zwitserloot.cmdreader.jar diff --git a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java index f30ff761..cac327d1 100644 --- a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java +++ b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java @@ -45,7 +45,6 @@ import com.zwitserloot.cmdreader.CmdReader; import com.zwitserloot.cmdreader.Description; import com.zwitserloot.cmdreader.InvalidCommandLineException; import com.zwitserloot.cmdreader.Mandatory; -import com.zwitserloot.cmdreader.Parameterized; import com.zwitserloot.cmdreader.Requires; import com.zwitserloot.cmdreader.Shorthand; @@ -81,7 +80,6 @@ public class CreateLombokRuntimeApp implements LombokApp { @Shorthand("o") @Description("Where to write the lombok-runtime.jar. Defaults to the current working directory.") - @Parameterized @Requires("create") String output; diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 943136cf..b38d3ef5 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -44,7 +44,6 @@ import com.zwitserloot.cmdreader.Description; import com.zwitserloot.cmdreader.Excludes; import com.zwitserloot.cmdreader.InvalidCommandLineException; import com.zwitserloot.cmdreader.Mandatory; -import com.zwitserloot.cmdreader.Parameterized; import com.zwitserloot.cmdreader.Sequential; import com.zwitserloot.cmdreader.Shorthand; @@ -72,7 +71,6 @@ public class Delombok { @Shorthand("e") @Description("Sets the encoding of your source files. Defaults to the system default charset. Example: \"UTF-8\"") - @Parameterized private String encoding; @Shorthand("p") @@ -82,12 +80,10 @@ public class Delombok { @Shorthand("d") @Description("Directory to save delomboked files to") @Mandatory(onlyIfNot={"print", "help"}) - @Parameterized private String target; @Description("Files to delombok. Provide either a file, or a directory. If you use a directory, all files in it (recursive) are delombok-ed") @Sequential - @Parameterized private List<String> input = new ArrayList<String>(); @Description("Lombok will only delombok source files. Without this option, non-java, non-class files are copied to the target directory.") diff --git a/src/delombok/lombok/delombok/DelombokApp.java b/src/delombok/lombok/delombok/DelombokApp.java index b48337c8..f129704a 100644 --- a/src/delombok/lombok/delombok/DelombokApp.java +++ b/src/delombok/lombok/delombok/DelombokApp.java @@ -10,6 +10,7 @@ import java.net.URL; import java.util.Arrays; import java.util.Enumeration; import java.util.List; +import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -25,13 +26,12 @@ public class DelombokApp implements LombokApp { runDirectly(args); return 0; } catch (ClassNotFoundException e) { - Class<?> delombokClass = loadDelombok(); + Class<?> delombokClass = loadDelombok(args); if (delombokClass == null) { - System.err.println("Can't find tools.jar. Rerun delombok with tools.jar on the classpath."); return 1; } try { - loadDelombok().getMethod("main", String[].class).invoke(null, new Object[] {args.toArray(new String[0])}); + loadDelombok(args).getMethod("main", String[].class).invoke(null, new Object[] {args.toArray(new String[0])}); } catch (InvocationTargetException e1) { Throwable t = e1.getCause(); if (t instanceof Error) throw (Error)t; @@ -42,11 +42,24 @@ public class DelombokApp implements LombokApp { } } - public static Class<?> loadDelombok() throws Exception { + public static Class<?> loadDelombok(List<String> args) throws Exception { //tools.jar is probably not on the classpath. We're going to try and find it, and then load the rest via a ClassLoader that includes tools.jar. final File toolsJar = findToolsJar(); if (toolsJar == null) { - System.err.println("Can't find tools.jar. Rerun delombok with tools.jar on the classpath."); + String examplePath = "/path/to/tools.jar"; + if (File.separator.equals("\\")) examplePath = "C:\\path\\to\\tools.jar"; + StringBuilder sb = new StringBuilder(); + for (String arg : args) { + if (sb.length() > 0) sb.append(' '); + if (arg.contains(" ")) { + sb.append('"').append(arg).append('"'); + } else { + sb.append(arg); + } + } + + System.err.printf("Can't find tools.jar. Rerun delombok as: java -cp lombok.jar%1$s%2$s lombok.core.Main delombok %3$s\n", + File.pathSeparator, examplePath, sb.toString()); return null; } @@ -136,20 +149,50 @@ public class DelombokApp implements LombokApp { try { File toolsJar = findToolsJarViaRT(); if (toolsJar != null) return toolsJar; - } catch (Throwable ignore) {} + } catch (Throwable ignore) { + //fallthrough + } + + try { + File toolsJar = findToolsJarViaProperties(); + if (toolsJar != null) return toolsJar; + } catch (Throwable ignore) { + //fallthrough + } + + try { + File toolsJar = findToolsJarViaEnvironment(); + return toolsJar; + } catch (Throwable ignore) { + //fallthrough + } + + return null; + } + + private static File findToolsJarViaEnvironment() { + for (Map.Entry<String, String> s : System.getenv().entrySet()) { + if ("JAVA_HOME".equalsIgnoreCase(s.getKey())) { + return extensiveCheckToolsJar(new File(s.getValue())); + } + } - return findToolsJarViaProperties(); + return null; } private static File findToolsJarViaProperties() { File home = new File(System.getProperty("java.home", ".")); - File toolsJar = checkToolsJar(home); + return extensiveCheckToolsJar(home); + } + + private static File extensiveCheckToolsJar(File base) { + File toolsJar = checkToolsJar(base); if (toolsJar != null) return toolsJar; - toolsJar = checkToolsJar(new File(home, "lib")); + toolsJar = checkToolsJar(new File(base, "lib")); if (toolsJar != null) return toolsJar; - toolsJar = checkToolsJar(new File(home.getParentFile(), "lib")); + toolsJar = checkToolsJar(new File(base.getParentFile(), "lib")); if (toolsJar != null) return toolsJar; - toolsJar = checkToolsJar(new File(new File(home, "jdk"), "lib")); + toolsJar = checkToolsJar(new File(new File(base, "jdk"), "lib")); if (toolsJar != null) return toolsJar; return null; } diff --git a/src/installer/lombok/installer/Installer.java b/src/installer/lombok/installer/Installer.java index 7700cd90..6ce8efdb 100644 --- a/src/installer/lombok/installer/Installer.java +++ b/src/installer/lombok/installer/Installer.java @@ -44,7 +44,6 @@ import org.mangosdk.spi.ProviderFor; import com.zwitserloot.cmdreader.CmdReader; import com.zwitserloot.cmdreader.Description; import com.zwitserloot.cmdreader.InvalidCommandLineException; -import com.zwitserloot.cmdreader.Parameterized; import com.zwitserloot.cmdreader.Sequential; import com.zwitserloot.cmdreader.Shorthand; @@ -196,7 +195,6 @@ public class Installer { private static class CmdArgs { @Description("Specify paths to a location to install/uninstall. Use 'auto' to apply to all automatically discoverable installations.") - @Parameterized @Sequential List<String> path = new ArrayList<String>(); diff --git a/website/mavenrepo/index.html b/website/mavenrepo/index.html index ea7b8715..6b8ea48d 100644 --- a/website/mavenrepo/index.html +++ b/website/mavenrepo/index.html @@ -51,6 +51,7 @@ <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>@VERSION@</version> + <scope>provided</scope> </dependency> </dependencies> <repositories> |