-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a specific version of runtime, instead of using Gradle's variant …
…resolution. Previously we added the KotlinVersion attribute to all configurations in the module where SKIE was applied to. That unfortunately breaks transitive dependencies, when other modules would depend on it, as those wouldn't have the attribute. This change no longer relies on the attribute and instead targets an artifact for the specific version directly.
- Loading branch information
1 parent
febe2f6
commit 8eb3068
Showing
4 changed files
with
77 additions
and
11 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...oader/src/main/kotlin-compiler-attribute/co/touchlab/skie/gradle/KotlinCompilerVersion.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,44 @@ | ||
package co.touchlab.skie.gradle | ||
|
||
import org.gradle.api.Named | ||
import org.gradle.api.artifacts.dsl.DependencyHandler | ||
import org.gradle.api.attributes.Attribute | ||
import org.gradle.api.attributes.AttributeDisambiguationRule | ||
import org.gradle.api.attributes.MultipleCandidatesDetails | ||
import org.gradle.api.logging.Logging | ||
|
||
interface KotlinCompilerVersion : Named { | ||
companion object { | ||
|
||
val attribute = Attribute.of("co.touchlab.skie.kotlin.compiler.version", KotlinCompilerVersion::class.java) | ||
|
||
fun registerIn(dependencies: DependencyHandler, currentKotlinVersion: String) { | ||
dependencies.attributesSchema.attribute(attribute) { | ||
disambiguationRules.add(DisambiguationRule::class.java) { | ||
params(currentKotlinVersion) | ||
} | ||
} | ||
} | ||
} | ||
|
||
class DisambiguationRule( | ||
private val currentKotlinVersion: String, | ||
): AttributeDisambiguationRule<KotlinCompilerVersion> { | ||
override fun execute(details: MultipleCandidatesDetails<KotlinCompilerVersion>) { | ||
val correctCandidate = details.candidateValues.lastOrNull { | ||
it.name == currentKotlinVersion | ||
} | ||
|
||
if (correctCandidate != null) { | ||
details.closestMatch(correctCandidate) | ||
} else { | ||
// This should've already been caught by SKIE Plugin Loader, but we'll let the user know just in case. | ||
log.error("Could not find a Kotlin compiler version matching the current Kotlin version ($currentKotlinVersion)!") | ||
} | ||
} | ||
|
||
companion object { | ||
val log = Logging.getLogger("KotlinCompilerVersion.DisambiguationRule") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters