-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually apply the
java
plugin (#2356)
To support Kotlin Multiplatform 1.9.20 and forward together with the animalsniffer plugin See: xvik/gradle-animalsniffer-plugin#84 https://youtrack.jetbrains.com/issue/KT-59595 (cherry picked from commit a87b0f1)
- Loading branch information
1 parent
ce6f319
commit 4e9db0b
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import org.gradle.api.* | ||
import org.gradle.api.file.* | ||
import org.gradle.api.plugins.* | ||
import org.gradle.api.tasks.* | ||
import org.gradle.api.tasks.testing.* | ||
import org.gradle.jvm.tasks.* | ||
import org.jetbrains.kotlin.gradle.plugin.* | ||
|
||
/* | ||
* Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
object JavaPluginUtil { | ||
|
||
@JvmStatic | ||
fun Project.applyJavaPlugin() { | ||
plugins.apply("java") | ||
|
||
plugins.withId("org.jetbrains.kotlin.multiplatform") { | ||
listOf( | ||
JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME, | ||
JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME | ||
).forEach { outputConfigurationName -> | ||
configurations.findByName(outputConfigurationName)?.isCanBeConsumed = false | ||
} | ||
|
||
disableJavaPluginTasks(extensions.getByName("sourceSets") as SourceSetContainer) | ||
} | ||
} | ||
} | ||
|
||
private fun Project.disableJavaPluginTasks(javaSourceSet: SourceSetContainer) { | ||
project.tasks.withType(Jar::class.java).named(javaSourceSet.getByName("main").jarTaskName).configure { | ||
dependsOn("jvmTest") | ||
enabled = false | ||
} | ||
|
||
project.tasks.withType(Test::class.java).named(JavaPlugin.TEST_TASK_NAME) { | ||
dependsOn("jvmJar") | ||
enabled = false | ||
} | ||
} |