File tree Expand file tree Collapse file tree
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com.github.jengelman.gradle.plugins.shadow
22
33import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin.Companion.registerShadowJarCommon
4+ import com.github.jengelman.gradle.plugins.shadow.internal.isAtLeastKgpVersion
45import com.github.jengelman.gradle.plugins.shadow.internal.mainClassAttributeKey
56import kotlin.collections.contains
67import org.gradle.api.Plugin
78import org.gradle.api.Project
89import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
910import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
10- import org.jetbrains.kotlin.gradle.dsl.KotlinVersion as KgpVersion
1111import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
1212
1313public abstract class ShadowKmpPlugin : Plugin <Project > {
@@ -30,7 +30,7 @@ public abstract class ShadowKmpPlugin : Plugin<Project> {
3030 },
3131 )
3232
33- if (KgpVersion . DEFAULT < KgpVersion . KOTLIN_2_1 ) return @registerShadowJarCommon
33+ if (! isAtLeastKgpVersion( 2 , 1 , 0 ) ) return @registerShadowJarCommon
3434
3535 @OptIn(ExperimentalKotlinGradlePluginApi ::class )
3636 target.mainRun {
Original file line number Diff line number Diff line change 11package com.github.jengelman.gradle.plugins.shadow
22
3+ import com.github.jengelman.gradle.plugins.shadow.internal.KOTLIN_MULTIPLATFORM_PLUGIN_ID
34import com.github.jengelman.gradle.plugins.shadow.legacy.LegacyShadowPlugin
45import org.gradle.api.Plugin
56import org.gradle.api.Project
@@ -18,7 +19,7 @@ public abstract class ShadowPlugin : Plugin<Project> {
1819 withType(ApplicationPlugin ::class .java) {
1920 apply (ShadowApplicationPlugin ::class .java)
2021 }
21- withId(" org.jetbrains.kotlin.multiplatform " ) {
22+ withId(KOTLIN_MULTIPLATFORM_PLUGIN_ID ) {
2223 apply (ShadowKmpPlugin ::class .java)
2324 }
2425
Original file line number Diff line number Diff line change 1+ package com.github.jengelman.gradle.plugins.shadow.internal
2+
3+ import org.gradle.api.Project
4+ import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
5+
6+ internal const val KOTLIN_MULTIPLATFORM_PLUGIN_ID = " org.jetbrains.kotlin.multiplatform"
7+
8+ internal fun Project.isAtLeastKgpVersion (
9+ major : Int ,
10+ minor : Int ,
11+ patch : Int ,
12+ id : String = KOTLIN_MULTIPLATFORM_PLUGIN_ID ,
13+ ): Boolean {
14+ val plugin = plugins.getPlugin(id) as KotlinBasePlugin
15+ val elements = plugin.pluginVersion.takeWhile { it != ' -' }.split(" ." )
16+ val kgpMajor = elements[0 ].toInt()
17+ val kgpMinor = elements[1 ].toInt()
18+ val kgpPatch = elements[2 ].toInt()
19+ return kgpMajor > major || (kgpMajor == major && (kgpMinor > minor || (kgpMinor == minor && kgpPatch >= patch)))
20+ }
You can’t perform that action at this time.
0 commit comments