aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/installer
diff options
context:
space:
mode:
Diffstat (limited to 'src/lombok/installer')
-rw-r--r--src/lombok/installer/EclipseFinder.java19
-rw-r--r--src/lombok/installer/EclipseLocation.java24
-rw-r--r--src/lombok/installer/Installer.java52
3 files changed, 65 insertions, 30 deletions
diff --git a/src/lombok/installer/EclipseFinder.java b/src/lombok/installer/EclipseFinder.java
index d54dd691..8e45852c 100644
--- a/src/lombok/installer/EclipseFinder.java
+++ b/src/lombok/installer/EclipseFinder.java
@@ -132,13 +132,14 @@ class EclipseFinder {
return drives;
}
-
+
/**
* Returns a list of paths of Eclipse installations.
* Eclipse installations are found by checking for the existence of 'eclipse.exe' in the following locations:
- *
- * X:\*Program Files*\*Eclipse*
- * X:\*Eclipse*
+ * <ul>
+ * <li>X:\*Program Files*\*Eclipse*</li>
+ * <li>X:\*Eclipse*</li>
+ * </ul>
*
* Where 'X' is tried for all local disk drives, unless there's a problem calling fsutil, in which case only
* C: is tried.
@@ -204,9 +205,13 @@ class EclipseFinder {
* Calls the OS-dependent 'find Eclipse' routine. If the local OS doesn't have a routine written for it,
* null is returned.
*
- * @param locations List of valid eclipse locations - provide an empty list; this method will fill it.
- * @param problems List of eclipse locations that seem to contain half-baked eclipses that can't be installed.
- * Provide an empty list; this method will fill it.
+ * @param locations
+ * List of valid eclipse locations - provide an empty list; this
+ * method will fill it.
+ * @param problems
+ * List of eclipse locations that seem to contain half-baked
+ * eclipses that can't be installed. Provide an empty list; this
+ * method will fill it.
*/
static void findEclipses(List<EclipseLocation> locations, List<NotAnEclipseException> problems) {
switch (getOS()) {
diff --git a/src/lombok/installer/EclipseLocation.java b/src/lombok/installer/EclipseLocation.java
index b1de37d5..c43c5042 100644
--- a/src/lombok/installer/EclipseLocation.java
+++ b/src/lombok/installer/EclipseLocation.java
@@ -99,7 +99,9 @@ final class EclipseLocation {
* Create a new EclipseLocation by pointing at either the directory contain the Eclipse executable, or the executable itself,
* or an eclipse.ini file.
*
- * @throws NotAnEclipseException If this isn't an Eclipse executable or a directory with an Eclipse executable.
+ * @throws NotAnEclipseException
+ * If this isn't an Eclipse executable or a directory with an
+ * Eclipse executable.
*/
public static EclipseLocation create(String path) throws NotAnEclipseException {
if (path == null) throw new NullPointerException("path");
@@ -130,7 +132,6 @@ final class EclipseLocation {
}
private static EclipseLocation findEclipseIniFromExe(File exePath, int loopCounter) throws NotAnEclipseException {
- System.out.println(exePath);
/* Try looking for eclipse.ini as sibling to the executable */ {
File ini = new File(exePath.getParentFile(), "eclipse.ini");
if (ini.isFile()) return new EclipseLocation(getFilePath(exePath), ini);
@@ -147,7 +148,7 @@ final class EclipseLocation {
String oPath = exePath.getAbsolutePath();
String nPath = exePath.getCanonicalPath();
if (!oPath.equals(nPath)) try {
- return findEclipseIniFromExe(new File(nPath), loopCounter +1);
+ return findEclipseIniFromExe(new File(nPath), loopCounter + 1);
} catch (NotAnEclipseException ignore) {
// Unlinking didn't help find an eclipse, so continue.
}
@@ -215,7 +216,7 @@ final class EclipseLocation {
"^\\-javaagent\\:.*lombok.*\\.jar$", Pattern.CASE_INSENSITIVE);
private final Pattern BOOTCLASSPATH_LINE_MATCHER = Pattern.compile(
- "^\\-Xbootclasspath\\/a\\:(.*lombok.*\\.jar.*)$", Pattern.CASE_INSENSITIVE);
+ "^\\-Xbootclasspath\\/a\\:(.*lombok.*\\.jar.*)$", Pattern.CASE_INSENSITIVE);
private boolean checkForLombok(File iniFile) throws IOException {
if (!iniFile.exists()) return false;
@@ -257,8 +258,10 @@ final class EclipseLocation {
* It's a no-op if lombok wasn't there in the first place,
* and it will remove a half-succeeded lombok installation as well.
*
- * @throws UninstallException If there's an obvious I/O problem that is preventing installation.
- * bugs in the uninstall code will probably throw other exceptions; this is intentional.
+ * @throws UninstallException
+ * If there's an obvious I/O problem that is preventing
+ * installation. bugs in the uninstall code will probably throw
+ * other exceptions; this is intentional.
*/
void uninstall() throws UninstallException {
for (File dir : getUninstallDirs()) {
@@ -319,8 +322,7 @@ final class EclipseLocation {
fos.close();
}
} catch (IOException e) {
- throw new UninstallException("Cannot uninstall lombok from " + name +
- generateWriteErrorMessage(), e);
+ throw new UninstallException("Cannot uninstall lombok from " + name + generateWriteErrorMessage(), e);
}
}
}
@@ -356,8 +358,10 @@ final class EclipseLocation {
* Install lombok into the Eclipse at this location.
* If lombok is already there, it is overwritten neatly (upgrade mode).
*
- * @throws InstallException If there's an obvious I/O problem that is preventing installation.
- * bugs in the install code will probably throw other exceptions; this is intentional.
+ * @throws InstallException
+ * If there's an obvious I/O problem that is preventing
+ * installation. bugs in the install code will probably throw
+ * other exceptions; this is intentional.
*/
void install() throws InstallException {
// For whatever reason, relative paths in your eclipse.ini file don't work on linux, but only for -javaagent.
diff --git a/src/lombok/installer/Installer.java b/src/lombok/installer/Installer.java
index fd90c6a0..e1da5d31 100644
--- a/src/lombok/installer/Installer.java
+++ b/src/lombok/installer/Installer.java
@@ -95,31 +95,57 @@ public class Installer {
private JButton installButton;
public static void main(String[] args) {
- if (args.length > 0 && args[0].equals("install")) {
+ if (args.length > 0 && (args[0].equals("install") || args[0].equals("uninstall"))) {
+ boolean uninstall = args[0].equals("uninstall");
if (args.length < 3 || !args[1].equals("eclipse")) {
- System.err.println("Run java -jar lombok.jar install eclipse path/to/eclipse/executable");
+ System.err.printf("Run java -jar lombok.jar %1$s eclipse path/to/eclipse/executable (or 'auto' to %1$s to all auto-discovered eclipse locations)\n", uninstall ? "uninstall" : "install");
System.exit(1);
}
String path = args[2];
try {
- EclipseLocation loc = EclipseLocation.create(path);
- loc.install();
- System.out.println("Installed to: " + loc.getName());
+ final List<EclipseLocation> locations = new ArrayList<EclipseLocation>();
+ final List<NotAnEclipseException> problems = new ArrayList<NotAnEclipseException>();
+ if (path.equals("auto")) {
+ EclipseFinder.findEclipses(locations, problems);
+ } else {
+ locations.add(EclipseLocation.create(path));
+ }
+ int validLocations = locations.size();
+ for (EclipseLocation loc : locations) {
+ try {
+ if (uninstall) {
+ loc.uninstall();
+ } else {
+ loc.install();
+ }
+ System.out.printf("Lombok %s %s: %s\n", uninstall ? "uninstalled" : "installed", uninstall ? "from" : "to", loc.getName());
+ } catch (InstallException e) {
+ System.err.printf("Installation at %s failed:\n", loc.getName());
+ System.err.println(e.getMessage());
+ validLocations--;
+ } catch (UninstallException e) {
+ System.err.printf("Uninstall at %s failed:\n", loc.getName());
+ System.err.println(e.getMessage());
+ validLocations--;
+ }
+ }
+ for (NotAnEclipseException problem : problems) {
+ System.err.println("WARNING: " + problem.getMessage());
+ }
+ if (validLocations == 0) {
+ System.err.println("WARNING: Zero valid locations found; so nothing was done.");
+ }
System.exit(0);
} catch (NotAnEclipseException e) {
System.err.println("Not a valid eclipse location:");
System.err.println(e.getMessage());
System.exit(2);
- } catch (InstallException e) {
- System.err.println("Installation failed:");
- System.err.println(e.getMessage());
- System.exit(1);
}
}
if (args.length > 0 && args[0].equals("uninstall")) {
if (args.length < 3 || !args[1].equals("eclipse")) {
- System.err.println("Run java -jar lombok.jar uninstall eclipse path/to/eclipse/executable");
+ System.err.println("Run java -jar lombok.jar uninstall eclipse path/to/eclipse/executable (or 'auto' to uninstall all auto-discovered eclipse locations)");
System.exit(1);
}
String path = args[2];
@@ -732,7 +758,7 @@ public class Installer {
constraints.gridx = 0;
constraints.gridy = 0;
constraints.insets = new Insets(8, 8, 8, 8);
- appWindowContainer.add(leftGraphic,constraints);
+ appWindowContainer.add(leftGraphic, constraints);
constraints.insets = new Insets(0, 0, 0, 0);
constraints.gridx++;
@@ -740,7 +766,7 @@ public class Installer {
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.ipadx = 16;
- constraints.ipady = 14 ;
+ constraints.ipady = 14;
appWindowContainer.add(javacArea, constraints);
constraints.gridy++;
@@ -789,7 +815,7 @@ public class Installer {
rt.exec(cmd);
break;
case MAC_OS_X:
- rt.exec( "open " + ABOUT_LOMBOK_URL.toString());
+ rt.exec("open " + ABOUT_LOMBOK_URL.toString());
break;
default:
case UNIX: