Skip to content

Commit 2a406fe

Browse files
committed
Add snap locations to common paths
1 parent 5a3c77a commit 2a406fe

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/main/java/rife/bld/extension/CompileKotlinOperation.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,36 @@ public static String findKotlincPath(boolean isSilent) {
122122
}
123123

124124
// Common installation paths (e.g., SDKMAN!, IntelliJ IDEA, etc.)
125-
var commonPaths = new HashMap<String, String>(); //NOPMD no concurrent access
125+
var commonPaths = new LinkedHashMap<String, String>(); //NOPMD no concurrent access
126126

127127
if (isLinux()) {
128128
var userHome = System.getProperty("user.home");
129129
if (userHome != null) {
130-
commonPaths.put(userHome + "/.sdkman/candidates/kotlin/current/bin", "SDKMAN");
131-
commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/plugins/Kotlin/kotlinc/bin",
132-
"IntelliJ IDEA Ultimate");
133-
commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/Kotlin/kotlinc/bin",
134-
"IntelliJ IDEA Community Edition");
135-
commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/android-studio/plugins/Kotlin/kotlinc/bin",
136-
"Android Studio");
130+
commonPaths.put(userHome + "/.sdkman/candidates/kotlin/current/bin", "SDKMAN!");
137131
}
132+
commonPaths.put("/snap/bin", "Kotlin (Snap)");
138133
commonPaths.put("/usr/bin", null);
139134
commonPaths.put("/usr/share", null);
140135
commonPaths.put("/usr/local/bin", null);
141136
commonPaths.put("/usr/local/kotlin/bin", null);
142137
commonPaths.put("/usr/share/kotlin/bin/", null);
143138
commonPaths.put("/opt/kotlin/bin", null);
139+
if (userHome != null) {
140+
commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/plugins/Kotlin/kotlinc/bin",
141+
"IntelliJ IDEA Ultimate");
142+
commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/Kotlin/kotlinc/bin",
143+
"IntelliJ IDEA Community Edition");
144+
commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/android-studio/plugins/Kotlin/kotlinc/bin",
145+
"Android Studio");
146+
}
147+
commonPaths.put("/snap/intellij-idea-ultimate/current/commons/plugins/Kotlin/kotlinc/bin",
148+
"IntelliJ IDEA Ultimate (Snap)");
149+
commonPaths.put("/snap/intellij-idea-community/current/commons/plugins/Kotlin/kotlinc/bin",
150+
"IntelliJ IDEA Community Edition (Snap)");
151+
commonPaths.put("/snap/android-studio/current/android-studio/commons/plugins/Kotlin/kotlinc/bin",
152+
"Android Studio (Snap)");
144153
} else if (isWindows()) {
145-
commonPaths.put("C:\\tools\\kotlinc", null);
154+
commonPaths.put("C:\\tools\\kotlinc\\bin", null);
146155
var localAppData = System.getenv("LOCALAPPDATA");
147156
if (localAppData != null) {
148157
commonPaths.put(localAppData + "\\Programs\\IntelliJ IDEA Ultimate\\plugins\\Kotlin\\kotlinc\\bin",
@@ -154,21 +163,21 @@ public static String findKotlincPath(boolean isSilent) {
154163
}
155164
var programFiles = System.getenv("ProgramFiles");
156165
if (programFiles != null) {
157-
commonPaths.put(programFiles + File.separator + "Kotlin", "null");
166+
commonPaths.put(programFiles + "\\Kotlin\\bin", null);
158167
}
159168
} else if (isMacOS()) {
160169
var userHome = System.getProperty("user.home");
161170
if (userHome != null) {
162171
commonPaths.put(userHome + "/.sdkman/candidates/kotlin/current/bin", "SDKMAN!");
163172
}
173+
commonPaths.put("/opt/homebrew/bin", "Homebrew");
174+
commonPaths.put("/usr/local/bin", null);
164175
commonPaths.put("/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/kotlinc/bin/",
165176
"IntelliJ IDEA");
166177
commonPaths.put("/Applications/IntelliJ IDEA Community Edition.app/Contents/plugins/Kotlin/kotlinc/bin/",
167178
"IntelliJ IDEA Community Edition");
168179
commonPaths.put("/Applications/Android Studio.app/Contents/plugins/Kotlin/kotlinc/bin",
169180
"Android Studio");
170-
commonPaths.put("/usr/local/bin", null);
171-
commonPaths.put("/opt/homebrew/bin", "Homebrew");
172181
}
173182

174183
for (var path : commonPaths.keySet()) {
@@ -178,9 +187,6 @@ public static String findKotlincPath(boolean isSilent) {
178187
return kotlincPath;
179188
}
180189
}
181-
commonPaths.forEach((path, where) -> {
182-
183-
});
184190

185191
// Try 'which' or 'where' commands (less reliable but sometimes works)
186192
try {

0 commit comments

Comments
 (0)