Merge branch 'master' of git@github.com:rzwitserloot/lombok

This commit is contained in:
Roel Spilker committed 2010-02-14 03:50:39 +01:00
commit 5f276b6209
7 files changed
+56 -19

No files matched your search

+1
View File
@@ -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)
Binary file not shown.
@@ -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;
@@ -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.")
+54 -11
View File
@@ -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
}
return findToolsJarViaProperties();
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 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;
}
@@ -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>();
+1
View File
@@ -51,6 +51,7 @@
&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
&lt;artifactId&gt;lombok&lt;/artifactId&gt;
&lt;version&gt;@VERSION@&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;repositories&gt;