Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler resolution for long build numbers #883

Merged
merged 6 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## next
- Fixed JBR resolving for MacOSX M1
- Fix compiler resolution for long build numbers [#883](../../issues/883)

## 1.3.1
- Fixed execution bit filter when extracting Rider [RIDER-72922](https://youtrack.jetbrains.com/issue/RIDER-72922)
Expand Down
22 changes: 18 additions & 4 deletions src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,9 @@ open class IntelliJPlugin : Plugin<Project> {
val isEap = localPath?.let { ideProductInfo(ideaDependency.classes)?.versionSuffix == "EAP" } ?: false
val eapSuffix = "-EAP-SNAPSHOT".takeIf { isEap } ?: ""

IdeVersion.createIdeVersion(ideaDependency.buildNumber).asStringWithoutProductCode() + eapSuffix
IdeVersion.createIdeVersion(ideaDependency.buildNumber)
.stripExcessComponents()
.asStringWithoutProductCode() + eapSuffix
}
})
ideaDependency.convention(setupDependenciesTask.idea)
Expand All @@ -719,9 +721,8 @@ open class IntelliJPlugin : Plugin<Project> {
})
compilerClassPathFromMaven.convention(project.provider {
val compilerVersion = compilerVersion.get()
if (compilerVersion == IntelliJPluginConstants.DEFAULT_IDEA_VERSION || Version.parse(compilerVersion) >= Version(183,
3795,
13)
if (compilerVersion == IntelliJPluginConstants.DEFAULT_IDEA_VERSION ||
Version.parse(compilerVersion) >= Version(183, 3795, 13)
) {
dependenciesDownloader.downloadFromMultipleRepositories(logCategory(), {
create(
Expand Down Expand Up @@ -1160,4 +1161,17 @@ open class IntelliJPlugin : Plugin<Project> {
private fun ProjectSettings.taskTriggers(
action: TaskTriggersConfig.() -> Unit,
) = (this as ExtensionAware).extensions.configure("taskTriggers", action)

/**
* Strips an [IdeVersion] of components other than SNAPSHOT and * that exceeds patch, i.e. "excess" in the following
* version will be stripped: major.minor.patch.excess.SNAPSHOT.
* This is needed due to recent versions of Android Studio having additional components in its build number; e.g.
* 2020.3.1-patch-4 has build number AI-203.7717.56.2031.7935034, with these additional components instrumentCode
* fails because it tries to resolve a non-existent compiler version (203.7717.56.2031.7935034). This function
* strips it down so that only major minor and patch are used.
*/
private fun IdeVersion.stripExcessComponents(): IdeVersion = asStringWithoutProductCode().split(".")
.filterIndexed { index, component -> index < 3 || component == "SNAPSHOT" || component == "*" }
.joinToString(prefix = "$productCode-", separator = ".")
.let(IdeVersion::createIdeVersion)
}