aboutsummaryrefslogtreecommitdiff
path: root/src/installer
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-11-27 13:54:14 +0100
committerReinier Zwitserloot <reinier@tipit.to>2009-11-27 13:54:14 +0100
commit8c7c764d7fcc2c6c37db38a3d77f5e6d1c7b87a7 (patch)
treebed204dc8cf8d432bcd2e3d93bad576bc320f12c /src/installer
parent60476317bc7d44edad63350253dc052432dea0ed (diff)
downloadlombok-8c7c764d7fcc2c6c37db38a3d77f5e6d1c7b87a7.tar.gz
lombok-8c7c764d7fcc2c6c37db38a3d77f5e6d1c7b87a7.tar.bz2
lombok-8c7c764d7fcc2c6c37db38a3d77f5e6d1c7b87a7.zip
SPI-ified the 'app' concept, which lets us create little apps inside lombok.jar proper. Currently used only by 'delombok'.
Diffstat (limited to 'src/installer')
-rw-r--r--src/installer/lombok/installer/Installer.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/installer/lombok/installer/Installer.java b/src/installer/lombok/installer/Installer.java
index d6f1add0..5b023766 100644
--- a/src/installer/lombok/installer/Installer.java
+++ b/src/installer/lombok/installer/Installer.java
@@ -40,12 +40,11 @@ import java.awt.event.ActionListener;
import java.awt.font.TextAttribute;
import java.io.File;
import java.io.FilenameFilter;
+import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import javax.swing.Box;
@@ -65,6 +64,8 @@ import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
+import lombok.core.LombokApp;
+import lombok.core.SpiLoadUtil;
import lombok.core.Version;
import lombok.installer.EclipseFinder.OS;
import lombok.installer.EclipseLocation.InstallException;
@@ -96,26 +97,26 @@ public class Installer {
private JLabel uninstallPlaceholder;
private JButton installButton;
- private static final Map<String, String> APPS;
- static {
- Map<String, String> m = new HashMap<String, String>();
- m.put("delombok", "lombok.delombok.Delombok");
- APPS = Collections.unmodifiableMap(m);
- }
-
public static void main(String[] args) {
if (args.length > 0) {
- String className = APPS.get(args[0]);
- if (className != null) {
- String[] newArgs = new String[args.length-1];
- System.arraycopy(args, 1, newArgs, 0, newArgs.length);
- try {
- Class.forName(className).getMethod("main", String[].class).invoke(newArgs);
- } catch (Exception e) {
- System.err.println("Lombok bug: Can't find application main class: " + className);
+ String appName = args[0];
+ String[] newArgs = new String[args.length-1];
+ System.arraycopy(args, 1, newArgs, 0, newArgs.length);
+ Iterable<LombokApp> services;
+ try {
+ services = SpiLoadUtil.findServices(LombokApp.class);
+ } catch (IOException e) {
+ System.err.println("Your lombok installation appears to be corrupted! Please let us know by clicking 'report bugs' on projectlombok.org. Include this stack trace:");
+ e.printStackTrace();
+ System.exit(2);
+ return;
+ }
+ for (LombokApp app : services) {
+ if (appName.equals(app.getAppName())) {
+ app.runApp(newArgs);
+ return;
}
}
- return;
}
if (args.length > 0 && (args[0].equals("install") || args[0].equals("uninstall"))) {
boolean uninstall = args[0].equals("uninstall");