Skip to content

Commit

Permalink
Fixed resolving Android Studio releases URL for Windows #1551
Browse files Browse the repository at this point in the history
  • Loading branch information
hsz committed Mar 15, 2024
1 parent 4a87eba commit 915bdb3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- Fix for: `coroutinesJavaAgentPath` specifies file `.../build/tmp/initializeIntelliJPlugin/coroutines-javaagent.jar` which doesn't exist
- Fixed resolving Android Studio releases URL for Windows [#1551](../../issues/1551)

## [1.17.2] - 2024-02-20

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,22 +359,28 @@ abstract class IdeaDependencyManager @Inject constructor(
it.version == version || it.build == "$PLATFORM_TYPE_ANDROID_STUDIO-$version"
} ?: throw GradleException("Cannot resolve Android Studio with provided version: $version")

val arch = System.getProperty("os.arch")
val hasAppleM1Link by lazy { release.downloads.any { it.link.contains("-mac_arm.zip") } }
val suffix = with(OperatingSystem.current()) {
val os = with(OperatingSystem.current()) {
when {
isMacOsX -> when {
arch == "aarch64" && hasAppleM1Link -> "-mac_arm.zip"
else -> "-mac.zip"
}

isLinux -> "-linux.tar.gz"
else -> "-windows.zip"
isMacOsX -> "mac"
isLinux -> "linux"
isWindows -> "windows"
else -> throw GradleException("Unsupported OS: $this")
}
}
val supportedExtensions = setOf("zip", "tar.gz", "sit")
val url = release.downloads
.find { it.link.endsWith(suffix) }
?.link
.asSequence()
.map { it.link }
.filter { link -> supportedExtensions.any { link.endsWith(it) } }
.filter { link -> link.substringAfterLast('/').contains(os) }
.sortedWith(compareByDescending { link ->
val arch = when {
os == "mac" && System.getProperty("os.arch") == "aarch64" -> "arm"
else -> ""
}
link.substringAfterLast('/').contains(arch)
})
.firstOrNull()
?: throw GradleException("Cannot resolve Android Studio with provided version: $version")

ivyRepository(url)
Expand Down

0 comments on commit 915bdb3

Please sign in to comment.