diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-08 06:06:46 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-08 06:06:46 +0100 |
commit | c3a3c09f4fd00b83814c1949fa5282ac9c595fa3 (patch) | |
tree | 0e28c636dca33caa09709291e3011cacb008de94 | |
parent | 48404894d8e4c875346677c6f68fff742f314763 (diff) | |
download | lombok-c3a3c09f4fd00b83814c1949fa5282ac9c595fa3.tar.gz lombok-c3a3c09f4fd00b83814c1949fa5282ac9c595fa3.tar.bz2 lombok-c3a3c09f4fd00b83814c1949fa5282ac9c595fa3.zip |
Added support for SpringSource Tool Suite, which, given that its based on eclipse, was just a matter of updating the installer.
Any future tools that are based on eclipse (and eclipse's JDT) should be very easy to add to the installer now.
-rw-r--r-- | doc/changelog.markdown | 1 | ||||
-rw-r--r-- | src/installer/lombok/installer/eclipse/EclipseFinder.java | 150 | ||||
-rw-r--r-- | src/installer/lombok/installer/eclipse/EclipseLocation.java | 22 | ||||
-rw-r--r-- | src/installer/lombok/installer/eclipse/EclipseLocationProvider.java | 62 | ||||
-rw-r--r-- | src/installer/lombok/installer/eclipse/STS.png | bin | 0 -> 1807 bytes | |||
-rw-r--r-- | src/installer/lombok/installer/eclipse/STSFinder.java | 71 | ||||
-rw-r--r-- | src/installer/lombok/installer/eclipse/STSLocation.java | 45 | ||||
-rw-r--r-- | src/installer/lombok/installer/eclipse/STSLocationProvider.java | 48 |
8 files changed, 306 insertions, 93 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 9d98e46d..bcbf4112 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -8,6 +8,7 @@ Lombok Changelog * lombok now has various command-line accessible utilities bundled with it. Run `java -jar lombok.jar --help` to see them. Included (aside from the already mentioned delombok): * Ability to create a tiny jar named lombok-runtime.jar with runtime dependencies. The lombok transformations that have a runtime dependency on this jar can be listed as well. Run `java -jar lombok.jar createRuntime --help` for more information. * Scriptable command line install and uninstall options. Run `java -jar lombok.jar install --help` (or `uninstall`, of course) for more information. Technically this support has been there in earlier versions, but the command line options are now much more lenient, not to mention more visible. +* lombok now works on Springsource Tool Suite. [Issue #22](http://code.google.com/p/projectlombok/issues/detail?id=22) * Erroneous use of lombok in Eclipse (adding it to a project as an annotation processor, which is not how lombok is to be used on Eclipse) now generates a useful warning message with helpful information, instead of a confusing error hidden in the logs. [Issue #53](http://code.google.com/p/projectlombok/issues/detail?id=53) * FIXED: Regression bug where you would occasionally see errors with the gist 'loader constraint violation: when resolving...', such as when opening the help system, starting the diff editor, or, rarely, opening any java source file. [Issue #68](http://code.google.com/p/projectlombok/issues/detail?id=68) * FIXED: @SneakyThrows without any parameters should default to `Throwable.class` but it didn't do anything in javac. [Issue #73](http://code.google.com/p/projectlombok/issues/detail?id=73) diff --git a/src/installer/lombok/installer/eclipse/EclipseFinder.java b/src/installer/lombok/installer/eclipse/EclipseFinder.java index 256e6221..d520b1c4 100644 --- a/src/installer/lombok/installer/eclipse/EclipseFinder.java +++ b/src/installer/lombok/installer/eclipse/EclipseFinder.java @@ -25,6 +25,7 @@ import static java.util.Arrays.asList; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import lombok.installer.IdeFinder; @@ -35,6 +36,39 @@ import org.mangosdk.spi.ProviderFor; @ProviderFor(IdeFinder.class) public class EclipseFinder extends IdeFinder { + /** should be lowercase! */ + protected String getDirName() { + return "eclipse"; + } + + 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", System.getProperty("user.home", ".")); + } + + protected List<String> getSourceDirsOnMac() { + return Arrays.asList("/Applications", System.getProperty("user.home", ".")); + } + + protected List<String> getSourceDirsOnUnix() { + return Arrays.asList(System.getProperty("user.home", ".")); + } + /** * Returns a list of paths of Eclipse installations. * Eclipse installations are found by checking for the existence of 'eclipse.exe' in the following locations: @@ -46,7 +80,7 @@ public class EclipseFinder extends IdeFinder { * Where 'X' is tried for all local disk drives, unless there's a problem calling fsutil, in which case only * C: is tried. */ - private static void findEclipseOnWindows(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) { + private void findEclipseOnWindows(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) { List<String> driveLetters = asList("C"); try { driveLetters = getDrivesOnWindows(); @@ -58,48 +92,33 @@ public class EclipseFinder extends IdeFinder { //such as an unformatted drive causing a NullPointerException on listFiles. Best action is almost invariably to just //continue onwards. for (String letter : driveLetters) { - try { - File f = new File(letter + ":\\"); - for (File dir : f.listFiles()) { - if (!dir.isDirectory()) continue; - try { - if (dir.getName().toLowerCase().contains("eclipse")) { - String eclipseLocation = findEclipseOnWindows1(dir); - if (eclipseLocation != null) { - try { - locations.add(EclipseLocationProvider.create0(eclipseLocation)); - } catch (CorruptedIdeLocationException e) { - problems.add(e); - } - } - } - } catch (Exception ignore) {} - - try { - if (dir.getName().toLowerCase().contains("program files")) { - for (File dir2 : dir.listFiles()) { - if (!dir2.isDirectory()) continue; - if (dir2.getName().toLowerCase().contains("eclipse")) { - String eclipseLocation = findEclipseOnWindows1(dir2); - if (eclipseLocation != null) { - try { - locations.add(EclipseLocationProvider.create0(eclipseLocation)); - } catch (CorruptedIdeLocationException e) { - problems.add(e); - } + for (String possibleSource : getSourceDirsOnWindows()) { + try { + File f = new File(letter + ":" + possibleSource); + if (!f.isDirectory()) continue; + for (File dir : f.listFiles()) { + if (!dir.isDirectory()) continue; + try { + if (dir.getName().toLowerCase().contains(getDirName())) { + String eclipseLocation = findEclipseOnWindows1(dir); + if (eclipseLocation != null) { + try { + locations.add(createLocation(eclipseLocation)); + } catch (CorruptedIdeLocationException e) { + problems.add(e); } } } - } - } catch (Exception ignore) {} - } - } catch (Exception ignore) {} + } catch (Exception ignore) {} + } + } catch (Exception ignore) {} + } } } /** Checks if the provided directory contains 'eclipse.exe', and if so, returns the directory, otherwise null. */ - private static String findEclipseOnWindows1(File dir) { - if (new File(dir, "eclipse.exe").isFile()) return dir.getAbsolutePath(); + private String findEclipseOnWindows1(File dir) { + if (new File(dir, getWindowsExecutableName()).isFile()) return dir.getAbsolutePath(); return null; } @@ -137,33 +156,35 @@ public class EclipseFinder extends IdeFinder { File d; - d = new File("/usr/bin/eclipse"); + d = new File("/usr/bin/" + getUnixExecutableName()); if (d.exists()) guesses.add(d.getPath()); - d = new File("/usr/local/bin/eclipse"); + d = new File("/usr/local/bin/" + getUnixExecutableName()); if (d.exists()) guesses.add(d.getPath()); - d = new File(System.getProperty("user.home", "."), "bin/eclipse"); + d = new File(System.getProperty("user.home", "."), "bin/" + getUnixExecutableName()); if (d.exists()) guesses.add(d.getPath()); - findEclipseInSubDir("/usr/local/share", guesses); - findEclipseInSubDir("/usr/local", guesses); - findEclipseInSubDir("/usr/share", guesses); - findEclipseInSubDir(System.getProperty("user.home", "."), guesses); + findEclipseOnUnix1("/usr/local/share", guesses); + findEclipseOnUnix1("/usr/local", guesses); + findEclipseOnUnix1("/usr/share", guesses); + for (String possibleSourceDir : getSourceDirsOnUnix()) { + findEclipseOnUnix1(possibleSourceDir, guesses); + } for (String guess : guesses) { try { - locations.add(EclipseLocationProvider.create0(guess)); + locations.add(createLocation(guess)); } catch (CorruptedIdeLocationException e) { problems.add(e); } } } - private void findEclipseInSubDir(String dir, List<String> guesses) { + private void findEclipseOnUnix1(String dir, List<String> guesses) { File d = new File(dir); if (!d.isDirectory()) return; for (File f : d.listFiles()) { - if (f.isDirectory() && f.getName().toLowerCase().contains("eclipse")) { - File possible = new File(f, "eclipse"); + if (f.isDirectory() && f.getName().toLowerCase().contains(getDirName())) { + File possible = new File(f, getUnixExecutableName()); if (possible.exists()) guesses.add(possible.getAbsolutePath()); } } @@ -173,26 +194,31 @@ public class EclipseFinder extends IdeFinder { * Scans /Applications for any folder named 'Eclipse' */ private void findEclipseOnMac(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) { - for (File dir : new File("/Applications").listFiles()) { - if (!dir.isDirectory()) continue; - if (dir.getName().toLowerCase().equals("eclipse.app")) { - //This would be kind of an unorthodox Eclipse installation, but if Eclipse ever - //moves to this more maclike installation concept, our installer can still handle it. + for (String possibleSourceDir : getSourceDirsOnMac()) { + File[] list = new File(possibleSourceDir).listFiles(); + if (list != null) for (File dir : list) { + findEclipseOnMac1(dir, locations, problems); + } + } + } + + private void findEclipseOnMac1(File f, List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) { + if (!f.isDirectory()) return; + if (f.getName().toLowerCase().equals(getMacExecutableName().toLowerCase())) { + try { + locations.add(createLocation(f.getParent())); + } catch (CorruptedIdeLocationException e) { + problems.add(e); + } + } + if (f.getName().toLowerCase().contains(getDirName())) { + if (new File(f, getMacExecutableName()).exists()) { try { - locations.add(EclipseLocationProvider.create0("/Applications")); + locations.add(createLocation(f.toString())); } catch (CorruptedIdeLocationException e) { problems.add(e); } } - if (dir.getName().toLowerCase().contains("eclipse")) { - if (new File(dir, "Eclipse.app").exists()) { - try { - locations.add(EclipseLocationProvider.create0(dir.toString())); - } catch (CorruptedIdeLocationException e) { - problems.add(e); - } - } - } } } } diff --git a/src/installer/lombok/installer/eclipse/EclipseLocation.java b/src/installer/lombok/installer/eclipse/EclipseLocation.java index 7b3a5536..13142740 100644 --- a/src/installer/lombok/installer/eclipse/EclipseLocation.java +++ b/src/installer/lombok/installer/eclipse/EclipseLocation.java @@ -45,13 +45,21 @@ 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 final class EclipseLocation extends IdeLocation { +public class EclipseLocation extends IdeLocation { private final String name; private final File eclipseIniPath; private volatile 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 { this.name = nameOfLocation; this.eclipseIniPath = pathToEclipseIni; @@ -59,8 +67,8 @@ public final class EclipseLocation extends IdeLocation { this.hasLombok = checkForLombok(eclipseIniPath); } catch (IOException e) { throw new CorruptedIdeLocationException( - "I can't read the configuration file of the Eclipse installed at " + name + "\n" + - "You may need to run this installer with root privileges if you want to modify that Eclipse.", "eclipse", e); + "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); } } @@ -75,8 +83,6 @@ public final class EclipseLocation extends IdeLocation { /** * Returns the name of this location; generally the path to the eclipse executable. - * - * Executables: "eclipse.exe" (Windows), "Eclipse.app" (Mac OS X), "eclipse" (Linux and other unixes). */ @Override public String getName() { @@ -267,7 +273,7 @@ public final 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 Eclipse directory at " + name + generateWriteErrorMessage(), e); + throw new InstallException("I can't write to your " + getTypeName() + " directory at " + name + generateWriteErrorMessage(), e); } /* legacy - delete lombok.eclipse.agent.jar if its there, which lombok no longer uses. */ { @@ -329,10 +335,10 @@ public final class EclipseLocation extends IdeLocation { } if (!installSucceeded) { - throw new InstallException("I can't find the eclipse.ini file. Is this a real Eclipse installation?", null); + throw new InstallException("I can't find the " + getIniFileName() + " file. Is this a real " + getTypeName() + " installation?", null); } - return "If you start eclipse with a custom -vm parameter, you'll need to add:<br>" + + return "If you start " + getTypeName() + " with a custom -vm parameter, you'll need to add:<br>" + "<code>-vmargs -Xbootclasspath/a:lombok.jar -javaagent:lombok.jar</code><br>" + "as parameter as well."; } diff --git a/src/installer/lombok/installer/eclipse/EclipseLocationProvider.java b/src/installer/lombok/installer/eclipse/EclipseLocationProvider.java index 0cef59f4..2a2ca31c 100644 --- a/src/installer/lombok/installer/eclipse/EclipseLocationProvider.java +++ b/src/installer/lombok/installer/eclipse/EclipseLocationProvider.java @@ -26,7 +26,6 @@ import static lombok.installer.IdeLocation.canonical; import java.io.File; import java.io.IOException; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.regex.Pattern; @@ -43,8 +42,25 @@ public class EclipseLocationProvider implements IdeLocationProvider { return create0(path); } - private static final List<String> eclipseExecutableNames = Collections.unmodifiableList(Arrays.asList( - "eclipse.app", "eclipse.exe", "eclipse")); + protected List<String> getEclipseExecutableNames() { + return Arrays.asList("eclipse.app", "eclipse.exe", "eclipse"); + } + + 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, @@ -54,27 +70,27 @@ public class EclipseLocationProvider implements IdeLocationProvider { * If this isn't an Eclipse executable or a directory with an * Eclipse executable. */ - static EclipseLocation create0(String path) throws CorruptedIdeLocationException { + 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 : eclipseExecutableNames) { + for (String possibleExeName : getEclipseExecutableNames()) { File f = new File(p, possibleExeName); if (f.exists()) return findEclipseIniFromExe(f, 0); } - File f = new File(p, "eclipse.ini"); + File f = new File(p, getIniName()); if (f.exists()) return new EclipseLocation(canonical(p), f); } if (p.isFile()) { - if (p.getName().equalsIgnoreCase("eclipse.ini")) { + if (p.getName().equalsIgnoreCase(getIniName())) { return new EclipseLocation(canonical(p.getParentFile()), p); } - if (eclipseExecutableNames.contains(p.getName().toLowerCase())) { + if (getEclipseExecutableNames().contains(p.getName().toLowerCase())) { return findEclipseIniFromExe(p, 0); } } @@ -82,15 +98,15 @@ public class EclipseLocationProvider implements IdeLocationProvider { return null; } - private static EclipseLocation findEclipseIniFromExe(File exePath, int loopCounter) throws CorruptedIdeLocationException { + 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(), "eclipse.ini"); - if (ini.isFile()) return new EclipseLocation(canonical(exePath), ini); + 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(), "Eclipse.app/Contents/MacOS/eclipse.ini"); - if (ini.isFile()) return new EclipseLocation(canonical(exePath), ini); + File ini = new File(exePath.getParentFile(), getMacAppName() + "/Contents/MacOS/" + getIniName()); + if (ini.isFile()) return makeLocation(canonical(exePath), ini); } /* If executable is a soft link, follow it and retry. */ { @@ -99,7 +115,7 @@ public class EclipseLocationProvider implements IdeLocationProvider { String oPath = exePath.getAbsolutePath(); String nPath = exePath.getCanonicalPath(); if (!oPath.equals(nPath)) try { - EclipseLocation loc = findEclipseIniFromExe(new File(nPath), loopCounter + 1); + 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. @@ -114,15 +130,15 @@ public class EclipseLocationProvider implements IdeLocationProvider { path = exePath.getCanonicalPath(); } catch (IOException ignore) { /* We'll stick with getAbsolutePath()'s result then. */ } - if (path.equals("/usr/bin/eclipse") || path.equals("/bin/eclipse") || path.equals("/usr/local/bin/eclipse")) { - File ini = new File("/usr/lib/eclipse/eclipse.ini"); - if (ini.isFile()) return new EclipseLocation(path, ini); - ini = new File("/usr/local/lib/eclipse/eclipse.ini"); - if (ini.isFile()) return new EclipseLocation(path, ini); - ini = new File("/usr/local/etc/eclipse/eclipse.ini"); - if (ini.isFile()) return new EclipseLocation(path, ini); - ini = new File("/etc/eclipse.ini"); - if (ini.isFile()) return new EclipseLocation(path, ini); + 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); } } diff --git a/src/installer/lombok/installer/eclipse/STS.png b/src/installer/lombok/installer/eclipse/STS.png Binary files differnew file mode 100644 index 00000000..b12abf80 --- /dev/null +++ b/src/installer/lombok/installer/eclipse/STS.png diff --git a/src/installer/lombok/installer/eclipse/STSFinder.java b/src/installer/lombok/installer/eclipse/STSFinder.java new file mode 100644 index 00000000..47abb186 --- /dev/null +++ b/src/installer/lombok/installer/eclipse/STSFinder.java @@ -0,0 +1,71 @@ +/* + * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * + * 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\\springsource", System.getProperty("user.home", "."), System.getProperty("user.home", ".") + "\\springsource"); + return Arrays.asList(); + } + + @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"); + } +} diff --git a/src/installer/lombok/installer/eclipse/STSLocation.java b/src/installer/lombok/installer/eclipse/STSLocation.java new file mode 100644 index 00000000..912eb73c --- /dev/null +++ b/src/installer/lombok/installer/eclipse/STSLocation.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * + * 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 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"; + } +} diff --git a/src/installer/lombok/installer/eclipse/STSLocationProvider.java b/src/installer/lombok/installer/eclipse/STSLocationProvider.java new file mode 100644 index 00000000..220eb184 --- /dev/null +++ b/src/installer/lombok/installer/eclipse/STSLocationProvider.java @@ -0,0 +1,48 @@ +package lombok.installer.eclipse; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +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"); + } + + @Override protected String getIniName() { + return "STS.ini"; + } + + @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); + } + } +} |