File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 1
1
package com.github.jengelman.gradle.plugins.shadow
2
2
3
3
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin.Companion.registerShadowJarCommon
4
+ import com.github.jengelman.gradle.plugins.shadow.internal.isAtLeastKgpVersion
4
5
import com.github.jengelman.gradle.plugins.shadow.internal.mainClassAttributeKey
5
6
import kotlin.collections.contains
6
7
import org.gradle.api.Plugin
7
8
import org.gradle.api.Project
8
9
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
9
10
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
10
- import org.jetbrains.kotlin.gradle.dsl.KotlinVersion as KgpVersion
11
11
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
12
12
13
13
public abstract class ShadowKmpPlugin : Plugin <Project > {
@@ -30,7 +30,7 @@ public abstract class ShadowKmpPlugin : Plugin<Project> {
30
30
},
31
31
)
32
32
33
- if (KgpVersion . DEFAULT < KgpVersion . KOTLIN_2_1 ) return @registerShadowJarCommon
33
+ if (! isAtLeastKgpVersion( 2 , 1 , 0 ) ) return @registerShadowJarCommon
34
34
35
35
@OptIn(ExperimentalKotlinGradlePluginApi ::class )
36
36
target.mainRun {
Original file line number Diff line number Diff line change 1
1
package com.github.jengelman.gradle.plugins.shadow
2
2
3
+ import com.github.jengelman.gradle.plugins.shadow.internal.KOTLIN_MULTIPLATFORM_PLUGIN_ID
3
4
import com.github.jengelman.gradle.plugins.shadow.legacy.LegacyShadowPlugin
4
5
import org.gradle.api.Plugin
5
6
import org.gradle.api.Project
@@ -18,7 +19,7 @@ public abstract class ShadowPlugin : Plugin<Project> {
18
19
withType(ApplicationPlugin ::class .java) {
19
20
apply (ShadowApplicationPlugin ::class .java)
20
21
}
21
- withId(" org.jetbrains.kotlin.multiplatform " ) {
22
+ withId(KOTLIN_MULTIPLATFORM_PLUGIN_ID ) {
22
23
apply (ShadowKmpPlugin ::class .java)
23
24
}
24
25
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