Reorder the common kotlin compiler potential locations

This commit is contained in:
Erik C. Thauvin 2025-03-21 21:24:44 -07:00
parent a57ae52a1c
commit e7d0ada68c
Signed by: erik
GPG key ID: 776702A6A2DA330E
2 changed files with 18 additions and 13 deletions

View file

@ -44,13 +44,14 @@ for all available configuration options.
Please make sure the Kotlin compiler is [installed](https://kotlinlang.org/docs/command-line.html#install-the-compiler). Please make sure the Kotlin compiler is [installed](https://kotlinlang.org/docs/command-line.html#install-the-compiler).
The plugin will look in common locations such as: The extension will look in common locations such as:
- `KOTLIN_HOME`
- `PATH` - `KOTLIN_HOME`
- SDKMAN! - `PATH`
- Homebrew - [SDKMAN!](https://sdkman.io/)
- JetBrains Toolbox (IntelliJ IDEA, Android Studio) - [Homebrew](https://brew.sh/)
- etc. - [JetBrains Toolbox](https://www.jetbrains.com/toolbox-app/) (IntelliJ IDEA, Android Studio)
- etc.
You can also manually configure the Kotlin home location as follows: You can also manually configure the Kotlin home location as follows:

View file

@ -79,6 +79,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
* Locates the Kotlin compiler (kotlinc) executable. * Locates the Kotlin compiler (kotlinc) executable.
* *
* @return The path to the kotlinc executable, or {@code kotlinc}/{@code kotlinc.bat} if not found. * @return The path to the kotlinc executable, or {@code kotlinc}/{@code kotlinc.bat} if not found.
* @since 1.0.5
*/ */
public static String findKotlincPath() { public static String findKotlincPath() {
String kotlincPath; String kotlincPath;
@ -108,10 +109,6 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
List<String> commonPaths = new ArrayList<>(); List<String> commonPaths = new ArrayList<>();
if (isLinux()) { if (isLinux()) {
commonPaths.add("/usr/bin");
commonPaths.add("/usr/local/bin");
commonPaths.add("/usr/local/kotlin/bin");
commonPaths.add("/opt/kotlin/bin");
var userHome = System.getProperty("user.home"); var userHome = System.getProperty("user.home");
if (userHome != null) { if (userHome != null) {
commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN! commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN!
@ -119,6 +116,10 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/Kotlin/bin"); // Toolbox IDEA CE commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/Kotlin/bin"); // Toolbox IDEA CE
commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/android-studio/plugins/Kotlin/bin"); // Toolbox Android Studio commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/android-studio/plugins/Kotlin/bin"); // Toolbox Android Studio
} }
commonPaths.add("/usr/bin");
commonPaths.add("/usr/local/bin");
commonPaths.add("/usr/local/kotlin/bin");
commonPaths.add("/opt/kotlin/bin");
} else if (isWindows()) { } else if (isWindows()) {
var localAppData = System.getenv("LOCALAPPDATA"); var localAppData = System.getenv("LOCALAPPDATA");
if (localAppData != null) { if (localAppData != null) {
@ -131,8 +132,6 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
commonPaths.add(programFiles + File.separator + "Kotlin"); commonPaths.add(programFiles + File.separator + "Kotlin");
} }
} else if (isMacOS()) { } else if (isMacOS()) {
commonPaths.add("/usr/local/bin"); // Homebrew
commonPaths.add("/opt/homebrew/bin"); // Homebrew
var userHome = System.getProperty("user.home"); var userHome = System.getProperty("user.home");
if (userHome != null) { if (userHome != null) {
commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN! commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN!
@ -140,6 +139,8 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
commonPaths.add("/Applications/IntelliJ IDEA Ultimate.app/Contents/plugins/Kotlin/bin"); //IntelliJ IDEA Ultimate commonPaths.add("/Applications/IntelliJ IDEA Ultimate.app/Contents/plugins/Kotlin/bin"); //IntelliJ IDEA Ultimate
commonPaths.add("/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/bin"); //IntelliJ IDEA commonPaths.add("/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/bin"); //IntelliJ IDEA
commonPaths.add("/Applications/Android Studio.app/Contents/plugins/Kotlin/bin"); //Android Studio commonPaths.add("/Applications/Android Studio.app/Contents/plugins/Kotlin/bin"); //Android Studio
commonPaths.add("/usr/local/bin"); // Homebrew
commonPaths.add("/opt/homebrew/bin"); // Homebrew
} }
for (var location : commonPaths) { for (var location : commonPaths) {
@ -181,6 +182,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
* Determines if the operating system is Linux. * Determines if the operating system is Linux.
* *
* @return true if the operating system is Linux, false otherwise. * @return true if the operating system is Linux, false otherwise.
* @since 1.0.5
*/ */
public static boolean isLinux() { public static boolean isLinux() {
return OS_NAME != null && (OS_NAME.contains("linux") || OS_NAME.contains("unix")); // Consider Unix-like systems as well. return OS_NAME != null && (OS_NAME.contains("linux") || OS_NAME.contains("unix")); // Consider Unix-like systems as well.
@ -190,6 +192,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
* Determines if the current operating system is macOS. * Determines if the current operating system is macOS.
* *
* @return true if the OS is macOS, false otherwise. * @return true if the OS is macOS, false otherwise.
* @since 1.0.5
*/ */
public static boolean isMacOS() { public static boolean isMacOS() {
return OS_NAME != null && (OS_NAME.contains("mac") || OS_NAME.contains("darwin")); return OS_NAME != null && (OS_NAME.contains("mac") || OS_NAME.contains("darwin"));
@ -209,6 +212,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
* Determines if the current operating system is Windows. * Determines if the current operating system is Windows.
* *
* @return true if the operating system is Windows, false otherwise. * @return true if the operating system is Windows, false otherwise.
* @since 1.0.5
*/ */
public static boolean isWindows() { public static boolean isWindows() {
return OS_NAME != null && OS_NAME.contains("win"); return OS_NAME != null && OS_NAME.contains("win");