@@ -3,6 +3,7 @@ package com.squareup.workflow1.buildsrc
3
3
import org.gradle.api.Project
4
4
import org.gradle.kotlin.dsl.dependencies
5
5
import org.gradle.kotlin.dsl.kotlin
6
+ import org.gradle.kotlin.dsl.withType
6
7
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
7
8
8
9
// See https://stackoverflow.com/questions/25324880/detect-ide-environment-with-gradle
@@ -11,35 +12,38 @@ val Project.isRunningFromIde
11
12
12
13
@Suppress(" SuspiciousCollectionReassignment" )
13
14
fun Project.kotlinCommonSettings (
14
- compileTask : KotlinCompile ,
15
- configuration : String = "implementation",
15
+ bomConfigurationName : String
16
16
) {
17
17
18
18
// force the same Kotlin version everywhere, including transitive dependencies
19
19
dependencies {
20
- configuration (platform(kotlin(" bom" )))
20
+ bomConfigurationName (platform(kotlin(" bom" )))
21
21
}
22
22
23
- compileTask.kotlinOptions {
23
+ tasks.withType<KotlinCompile > {
24
+ kotlinOptions {
24
25
25
- // Allow warnings when running from IDE, makes it easier to experiment.
26
- if (! isRunningFromIde) {
27
- allWarningsAsErrors = true
28
- }
26
+ jvmTarget = " 1.8"
29
27
30
- // Don't panic, all this does is allow us to use the @OptIn meta-annotation.
31
- // to define our own experiments.
32
- freeCompilerArgs + = " -opt-in=kotlin.RequiresOptIn"
28
+ // Allow warnings when running from IDE, makes it easier to experiment.
29
+ if (! isRunningFromIde) {
30
+ allWarningsAsErrors = true
31
+ }
33
32
34
- // Make sure our module names don't conflict with those from pre-workflow1
35
- // releases, so that old and new META-INF/ entries don't stomp each other.
36
- // (This is only an issue for apps that are still migrating from workflow to
37
- // workflow1, and so need to import two versions of the library.)
38
- // https://blog.jetbrains.com/kotlin/2015/09/kotlin-m13-is-out/
39
- moduleName = " wf1-${project.name} "
40
- }
33
+ // Don't panic, all this does is allow us to use the @OptIn meta-annotation.
34
+ // to define our own experiments.
35
+ freeCompilerArgs + = " -opt-in=kotlin.RequiresOptIn"
41
36
42
- maybeEnableExplicitApi(compileTask)
37
+ // Make sure our module names don't conflict with those from pre-workflow1
38
+ // releases, so that old and new META-INF/ entries don't stomp each other.
39
+ // (This is only an issue for apps that are still migrating from workflow to
40
+ // workflow1, and so need to import two versions of the library.)
41
+ // https://blog.jetbrains.com/kotlin/2015/09/kotlin-m13-is-out/
42
+ moduleName = " wf1-${project.name} "
43
+ }
44
+
45
+ maybeEnableExplicitApi(this @withType)
46
+ }
43
47
}
44
48
45
49
private fun Project.maybeEnableExplicitApi (compileTask : KotlinCompile ) {
0 commit comments