File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,11 @@ subprojects {
191
191
if (excludedFromBomProjects. contains(project. name)) return
192
192
193
193
// Animalsniffer setup
194
+ // Animalsniffer requires java plugin to be applied, but Kotlin 1.9.20
195
+ // relies on `java-base` for Kotlin Multiplatforms `withJava` implementation
196
+ // https://github.com/xvik/gradle-animalsniffer-plugin/issues/84
197
+ // https://youtrack.jetbrains.com/issue/KT-59595
198
+ JavaPluginUtil . applyJavaPlugin(project)
194
199
apply plugin : ' ru.vyarus.animalsniffer'
195
200
196
201
afterEvaluate { // Can be applied only when the project is evaluated
Original file line number Diff line number Diff line change
1
+ import org.gradle.api.*
2
+ import org.gradle.api.file.*
3
+ import org.gradle.api.plugins.*
4
+ import org.gradle.api.tasks.*
5
+ import org.gradle.api.tasks.testing.*
6
+ import org.gradle.jvm.tasks.*
7
+ import org.jetbrains.kotlin.gradle.plugin.*
8
+
9
+ /*
10
+ * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
11
+ */
12
+
13
+ object JavaPluginUtil {
14
+
15
+ @JvmStatic
16
+ fun Project.applyJavaPlugin () {
17
+ plugins.apply (" java" )
18
+
19
+ plugins.withId(" org.jetbrains.kotlin.multiplatform" ) {
20
+ listOf (
21
+ JavaPlugin .API_ELEMENTS_CONFIGURATION_NAME ,
22
+ JavaPlugin .RUNTIME_ELEMENTS_CONFIGURATION_NAME
23
+ ).forEach { outputConfigurationName ->
24
+ configurations.findByName(outputConfigurationName)?.isCanBeConsumed = false
25
+ }
26
+
27
+ disableJavaPluginTasks(extensions.getByName(" sourceSets" ) as SourceSetContainer )
28
+ }
29
+ }
30
+ }
31
+
32
+ private fun Project.disableJavaPluginTasks (javaSourceSet : SourceSetContainer ) {
33
+ project.tasks.withType(Jar ::class .java).named(javaSourceSet.getByName(" main" ).jarTaskName).configure {
34
+ dependsOn(" jvmTest" )
35
+ enabled = false
36
+ }
37
+
38
+ project.tasks.withType(Test ::class .java).named(JavaPlugin .TEST_TASK_NAME ) {
39
+ dependsOn(" jvmJar" )
40
+ enabled = false
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments