mirror of
https://github.com/tiennm99/lombok.git
synced 2026-08-18 04:27:34 +00:00
Simplify the registration of Eclipse-like IDEs, remove code duplication
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2014 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import lombok.installer.eclipse.EclipseFinder;
|
||||
import lombok.patcher.ClassRootFinder;
|
||||
|
||||
/**
|
||||
@@ -46,7 +45,7 @@ public abstract class IdeLocation {
|
||||
* a jar that wasn't accessed via the file-system, or if its started via e.g. unpacking the jar.
|
||||
*/
|
||||
public static File findOurJar() {
|
||||
return new File(ClassRootFinder.findClassRootOfClass(IdeFinder.class));
|
||||
return new File(ClassRootFinder.findClassRootOfClass(OsUtils.class));
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@@ -70,7 +69,7 @@ public abstract class IdeLocation {
|
||||
private static final String LEGAL_PATH_CHARS_WINDOWS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/:\\ ";
|
||||
public static String escapePath(String path) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
String legalChars = IdeFinder.getOS() == EclipseFinder.OS.UNIX ? LEGAL_PATH_CHARS : LEGAL_PATH_CHARS_WINDOWS;
|
||||
String legalChars = OsUtils.getOS() == OsUtils.OS.UNIX ? LEGAL_PATH_CHARS : LEGAL_PATH_CHARS_WINDOWS;
|
||||
for (char c : path.toCharArray()) {
|
||||
if (legalChars.indexOf(c) == -1) out.append('\\');
|
||||
out.append(c);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,20 +21,30 @@
|
||||
*/
|
||||
package lombok.installer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
|
||||
public interface IdeLocationProvider {
|
||||
/**
|
||||
* @throws CorruptedIdeLocationException
|
||||
* Only throw this exception if the location seems like a proper installation except there's something wrong with it.
|
||||
* Do not throw it (just return {@code null}) if there's nothing there or it looks absolutely nothing like your IDE.
|
||||
*/
|
||||
public abstract IdeLocation create(String path) throws CorruptedIdeLocationException;
|
||||
IdeLocation create(String path) throws CorruptedIdeLocationException;
|
||||
|
||||
/**
|
||||
* Return the usual name of the IDE executable or other obvious marker of an IDE installation on the provided platform.
|
||||
* Return the usual name of the IDE executable or other obvious marker of an IDE installation on the current platform.
|
||||
*/
|
||||
public abstract Pattern getLocationSelectors(OS os);
|
||||
Pattern getLocationSelectors();
|
||||
|
||||
/**
|
||||
* Look for installations of your IDE in the usual places.
|
||||
*
|
||||
* @param locations Add to this list any valid locations that you found.
|
||||
* @param problems
|
||||
* Add to this list any locations that look like installations,
|
||||
* but have problems that prevent you from installing/uninstalling from them. DONT add to this list
|
||||
* any common locations that have no installation at all - only add near misses.
|
||||
*/
|
||||
void findIdes(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -38,7 +38,7 @@ import lombok.Lombok;
|
||||
import lombok.core.LombokApp;
|
||||
import lombok.core.SpiLoadUtil;
|
||||
import lombok.core.Version;
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
import lombok.installer.OsUtils.OS;
|
||||
import lombok.patcher.ClassRootFinder;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
@@ -72,10 +72,9 @@ public class Installer {
|
||||
}
|
||||
|
||||
static List<Pattern> getIdeExecutableNames() {
|
||||
OS os = IdeFinder.getOS();
|
||||
List<Pattern> list = new ArrayList<Pattern>();
|
||||
for (IdeLocationProvider provider : locationProviders) {
|
||||
Pattern p = provider.getLocationSelectors(os);
|
||||
Pattern p = provider.getLocationSelectors();
|
||||
if (p != null) list.add(p);
|
||||
}
|
||||
return list;
|
||||
@@ -91,12 +90,8 @@ public class Installer {
|
||||
}
|
||||
|
||||
static void autoDiscover(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) {
|
||||
try {
|
||||
for (IdeFinder finder : SpiLoadUtil.findServices(IdeFinder.class)) {
|
||||
finder.findIdes(locations, problems);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw Lombok.sneakyThrow(e);
|
||||
for (IdeLocationProvider provider : locationProviders) {
|
||||
provider.findIdes(locations, problems);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +155,7 @@ public class Installer {
|
||||
}
|
||||
|
||||
private static int guiInstaller() {
|
||||
if (IdeFinder.getOS() == OS.MAC_OS_X) {
|
||||
if (OsUtils.getOS() == OS.MAC_OS_X) {
|
||||
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Lombok Installer");
|
||||
System.setProperty("com.apple.macos.use-file-dialog-packages", "true");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -67,7 +67,7 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import lombok.core.Version;
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
import lombok.installer.OsUtils.OS;
|
||||
|
||||
/**
|
||||
* The lombok GUI installer.
|
||||
@@ -313,7 +313,7 @@ public class InstallerGUI {
|
||||
final List<Pattern> exeNames = Installer.getIdeExecutableNames();
|
||||
String file = null;
|
||||
|
||||
if (IdeFinder.getOS() == OS.MAC_OS_X) {
|
||||
if (OsUtils.getOS() == OS.MAC_OS_X) {
|
||||
FileDialog chooser = new FileDialog(appWindow);
|
||||
chooser.setMode(FileDialog.LOAD);
|
||||
|
||||
@@ -740,7 +740,7 @@ public class InstallerGUI {
|
||||
} catch (Exception e) {
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
try {
|
||||
switch (IdeFinder.getOS()) {
|
||||
switch (OsUtils.getOS()) {
|
||||
case WINDOWS:
|
||||
String[] cmd = new String[4];
|
||||
cmd[0] = "cmd.exe";
|
||||
@@ -781,7 +781,7 @@ public class InstallerGUI {
|
||||
*/
|
||||
public void show() {
|
||||
appWindow.setVisible(true);
|
||||
if (IdeFinder.getOS() == OS.MAC_OS_X) {
|
||||
if (OsUtils.getOS() == OS.MAC_OS_X) {
|
||||
try {
|
||||
AppleNativeLook.go();
|
||||
} catch (Throwable ignore) {
|
||||
|
||||
+7
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -34,9 +34,13 @@ import lombok.core.Version;
|
||||
/**
|
||||
* Implement and provide this class to add auto-finding a certain brand of IDEs to the lombok installer.
|
||||
*/
|
||||
public abstract class IdeFinder {
|
||||
public final class OsUtils {
|
||||
private static final AtomicBoolean windowsDriveInfoLibLoaded = new AtomicBoolean(false);
|
||||
|
||||
private OsUtils() {
|
||||
// Prevent instantiation
|
||||
}
|
||||
|
||||
private static void loadWindowsDriveInfoLib() throws IOException {
|
||||
if (!windowsDriveInfoLibLoaded.compareAndSet(false, true)) return;
|
||||
|
||||
@@ -63,7 +67,7 @@ public abstract class IdeFinder {
|
||||
}
|
||||
|
||||
private static boolean unpackDLL(String dllName, File target) throws IOException {
|
||||
InputStream in = IdeFinder.class.getResourceAsStream(dllName);
|
||||
InputStream in = OsUtils.class.getResourceAsStream(dllName);
|
||||
try {
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(target);
|
||||
@@ -130,15 +134,4 @@ public abstract class IdeFinder {
|
||||
|
||||
return OS.UNIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for installations of your IDE in the usual places.
|
||||
*
|
||||
* @param locations Add to this list any valid locations that you found.
|
||||
* @param problems
|
||||
* Add to this list any locations that look like installations,
|
||||
* but have problems that prevent you from installing/uninstalling from them. DONT add to this list
|
||||
* any common locations that have no installation at all - only add near misses.
|
||||
*/
|
||||
public abstract void findIdes(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,145 +21,24 @@
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import static lombok.installer.IdeLocation.canonical;
|
||||
import java.util.Collections;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.installer.IdeLocation;
|
||||
import lombok.installer.IdeLocationProvider;
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
@ProviderFor(IdeLocationProvider.class)
|
||||
public class EclipseLocationProvider implements IdeLocationProvider {
|
||||
@Override public IdeLocation create(String path) throws CorruptedIdeLocationException {
|
||||
return create0(path);
|
||||
}
|
||||
public class EclipseLocationProvider extends EclipseProductLocationProvider {
|
||||
|
||||
protected List<String> getEclipseExecutableNames() {
|
||||
return Arrays.asList("eclipse.app", "eclipse.exe", "eclipse");
|
||||
}
|
||||
private static final EclipseProductDescriptor ECLIPSE = new StandardProductDescriptor(
|
||||
"Eclipse",
|
||||
"eclipse",
|
||||
"eclipse",
|
||||
EclipseLocationProvider.class.getResource("eclipse.png"),
|
||||
Collections.<String>emptySet()
|
||||
);
|
||||
|
||||
protected String getIniName() {
|
||||
return "eclipse.ini";
|
||||
}
|
||||
|
||||
protected IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException {
|
||||
return new EclipseLocation(name, ini);
|
||||
}
|
||||
|
||||
protected String getMacAppName() {
|
||||
return "Eclipse.app";
|
||||
}
|
||||
|
||||
protected String getUnixAppName() {
|
||||
return "eclipse";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new EclipseLocation by pointing at either the directory contains the Eclipse executable, or the executable itself,
|
||||
* or an eclipse.ini file.
|
||||
*
|
||||
* @throws NotAnIdeLocationException
|
||||
* If this isn't an Eclipse executable or a directory with an
|
||||
* Eclipse executable.
|
||||
*/
|
||||
protected IdeLocation create0(String path) throws CorruptedIdeLocationException {
|
||||
if (path == null) throw new NullPointerException("path");
|
||||
File p = new File(path);
|
||||
|
||||
if (!p.exists()) return null;
|
||||
if (p.isDirectory()) {
|
||||
for (String possibleExeName : getEclipseExecutableNames()) {
|
||||
File f = new File(p, possibleExeName);
|
||||
if (f.exists()) return findEclipseIniFromExe(f, 0);
|
||||
}
|
||||
|
||||
File f = new File(p, getIniName());
|
||||
if (f.exists()) return new EclipseLocation(canonical(p), f);
|
||||
}
|
||||
|
||||
if (p.isFile()) {
|
||||
if (p.getName().equalsIgnoreCase(getIniName())) {
|
||||
return new EclipseLocation(canonical(p.getParentFile()), p);
|
||||
}
|
||||
}
|
||||
|
||||
if (getEclipseExecutableNames().contains(p.getName().toLowerCase())) {
|
||||
return findEclipseIniFromExe(p, 0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IdeLocation findEclipseIniFromExe(File exePath, int loopCounter) throws CorruptedIdeLocationException {
|
||||
/* Try looking for eclipse.ini as sibling to the executable */ {
|
||||
File ini = new File(exePath.getParentFile(), getIniName());
|
||||
if (ini.isFile()) return makeLocation(canonical(exePath), ini);
|
||||
}
|
||||
|
||||
/* Try looking for Eclipse.app/Contents/MacOS/eclipse.ini as sibling to executable; this works on Mac OS X. */ {
|
||||
File ini = new File(exePath.getParentFile(), getMacAppName() + "/Contents/MacOS/" + getIniName());
|
||||
if (ini.isFile()) return makeLocation(canonical(exePath), ini);
|
||||
}
|
||||
|
||||
/* Starting with Eclipse Mars (with the oomph installer), the structure has changed, and it's now at Eclipse.app/Contents/Eclipse/eclipse.ini*/ {
|
||||
File ini = new File(exePath.getParentFile(), getMacAppName() + "/Contents/Eclipse/" + getIniName());
|
||||
if (ini.isFile()) return makeLocation(canonical(exePath), ini);
|
||||
}
|
||||
|
||||
/* If executable is a soft link, follow it and retry. */ {
|
||||
if (loopCounter < 50) {
|
||||
try {
|
||||
String oPath = exePath.getAbsolutePath();
|
||||
String nPath = exePath.getCanonicalPath();
|
||||
if (!oPath.equals(nPath)) try {
|
||||
IdeLocation loc = findEclipseIniFromExe(new File(nPath), loopCounter + 1);
|
||||
if (loc != null) return loc;
|
||||
} catch (CorruptedIdeLocationException ignore) {
|
||||
// Unlinking didn't help find an eclipse, so continue.
|
||||
}
|
||||
} catch (IOException ignore) { /* okay, that didn't work, assume it isn't a soft link then. */ }
|
||||
}
|
||||
}
|
||||
|
||||
/* If executable is a linux LSB-style path, then look in the usual places that package managers like apt-get use.*/ {
|
||||
String path = exePath.getAbsolutePath();
|
||||
try {
|
||||
path = exePath.getCanonicalPath();
|
||||
} catch (IOException ignore) { /* We'll stick with getAbsolutePath()'s result then. */ }
|
||||
|
||||
if (path.equals("/usr/bin/" + getUnixAppName()) || path.equals("/bin/" + getUnixAppName()) || path.equals("/usr/local/bin/" + getUnixAppName())) {
|
||||
File ini = new File("/usr/lib/" + getUnixAppName() + "/" + getIniName());
|
||||
if (ini.isFile()) return makeLocation(path, ini);
|
||||
ini = new File("/usr/local/lib/" + getUnixAppName() + "/" + getIniName());
|
||||
if (ini.isFile()) return makeLocation(path, ini);
|
||||
ini = new File("/usr/local/etc/" + getUnixAppName() + "/" + getIniName());
|
||||
if (ini.isFile()) return makeLocation(path, ini);
|
||||
ini = new File("/etc/" + getIniName());
|
||||
if (ini.isFile()) return makeLocation(path, ini);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we get this far, we lose. */
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public Pattern getLocationSelectors(OS os) {
|
||||
switch (os) {
|
||||
case MAC_OS_X:
|
||||
return Pattern.compile("^(eclipse|eclipse\\.ini|eclipse\\.app)$", Pattern.CASE_INSENSITIVE);
|
||||
case WINDOWS:
|
||||
return Pattern.compile("^(eclipse\\.exe|eclipse\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
default:
|
||||
case UNIX:
|
||||
return Pattern.compile("^(eclipse|eclipse\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
public EclipseLocationProvider() {
|
||||
super(ECLIPSE);
|
||||
}
|
||||
}
|
||||
|
||||
+17
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
* Copyright (C) 2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,25 +21,21 @@
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
|
||||
public class STSLocation extends EclipseLocation {
|
||||
public STSLocation(String nameOfLocation, File pathToEclipseIni) throws CorruptedIdeLocationException {
|
||||
super(nameOfLocation, pathToEclipseIni);
|
||||
}
|
||||
|
||||
@Override public URL getIdeIcon() {
|
||||
return STSLocation.class.getResource("STS.png");
|
||||
}
|
||||
|
||||
@Override protected String getIniFileName() {
|
||||
return "STS.ini";
|
||||
}
|
||||
|
||||
@Override protected String getTypeName() {
|
||||
return "STS";
|
||||
}
|
||||
}
|
||||
public interface EclipseProductDescriptor {
|
||||
String getProductName();
|
||||
String getWindowsExecutableName();
|
||||
String getUnixAppName();
|
||||
String getMacAppName();
|
||||
String getDirectoryName();
|
||||
List<String> getExecutableNames();
|
||||
List<String> getSourceDirsOnWindows();
|
||||
List<String> getSourceDirsOnMac();
|
||||
List<String> getSourceDirsOnUnix();
|
||||
String getIniFileName();
|
||||
Pattern getLocationSelectors();
|
||||
URL getIdeIcon();
|
||||
}
|
||||
+25
-30
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2012 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -35,7 +35,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeFinder;
|
||||
import lombok.installer.OsUtils;
|
||||
import lombok.installer.IdeLocation;
|
||||
import lombok.installer.InstallException;
|
||||
import lombok.installer.Installer;
|
||||
@@ -46,23 +46,18 @@ import lombok.installer.UninstallException;
|
||||
* An instance can figure out if an Eclipse installation has been lombok-ified, and can
|
||||
* install and uninstall lombok from the Eclipse installation.
|
||||
*/
|
||||
public class EclipseLocation extends IdeLocation {
|
||||
public final class EclipseProductLocation extends IdeLocation {
|
||||
|
||||
private static final String OS_NEWLINE = OsUtils.getOS().getLineEnding();
|
||||
|
||||
private final EclipseProductDescriptor descriptor;
|
||||
private final String name;
|
||||
private final File eclipseIniPath;
|
||||
private final String pathToLombokJarPrefix;
|
||||
private volatile boolean hasLombok;
|
||||
private final boolean hasLombok;
|
||||
|
||||
private static final String OS_NEWLINE = IdeFinder.getOS().getLineEnding();
|
||||
|
||||
protected String getTypeName() {
|
||||
return "eclipse";
|
||||
}
|
||||
|
||||
protected String getIniFileName() {
|
||||
return "eclipse.ini";
|
||||
}
|
||||
|
||||
EclipseLocation(String nameOfLocation, File pathToEclipseIni) throws CorruptedIdeLocationException {
|
||||
EclipseProductLocation(EclipseProductDescriptor descriptor, String nameOfLocation, File pathToEclipseIni) throws CorruptedIdeLocationException {
|
||||
this.descriptor = descriptor;
|
||||
this.name = nameOfLocation;
|
||||
this.eclipseIniPath = pathToEclipseIni;
|
||||
File p1 = pathToEclipseIni.getParentFile();
|
||||
@@ -78,8 +73,8 @@ public class EclipseLocation extends IdeLocation {
|
||||
this.hasLombok = checkForLombok(eclipseIniPath);
|
||||
} catch (IOException e) {
|
||||
throw new CorruptedIdeLocationException(
|
||||
"I can't read the configuration file of the " + getTypeName() + " installed at " + name + "\n" +
|
||||
"You may need to run this installer with root privileges if you want to modify that " + getTypeName() + ".", getTypeName(), e);
|
||||
"I can't read the configuration file of the " + descriptor.getProductName() + " installed at " + name + "\n" +
|
||||
"You may need to run this installer with root privileges if you want to modify that " + descriptor.getProductName() + ".", descriptor.getProductName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +83,8 @@ public class EclipseLocation extends IdeLocation {
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
if (!(o instanceof EclipseLocation)) return false;
|
||||
return ((EclipseLocation)o).eclipseIniPath.equals(eclipseIniPath);
|
||||
if (!(o instanceof EclipseProductLocation)) return false;
|
||||
return ((EclipseProductLocation)o).eclipseIniPath.equals(eclipseIniPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,13 +103,13 @@ public class EclipseLocation extends IdeLocation {
|
||||
return hasLombok;
|
||||
}
|
||||
|
||||
private final Pattern JAVA_AGENT_LINE_MATCHER = Pattern.compile(
|
||||
private static final Pattern JAVA_AGENT_LINE_MATCHER = Pattern.compile(
|
||||
"^\\-javaagent\\:.*lombok.*\\.jar$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private final Pattern BOOTCLASSPATH_LINE_MATCHER = Pattern.compile(
|
||||
private static final Pattern BOOTCLASSPATH_LINE_MATCHER = Pattern.compile(
|
||||
"^\\-Xbootclasspath\\/a\\:(.*lombok.*\\.jar.*)$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private boolean checkForLombok(File iniFile) throws IOException {
|
||||
private static boolean checkForLombok(File iniFile) throws IOException {
|
||||
if (!iniFile.exists()) return false;
|
||||
FileInputStream fis = new FileInputStream(iniFile);
|
||||
try {
|
||||
@@ -206,7 +201,7 @@ public class EclipseLocation extends IdeLocation {
|
||||
File lombokJar = new File(dir, "lombok.jar");
|
||||
if (lombokJar.exists()) {
|
||||
if (!lombokJar.delete()) {
|
||||
if (IdeFinder.getOS() == IdeFinder.OS.WINDOWS && Installer.isSelf(lombokJar.getAbsolutePath())) {
|
||||
if (OsUtils.getOS() == OsUtils.OS.WINDOWS && Installer.isSelf(lombokJar.getAbsolutePath())) {
|
||||
lombokJarsForWhichCantDeleteSelf.add(lombokJar);
|
||||
} else {
|
||||
throw new UninstallException(
|
||||
@@ -228,14 +223,14 @@ public class EclipseLocation extends IdeLocation {
|
||||
throw new UninstallException(true, String.format(
|
||||
"lombok.jar cannot delete itself on windows.\nHowever, lombok has been uncoupled from your %s.\n" +
|
||||
"You can safely delete this jar file. You can find it at:\n%s",
|
||||
getTypeName(), lombokJarsForWhichCantDeleteSelf.get(0).getAbsolutePath()), null);
|
||||
descriptor.getProductName(), lombokJarsForWhichCantDeleteSelf.get(0).getAbsolutePath()), null);
|
||||
}
|
||||
}
|
||||
|
||||
private static String generateWriteErrorMessage() {
|
||||
String osSpecificError;
|
||||
|
||||
switch (IdeFinder.getOS()) {
|
||||
switch (OsUtils.getOS()) {
|
||||
default:
|
||||
case MAC_OS_X:
|
||||
case UNIX:
|
||||
@@ -265,7 +260,7 @@ public class EclipseLocation extends IdeLocation {
|
||||
// If someone knows how to fix this, please do so, as this current hack solution (putting the absolute path
|
||||
// to the jar files in your eclipse.ini) means you can't move your eclipse around on linux without lombok
|
||||
// breaking it. NB: rerunning lombok.jar installer and hitting 'update' will fix it if you do that.
|
||||
boolean fullPathRequired = IdeFinder.getOS() == EclipseFinder.OS.UNIX || System.getProperty("lombok.installer.fullpath") != null;
|
||||
boolean fullPathRequired = OsUtils.getOS() == OsUtils.OS.UNIX || System.getProperty("lombok.installer.fullpath") != null;
|
||||
|
||||
boolean installSucceeded = false;
|
||||
StringBuilder newContents = new StringBuilder();
|
||||
@@ -303,7 +298,7 @@ public class EclipseLocation extends IdeLocation {
|
||||
"I can't read my own jar file. I think you've found a bug in this installer!\nI suggest you restart it " +
|
||||
"and use the 'what do I do' link, to manually install lombok. Also, tell us about this at:\n" +
|
||||
"http://groups.google.com/group/project-lombok - Thanks!", e);
|
||||
throw new InstallException("I can't write to your " + getTypeName() + " directory at " + name + generateWriteErrorMessage(), e);
|
||||
throw new InstallException("I can't write to your " + descriptor.getProductName() + " directory at " + name + generateWriteErrorMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,14 +364,14 @@ public class EclipseLocation extends IdeLocation {
|
||||
}
|
||||
|
||||
if (!installSucceeded) {
|
||||
throw new InstallException("I can't find the " + getIniFileName() + " file. Is this a real " + getTypeName() + " installation?", null);
|
||||
throw new InstallException("I can't find the " + descriptor.getIniFileName() + " file. Is this a real " + descriptor.getProductName() + " installation?", null);
|
||||
}
|
||||
|
||||
return "If you start " + getTypeName() + " with a custom -vm parameter, you'll need to add:<br>" +
|
||||
return "If you start " + descriptor.getProductName() + " with a custom -vm parameter, you'll need to add:<br>" +
|
||||
"<code>-vmargs -javaagent:lombok.jar</code><br>as parameter as well.";
|
||||
}
|
||||
|
||||
@Override public URL getIdeIcon() {
|
||||
return EclipseLocation.class.getResource("eclipse.png");
|
||||
return descriptor.getIdeIcon();
|
||||
}
|
||||
}
|
||||
+173
-95
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,85 +22,158 @@
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static lombok.installer.IdeLocation.canonical;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.installer.IdeFinder;
|
||||
import lombok.installer.IdeLocation;
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.OsUtils;
|
||||
import lombok.installer.IdeLocation;
|
||||
import lombok.installer.IdeLocationProvider;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
public class EclipseProductLocationProvider implements IdeLocationProvider {
|
||||
private final EclipseProductDescriptor descriptor;
|
||||
|
||||
@ProviderFor(IdeFinder.class)
|
||||
public class EclipseFinder extends IdeFinder {
|
||||
/** should be lowercase! */
|
||||
protected String getDirName() {
|
||||
return "eclipse";
|
||||
EclipseProductLocationProvider(EclipseProductDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
protected String getWindowsExecutableName() {
|
||||
return "eclipse.exe";
|
||||
}
|
||||
|
||||
protected String getUnixExecutableName() {
|
||||
return "eclipse";
|
||||
}
|
||||
|
||||
protected String getMacExecutableName() {
|
||||
return "Eclipse.app";
|
||||
}
|
||||
|
||||
protected IdeLocation createLocation(String guess) throws CorruptedIdeLocationException {
|
||||
return new EclipseLocationProvider().create0(guess);
|
||||
}
|
||||
|
||||
protected List<String> getSourceDirsOnWindows() {
|
||||
return Arrays.asList("\\", "\\Program Files", "\\Program Files (x86)", System.getProperty("user.home", "."));
|
||||
@Override public final IdeLocation create(String path) throws CorruptedIdeLocationException {
|
||||
return create0(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of paths of Eclipse installations.
|
||||
* Create a new EclipseLocation by pointing at either the directory contains the Eclipse executable, or the executable itself,
|
||||
* or an eclipse.ini file.
|
||||
*
|
||||
* The search process works by scanning for each 'source dir' for either an eclipse installation or a folder containing the text returned
|
||||
* by getDirName(). If such a folder is found, this process is applied recursively. On windows, this process is run on each drive letter
|
||||
* which represents a physical hard disk. If the native windows API call to determine these drive letters fails, only 'C:' is checked.
|
||||
* @throws NotAnIdeLocationException
|
||||
* If this isn't an Eclipse executable or a directory with an
|
||||
* Eclipse executable.
|
||||
*/
|
||||
private List<String> getSourceDirsOnWindowsWithDriveLetters() {
|
||||
List<String> driveLetters = asList("C");
|
||||
try {
|
||||
driveLetters = getDrivesOnWindows();
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
List<String> sourceDirs = new ArrayList<String>();
|
||||
for (String letter : driveLetters) {
|
||||
for (String possibleSource : getSourceDirsOnWindows()) {
|
||||
if (!isDriveSpecificOnWindows(possibleSource)) {
|
||||
sourceDirs.add(letter + ":" + possibleSource);
|
||||
}
|
||||
private IdeLocation create0(String path) throws CorruptedIdeLocationException {
|
||||
if (path == null) throw new NullPointerException("path");
|
||||
String iniName = descriptor.getIniFileName();
|
||||
File p = new File(path);
|
||||
|
||||
if (!p.exists()) return null;
|
||||
if (p.isDirectory()) {
|
||||
for (String possibleExeName : descriptor.getExecutableNames()) {
|
||||
File f = new File(p, possibleExeName);
|
||||
if (f.exists()) return findEclipseIniFromExe(f, 0);
|
||||
}
|
||||
}
|
||||
for (String possibleSource : getSourceDirsOnWindows()) {
|
||||
if (isDriveSpecificOnWindows(possibleSource)) sourceDirs.add(possibleSource);
|
||||
|
||||
File f = new File(p, iniName);
|
||||
if (f.exists()) return makeLocation(canonical(p), f);
|
||||
}
|
||||
|
||||
return sourceDirs;
|
||||
if (p.isFile()) {
|
||||
if (p.getName().equalsIgnoreCase(iniName)) {
|
||||
return makeLocation(canonical(p.getParentFile()), p);
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor.getExecutableNames().contains(p.getName().toLowerCase())) {
|
||||
return findEclipseIniFromExe(p, 0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isDriveSpecificOnWindows(String path) {
|
||||
return path.length() > 1 && path.charAt(1) == ':';
|
||||
private IdeLocation findEclipseIniFromExe(File exePath, int loopCounter) throws CorruptedIdeLocationException {
|
||||
String iniName = descriptor.getIniFileName();
|
||||
/* Try looking for eclipse.ini as sibling to the executable */ {
|
||||
File ini = new File(exePath.getParentFile(), iniName);
|
||||
if (ini.isFile()) return makeLocation(canonical(exePath), ini);
|
||||
}
|
||||
|
||||
String macAppName = descriptor.getMacAppName();
|
||||
/* Try looking for Eclipse.app/Contents/MacOS/eclipse.ini as sibling to executable; this works on Mac OS X. */ {
|
||||
File ini = new File(exePath.getParentFile(), macAppName + "/Contents/MacOS/" + iniName);
|
||||
if (ini.isFile()) return makeLocation(canonical(exePath), ini);
|
||||
}
|
||||
|
||||
/* Starting with Eclipse Mars (with the oomph installer), the structure has changed, and it's now at Eclipse.app/Contents/Eclipse/eclipse.ini*/ {
|
||||
File ini = new File(exePath.getParentFile(), macAppName + "/Contents/Eclipse/" + iniName);
|
||||
if (ini.isFile()) return makeLocation(canonical(exePath), ini);
|
||||
}
|
||||
|
||||
/* If executable is a soft link, follow it and retry. */ {
|
||||
if (loopCounter < 50) {
|
||||
try {
|
||||
String oPath = exePath.getAbsolutePath();
|
||||
String nPath = exePath.getCanonicalPath();
|
||||
if (!oPath.equals(nPath)) try {
|
||||
IdeLocation loc = findEclipseIniFromExe(new File(nPath), loopCounter + 1);
|
||||
if (loc != null) return loc;
|
||||
} catch (CorruptedIdeLocationException ignore) {
|
||||
// Unlinking didn't help find an eclipse, so continue.
|
||||
}
|
||||
} catch (IOException ignore) { /* okay, that didn't work, assume it isn't a soft link then. */ }
|
||||
}
|
||||
}
|
||||
|
||||
/* If executable is a linux LSB-style path, then look in the usual places that package managers like apt-get use.*/ {
|
||||
String path = exePath.getAbsolutePath();
|
||||
try {
|
||||
path = exePath.getCanonicalPath();
|
||||
} catch (IOException ignore) { /* We'll stick with getAbsolutePath()'s result then. */ }
|
||||
|
||||
String unixAppName = descriptor.getUnixAppName();
|
||||
if (path.equals("/usr/bin/" + unixAppName) || path.equals("/bin/" + unixAppName) || path.equals("/usr/local/bin/" + unixAppName)) {
|
||||
File ini = new File("/usr/lib/" + unixAppName + "/" + iniName);
|
||||
if (ini.isFile()) return makeLocation(path, ini);
|
||||
ini = new File("/usr/local/lib/" + unixAppName + "/" + iniName);
|
||||
if (ini.isFile()) return makeLocation(path, ini);
|
||||
ini = new File("/usr/local/etc/" + unixAppName + "/" + iniName);
|
||||
if (ini.isFile()) return makeLocation(path, ini);
|
||||
ini = new File("/etc/" + iniName);
|
||||
if (ini.isFile()) return makeLocation(path, ini);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we get this far, we lose. */
|
||||
return null;
|
||||
}
|
||||
|
||||
protected List<String> getSourceDirsOnMac() {
|
||||
return Arrays.asList("/Applications", System.getProperty("user.home", "."));
|
||||
private IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException {
|
||||
return new EclipseProductLocation(descriptor, name, ini);
|
||||
}
|
||||
|
||||
protected List<String> getSourceDirsOnUnix() {
|
||||
return Arrays.asList(System.getProperty("user.home", "."));
|
||||
@Override public Pattern getLocationSelectors() {
|
||||
return descriptor.getLocationSelectors();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Override
|
||||
public void findIdes(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) {
|
||||
switch (OsUtils.getOS()) {
|
||||
case WINDOWS:
|
||||
new WindowsFinder().findEclipse(locations, problems);
|
||||
break;
|
||||
case MAC_OS_X:
|
||||
new MacFinder().findEclipse(locations, problems);
|
||||
break;
|
||||
default:
|
||||
case UNIX:
|
||||
new UnixFinder().findEclipse(locations, problems);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private List<File> transformToFiles(List<String> fileNames) {
|
||||
@@ -127,45 +200,50 @@ public class EclipseFinder extends IdeFinder {
|
||||
return dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@Override
|
||||
public void findIdes(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) {
|
||||
switch (getOS()) {
|
||||
case WINDOWS:
|
||||
new WindowsFinder().findEclipse(locations, problems);
|
||||
break;
|
||||
case MAC_OS_X:
|
||||
new MacFinder().findEclipse(locations, problems);
|
||||
break;
|
||||
default:
|
||||
case UNIX:
|
||||
new UnixFinder().findEclipse(locations, problems);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private class UnixFinder extends DirectoryFinder {
|
||||
UnixFinder() {
|
||||
super(getNestedSourceLocationOnUnix(), getFlatSourceLocationsOnUnix());
|
||||
}
|
||||
|
||||
@Override protected String findEclipseOnPlatform(File dir) {
|
||||
File possible = new File(dir, getUnixExecutableName());
|
||||
File possible = new File(dir, descriptor.getUnixAppName());
|
||||
return (possible.exists()) ? possible.getAbsolutePath() : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of paths of Eclipse installations.
|
||||
*
|
||||
* The search process works by scanning for each 'source dir' for either an eclipse installation or a folder containing the text returned
|
||||
* by getDirName(). If such a folder is found, this process is applied recursively. On windows, this process is run on each drive letter
|
||||
* which represents a physical hard disk. If the native windows API call to determine these drive letters fails, only 'C:' is checked.
|
||||
*/
|
||||
private List<String> getSourceDirsOnWindowsWithDriveLetters() {
|
||||
List<String> driveLetters = asList("C");
|
||||
try {
|
||||
driveLetters = OsUtils.getDrivesOnWindows();
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
List<String> sourceDirs = new ArrayList<String>();
|
||||
for (String letter : driveLetters) {
|
||||
for (String possibleSource : descriptor.getSourceDirsOnWindows()) {
|
||||
if (!isDriveSpecificOnWindows(possibleSource)) {
|
||||
sourceDirs.add(letter + ":" + possibleSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String possibleSource : descriptor.getSourceDirsOnWindows()) {
|
||||
if (isDriveSpecificOnWindows(possibleSource)) sourceDirs.add(possibleSource);
|
||||
}
|
||||
|
||||
return sourceDirs;
|
||||
}
|
||||
|
||||
private boolean isDriveSpecificOnWindows(String path) {
|
||||
return path.length() > 1 && path.charAt(1) == ':';
|
||||
}
|
||||
|
||||
private class WindowsFinder extends DirectoryFinder {
|
||||
WindowsFinder() {
|
||||
super(transformToFiles(getSourceDirsOnWindowsWithDriveLetters()), Collections.<File>emptyList());
|
||||
@@ -174,20 +252,20 @@ public class EclipseFinder extends IdeFinder {
|
||||
/** Checks if the provided directory contains 'eclipse.exe', and if so, returns the directory, otherwise null. */
|
||||
@Override
|
||||
protected String findEclipseOnPlatform(File dir) {
|
||||
File possible = new File(dir, getWindowsExecutableName());
|
||||
File possible = new File(dir, descriptor.getWindowsExecutableName());
|
||||
return (possible.isFile()) ? dir.getAbsolutePath() : null;
|
||||
}
|
||||
}
|
||||
|
||||
private class MacFinder extends DirectoryFinder {
|
||||
MacFinder() {
|
||||
super(transformToFiles(getSourceDirsOnMac()), Collections.<File>emptyList());
|
||||
super(transformToFiles(descriptor.getSourceDirsOnMac()), Collections.<File>emptyList());
|
||||
}
|
||||
|
||||
protected String findEclipseOnPlatform(File dir) {
|
||||
if (dir.getName().toLowerCase().equals(getMacExecutableName().toLowerCase())) return dir.getParent();
|
||||
if (dir.getName().toLowerCase().contains(getDirName())) {
|
||||
if (new File(dir, getMacExecutableName()).exists()) return dir.toString();
|
||||
if (dir.getName().toLowerCase().equals(descriptor.getMacAppName().toLowerCase())) return dir.getParent();
|
||||
if (dir.getName().toLowerCase().contains(descriptor.getDirectoryName())) {
|
||||
if (new File(dir, descriptor.getMacAppName()).exists()) return dir.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -202,14 +280,14 @@ public class EclipseFinder extends IdeFinder {
|
||||
this.flatSourceDirs = flatSourceDirs;
|
||||
}
|
||||
|
||||
public void findEclipse(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) {
|
||||
void findEclipse(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) {
|
||||
for (File dir : nestedSourceDirs) recurseDirectory(locations, problems, dir);
|
||||
for (File dir : flatSourceDirs) findEclipse(locations, problems, dir);
|
||||
}
|
||||
|
||||
protected abstract String findEclipseOnPlatform(File dir);
|
||||
abstract String findEclipseOnPlatform(File dir);
|
||||
|
||||
protected void recurseDirectory(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems, File dir) {
|
||||
void recurseDirectory(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems, File dir) {
|
||||
recurseDirectory0(locations, problems, dir, 0);
|
||||
}
|
||||
|
||||
@@ -223,19 +301,19 @@ public class EclipseFinder extends IdeFinder {
|
||||
for (File dir : listFiles) {
|
||||
if (!dir.isDirectory()) continue;
|
||||
try {
|
||||
if (dir.getName().toLowerCase().contains(getDirName())) {
|
||||
if (dir.getName().toLowerCase().contains(descriptor.getDirectoryName())) {
|
||||
findEclipse(locations, problems, dir);
|
||||
if (loopCounter < 50) recurseDirectory0(locations, problems, dir, loopCounter + 1);
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void findEclipse(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems, File dir) {
|
||||
String eclipseLocation = findEclipseOnPlatform(dir);
|
||||
if (eclipseLocation != null) {
|
||||
try {
|
||||
IdeLocation newLocation = createLocation(eclipseLocation);
|
||||
IdeLocation newLocation = create(eclipseLocation);
|
||||
if (newLocation != null) locations.add(newLocation);
|
||||
} catch (CorruptedIdeLocationException e) {
|
||||
problems.add(e);
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeFinder;
|
||||
import lombok.installer.IdeLocation;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
/**
|
||||
* JBDS (JBoss Developer Studio) is an eclipse variant.
|
||||
* Other than different executable names, it's the same as eclipse, as far as lombok support goes.
|
||||
*/
|
||||
@ProviderFor(IdeFinder.class)
|
||||
public class JbdsFinder extends EclipseFinder {
|
||||
@Override protected IdeLocation createLocation(String guess) throws CorruptedIdeLocationException {
|
||||
return new JbdsLocationProvider().create0(guess);
|
||||
}
|
||||
|
||||
@Override protected String getDirName() {
|
||||
return "studio";
|
||||
}
|
||||
|
||||
@Override protected String getMacExecutableName() {
|
||||
return "jbdevstudio.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixExecutableName() {
|
||||
return "jbdevstudio";
|
||||
}
|
||||
|
||||
@Override protected String getWindowsExecutableName() {
|
||||
return "jbdevstudio.exe";
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnWindows() {
|
||||
return Arrays.asList("\\", "\\Program Files", "\\Program Files (x86)", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnMac() {
|
||||
return Arrays.asList("/Applications", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnUnix() {
|
||||
return Arrays.asList(System.getProperty("user.home", "."));
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
|
||||
public class JbdsLocation extends EclipseLocation {
|
||||
public JbdsLocation(String nameOfLocation, File pathToEclipseIni) throws CorruptedIdeLocationException {
|
||||
super(nameOfLocation, pathToEclipseIni);
|
||||
}
|
||||
|
||||
@Override public URL getIdeIcon() {
|
||||
return JbdsLocation.class.getResource("jbds.png");
|
||||
}
|
||||
|
||||
@Override protected String getIniFileName() {
|
||||
return "jbdevstudio.ini";
|
||||
}
|
||||
|
||||
@Override protected String getTypeName() {
|
||||
return "JBoss Developer Studio";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Project Lombok Authors.
|
||||
* Copyright (C) 2013-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,49 +21,24 @@
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Collections;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeLocation;
|
||||
import lombok.installer.IdeLocationProvider;
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
@ProviderFor(IdeLocationProvider.class)
|
||||
public class JbdsLocationProvider extends EclipseLocationProvider {
|
||||
@Override protected List<String> getEclipseExecutableNames() {
|
||||
return Arrays.asList("jbdevstudio.app", "jbdevstudio.exe", "jbdevstudioc.exe", "jbdevstudio");
|
||||
}
|
||||
public class JbdsLocationProvider extends EclipseProductLocationProvider {
|
||||
|
||||
@Override protected String getIniName() {
|
||||
return "jbdevstudio.ini";
|
||||
}
|
||||
private static final EclipseProductDescriptor JBDS = new StandardProductDescriptor(
|
||||
"JBoss Developer Studio",
|
||||
"jbdevstudio",
|
||||
"studio",
|
||||
JbdsLocationProvider.class.getResource("jbds.png"),
|
||||
Collections.<String>emptySet()
|
||||
);
|
||||
|
||||
@Override protected IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException {
|
||||
return new JbdsLocation(name, ini);
|
||||
}
|
||||
|
||||
@Override protected String getMacAppName() {
|
||||
return "jbdevstudio.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixAppName() {
|
||||
return "jbdevstudio";
|
||||
}
|
||||
|
||||
@Override public Pattern getLocationSelectors(OS os) {
|
||||
switch (os) {
|
||||
case MAC_OS_X:
|
||||
return Pattern.compile("^(jbdevstudio|jbdevstudio\\.ini|jbdevstudio\\.app)$", Pattern.CASE_INSENSITIVE);
|
||||
case WINDOWS:
|
||||
return Pattern.compile("^(jbdevstudioc?\\.exe|jbdevstudio\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
default:
|
||||
case UNIX:
|
||||
return Pattern.compile("^(jbdevstudio|jbdevstudio\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
public JbdsLocationProvider() {
|
||||
super(JBDS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeFinder;
|
||||
import lombok.installer.IdeLocation;
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MyEclipse is an eclipse variant.
|
||||
* Other than different executable names, it's the same as eclipse, as far as lombok support goes.
|
||||
*/
|
||||
@ProviderFor(IdeFinder.class)
|
||||
public class MyEclipseFinder extends EclipseFinder {
|
||||
@Override protected IdeLocation createLocation(String guess) throws CorruptedIdeLocationException {
|
||||
return new MyEclipseLocationProvider().create0(guess);
|
||||
}
|
||||
|
||||
@Override protected String getDirName() {
|
||||
return "myeclipse";
|
||||
}
|
||||
|
||||
@Override protected String getMacExecutableName() {
|
||||
return "myeclipse.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixExecutableName() {
|
||||
return "myeclipse";
|
||||
}
|
||||
|
||||
@Override protected String getWindowsExecutableName() {
|
||||
return "myeclipse.exe";
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnWindows() {
|
||||
return Arrays.asList("\\", "\\Program Files", "\\Program Files (x86)", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnMac() {
|
||||
return Arrays.asList("/Applications", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnUnix() {
|
||||
return Arrays.asList(System.getProperty("user.home", "."));
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
public class MyEclipseLocation extends EclipseLocation {
|
||||
public MyEclipseLocation(String nameOfLocation, File pathToEclipseIni) throws CorruptedIdeLocationException {
|
||||
super(nameOfLocation, pathToEclipseIni);
|
||||
}
|
||||
|
||||
@Override public URL getIdeIcon() {
|
||||
return MyEclipseLocation.class.getResource("myeclipse.png");
|
||||
}
|
||||
|
||||
@Override protected String getIniFileName() {
|
||||
return "myeclipse.ini";
|
||||
}
|
||||
|
||||
@Override protected String getTypeName() {
|
||||
return "MyEclipse";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
* Copyright (C) 2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,48 +21,24 @@
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
import lombok.installer.IdeLocation;
|
||||
import java.util.Collections;
|
||||
|
||||
import lombok.installer.IdeLocationProvider;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ProviderFor(IdeLocationProvider.class)
|
||||
public class MyEclipseLocationProvider extends EclipseLocationProvider {
|
||||
@Override protected List<String> getEclipseExecutableNames() {
|
||||
return Arrays.asList("myeclipse.app", "myeclipse.exe", "myeclipsec.exe", "myeclipse");
|
||||
}
|
||||
public class MyEclipseLocationProvider extends EclipseProductLocationProvider {
|
||||
|
||||
@Override protected String getIniName() {
|
||||
return "myeclipse.ini";
|
||||
}
|
||||
private static final EclipseProductDescriptor MY_ECLIPSE = new StandardProductDescriptor(
|
||||
"MyEclipse",
|
||||
"myeclipse",
|
||||
"myeclipse",
|
||||
MyEclipseLocationProvider.class.getResource("myeclipse.png"),
|
||||
Collections.<String>emptySet()
|
||||
);
|
||||
|
||||
@Override protected IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException {
|
||||
return new MyEclipseLocation(name, ini);
|
||||
}
|
||||
|
||||
@Override protected String getMacAppName() {
|
||||
return "myeclipse.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixAppName() {
|
||||
return "myeclipse";
|
||||
}
|
||||
|
||||
@Override public Pattern getLocationSelectors(OS os) {
|
||||
switch (os) {
|
||||
case MAC_OS_X:
|
||||
return Pattern.compile("^(myeclipse|myeclipse\\.ini|myeclipse\\.app)$", Pattern.CASE_INSENSITIVE);
|
||||
case WINDOWS:
|
||||
return Pattern.compile("^(myeclipsec?\\.exe|myeclipse\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
default:
|
||||
case UNIX:
|
||||
return Pattern.compile("^(myeclipse|myeclipse\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
public MyEclipseLocationProvider() {
|
||||
super(MY_ECLIPSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeFinder;
|
||||
import lombok.installer.IdeLocation;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
/**
|
||||
* RHDS (Red Hat JBoss Developer Studio) is an eclipse variant.
|
||||
* Other than different executable names, it's the same as eclipse, as far as lombok support goes.
|
||||
*/
|
||||
@ProviderFor(IdeFinder.class)
|
||||
public class RhdsFinder extends EclipseFinder {
|
||||
@Override protected IdeLocation createLocation(String guess) throws CorruptedIdeLocationException {
|
||||
return new RhdsLocationProvider().create0(guess);
|
||||
}
|
||||
|
||||
@Override protected String getDirName() {
|
||||
return "studio";
|
||||
}
|
||||
|
||||
@Override protected String getMacExecutableName() {
|
||||
return "devstudio.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixExecutableName() {
|
||||
return "devstudio";
|
||||
}
|
||||
|
||||
@Override protected String getWindowsExecutableName() {
|
||||
return "devstudio.exe";
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnWindows() {
|
||||
return Arrays.asList("\\", "\\Program Files", "\\Program Files (x86)", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnMac() {
|
||||
return Arrays.asList("/Applications", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnUnix() {
|
||||
return Arrays.asList(System.getProperty("user.home", "."));
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
|
||||
public class RhdsLocation extends EclipseLocation {
|
||||
public RhdsLocation(String nameOfLocation, File pathToEclipseIni) throws CorruptedIdeLocationException {
|
||||
super(nameOfLocation, pathToEclipseIni);
|
||||
}
|
||||
|
||||
@Override public URL getIdeIcon() {
|
||||
return RhdsLocation.class.getResource("rhds.png");
|
||||
}
|
||||
|
||||
@Override protected String getIniFileName() {
|
||||
return "devstudio.ini";
|
||||
}
|
||||
|
||||
@Override protected String getTypeName() {
|
||||
return "Red Hat JBoss Developer Studio";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Project Lombok Authors.
|
||||
* Copyright (C) 2013-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,49 +21,24 @@
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Collections;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeLocation;
|
||||
import lombok.installer.IdeLocationProvider;
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
@ProviderFor(IdeLocationProvider.class)
|
||||
public class RhdsLocationProvider extends EclipseLocationProvider {
|
||||
@Override protected List<String> getEclipseExecutableNames() {
|
||||
return Arrays.asList("devstudio.app", "devstudio.exe", "devstudioc.exe", "devstudio");
|
||||
}
|
||||
public class RhdsLocationProvider extends EclipseProductLocationProvider {
|
||||
|
||||
@Override protected String getIniName() {
|
||||
return "devstudio.ini";
|
||||
}
|
||||
private static final EclipseProductDescriptor RHDS = new StandardProductDescriptor(
|
||||
"Red Hat JBoss Developer Studio",
|
||||
"devstudio",
|
||||
"studio",
|
||||
RhdsLocationProvider.class.getResource("rhds.png"),
|
||||
Collections.<String>emptySet()
|
||||
);
|
||||
|
||||
@Override protected IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException {
|
||||
return new RhdsLocation(name, ini);
|
||||
}
|
||||
|
||||
@Override protected String getMacAppName() {
|
||||
return "devstudio.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixAppName() {
|
||||
return "devstudio";
|
||||
}
|
||||
|
||||
@Override public Pattern getLocationSelectors(OS os) {
|
||||
switch (os) {
|
||||
case MAC_OS_X:
|
||||
return Pattern.compile("^(devstudio|devstudio\\.ini|devstudio\\.app)$", Pattern.CASE_INSENSITIVE);
|
||||
case WINDOWS:
|
||||
return Pattern.compile("^(devstudioc?\\.exe|devstudio\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
default:
|
||||
case UNIX:
|
||||
return Pattern.compile("^(devstudio|devstudio\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
public RhdsLocationProvider() {
|
||||
super(RHDS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeFinder;
|
||||
import lombok.installer.IdeLocation;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
/**
|
||||
* STS (Springsource Tool Suite) is an eclipse variant.
|
||||
* Other than different executable names, it's the same as eclipse, as far as lombok support goes.
|
||||
*/
|
||||
@ProviderFor(IdeFinder.class)
|
||||
public class STSFinder extends EclipseFinder {
|
||||
@Override protected IdeLocation createLocation(String guess) throws CorruptedIdeLocationException {
|
||||
return new STSLocationProvider().create0(guess);
|
||||
}
|
||||
|
||||
@Override protected String getDirName() {
|
||||
return "sts";
|
||||
}
|
||||
|
||||
@Override protected String getMacExecutableName() {
|
||||
return "STS.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixExecutableName() {
|
||||
return "STS";
|
||||
}
|
||||
|
||||
@Override protected String getWindowsExecutableName() {
|
||||
return "STS.exe";
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnWindows() {
|
||||
return Arrays.asList("\\", "\\springsource", "\\Program Files", "\\Program Files (x86)", "\\Program Files\\springsource", "\\Program Files (x86)\\springsource", System.getProperty("user.home", "."), System.getProperty("user.home", ".") + "\\springsource");
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnMac() {
|
||||
return Arrays.asList("/Applications", "/Applications/springsource", System.getProperty("user.home", "."), System.getProperty("user.home", ".") + "/springsource");
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnUnix() {
|
||||
return Arrays.asList(System.getProperty("user.home", "."), System.getProperty("user.home", ".") + "/springsource");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,49 +21,23 @@
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Collections;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeLocation;
|
||||
import lombok.installer.IdeLocationProvider;
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
@ProviderFor(IdeLocationProvider.class)
|
||||
public class STSLocationProvider extends EclipseLocationProvider {
|
||||
@Override protected List<String> getEclipseExecutableNames() {
|
||||
return Arrays.asList("sts.app", "sts.exe", "stsc.exe", "sts");
|
||||
}
|
||||
public class STSLocationProvider extends EclipseProductLocationProvider {
|
||||
|
||||
@Override protected String getIniName() {
|
||||
return "STS.ini";
|
||||
}
|
||||
private static final EclipseProductDescriptor STS = new StandardProductDescriptor("STS",
|
||||
"STS",
|
||||
"sts",
|
||||
STSLocationProvider.class.getResource("STS.png"),
|
||||
Collections.singleton("springsource")
|
||||
);
|
||||
|
||||
@Override protected IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException {
|
||||
return new STSLocation(name, ini);
|
||||
}
|
||||
|
||||
@Override protected String getMacAppName() {
|
||||
return "STS.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixAppName() {
|
||||
return "STS";
|
||||
}
|
||||
|
||||
@Override public Pattern getLocationSelectors(OS os) {
|
||||
switch (os) {
|
||||
case MAC_OS_X:
|
||||
return Pattern.compile("^(sts|sts\\.ini|sts\\.app)$", Pattern.CASE_INSENSITIVE);
|
||||
case WINDOWS:
|
||||
return Pattern.compile("^(stsc?\\.exe|sts\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
default:
|
||||
case UNIX:
|
||||
return Pattern.compile("^(sts|sts\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
public STSLocationProvider() {
|
||||
super(STS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.installer.OsUtils;
|
||||
|
||||
public class StandardProductDescriptor implements EclipseProductDescriptor {
|
||||
|
||||
private static final String USER_HOME = System.getProperty("user.home", ".");
|
||||
private static final String[] WINDOWS_ROOTS = {"\\", "\\Program Files", "\\Program Files (x86)", USER_HOME};
|
||||
private static final String[] MAC_ROOTS = {"/Applications", USER_HOME};
|
||||
private static final String[] UNIX_ROOTS = {USER_HOME};
|
||||
|
||||
private final String productName;
|
||||
private final String windowsName;
|
||||
private final String unixName;
|
||||
private final String macAppName;
|
||||
private final List<String> executableNames;
|
||||
private final List<String> sourceDirsOnWindows;
|
||||
private final List<String> sourceDirsOnMac;
|
||||
private final List<String> sourceDirsOnUnix;
|
||||
private final String iniFileName;
|
||||
private final Pattern locationSelectors;
|
||||
private final String directoryName;
|
||||
private final URL ideIcon;
|
||||
|
||||
public StandardProductDescriptor(String productName, String baseName, String directoryName, URL ideIcon, Collection<String> alternativeDirectoryNames) {
|
||||
this.productName = productName;
|
||||
this.windowsName = baseName + ".exe";
|
||||
this.unixName = baseName;
|
||||
this.macAppName = baseName + ".app";
|
||||
this.executableNames = executableNames(baseName);
|
||||
this.sourceDirsOnWindows = generateAlternatives(WINDOWS_ROOTS, "\\", alternativeDirectoryNames);
|
||||
this.sourceDirsOnMac = generateAlternatives(MAC_ROOTS, "/", alternativeDirectoryNames);
|
||||
this.sourceDirsOnUnix = generateAlternatives(UNIX_ROOTS, "/", alternativeDirectoryNames);
|
||||
this.iniFileName = baseName + ".ini";
|
||||
this.locationSelectors = getLocationSelectors(baseName);
|
||||
this.directoryName = directoryName.toLowerCase();
|
||||
this.ideIcon = ideIcon;
|
||||
}
|
||||
|
||||
@Override public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
@Override public String getWindowsExecutableName() {
|
||||
return windowsName;
|
||||
}
|
||||
|
||||
@Override public String getUnixAppName() {
|
||||
return unixName;
|
||||
}
|
||||
|
||||
@Override public String getMacAppName() {
|
||||
return macAppName;
|
||||
}
|
||||
|
||||
@Override public String getDirectoryName() {
|
||||
return directoryName;
|
||||
}
|
||||
|
||||
@Override public List<String> getExecutableNames() {
|
||||
return executableNames;
|
||||
}
|
||||
|
||||
@Override public List<String> getSourceDirsOnWindows() {
|
||||
return sourceDirsOnWindows;
|
||||
}
|
||||
|
||||
@Override public List<String> getSourceDirsOnMac() {
|
||||
return sourceDirsOnMac;
|
||||
}
|
||||
|
||||
@Override public List<String> getSourceDirsOnUnix() {
|
||||
return sourceDirsOnUnix;
|
||||
}
|
||||
|
||||
@Override public String getIniFileName() {
|
||||
return iniFileName;
|
||||
}
|
||||
|
||||
@Override public Pattern getLocationSelectors() {
|
||||
return locationSelectors;
|
||||
}
|
||||
|
||||
@Override public URL getIdeIcon() {
|
||||
return ideIcon;
|
||||
}
|
||||
|
||||
private static Pattern getLocationSelectors(String baseName) {
|
||||
return Pattern.compile(String.format(platformPattern(), baseName.toLowerCase()), Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
|
||||
private static String platformPattern() {
|
||||
switch (OsUtils.getOS()) {
|
||||
case MAC_OS_X:
|
||||
return "^(%s|%<s\\.ini|%<s\\.app)$";
|
||||
case WINDOWS:
|
||||
return "^(%sc?\\.exe|%<s\\.ini)$";
|
||||
default:
|
||||
case UNIX:
|
||||
return "^(%s|%<s\\.ini)$";
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> executableNames(String baseName) {
|
||||
String base = baseName.toLowerCase();
|
||||
return Collections.unmodifiableList(Arrays.asList(base, base + ".app", base + ".exe", base + "c.exe"));
|
||||
}
|
||||
|
||||
private static List<String> generateAlternatives(String[] roots, String pathSeparator, Collection<String> alternatives) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
for (String root : roots) {
|
||||
result.add(concat(root, pathSeparator, ""));
|
||||
for (String alternative : alternatives) {
|
||||
result.add(concat(root, pathSeparator, alternative));
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
private static String concat(String base, String pathSeparator, String alternative) {
|
||||
if (alternative.isEmpty()) {
|
||||
return base;
|
||||
}
|
||||
if (base.endsWith(pathSeparator)) {
|
||||
return base + alternative.replaceAll("[\\/]", "\\" + pathSeparator);
|
||||
}
|
||||
return base + pathSeparator + alternative.replaceAll("[\\/]", "\\" + pathSeparator);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user