1
1
package com.squareup.anvil.conventions
2
2
3
- import com.rickbusarow.kgx.buildDir
4
- import com.rickbusarow.kgx.extras
5
3
import com.rickbusarow.kgx.fromInt
6
4
import com.rickbusarow.kgx.getValue
7
5
import com.rickbusarow.kgx.javaExtension
8
6
import com.rickbusarow.kgx.provideDelegate
9
- import com.squareup.anvil.conventions.utils.isInAnvilBuild
10
- import com.squareup.anvil.conventions.utils.isInAnvilIncludedBuild
11
- import com.squareup.anvil.conventions.utils.isInAnvilRootBuild
12
7
import com.squareup.anvil.conventions.utils.libs
13
8
import org.gradle.api.JavaVersion
14
9
import org.gradle.api.Plugin
@@ -18,9 +13,9 @@ import org.gradle.api.tasks.testing.Test
18
13
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
19
14
import org.gradle.jvm.toolchain.JavaLanguageVersion
20
15
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
16
+ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
21
17
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper
22
18
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23
- import java.util.Properties
24
19
25
20
abstract class BasePlugin : Plugin <Project > {
26
21
@@ -33,10 +28,6 @@ abstract class BasePlugin : Plugin<Project> {
33
28
34
29
val extension = target.extensions.create(" conventions" , ConventionsExtension ::class .java)
35
30
36
- if (! target.isInAnvilBuild()) {
37
- target.copyRootProjectGradleProperties()
38
- }
39
-
40
31
beforeApply(target)
41
32
42
33
target.plugins.apply (" base" )
@@ -45,8 +36,6 @@ abstract class BasePlugin : Plugin<Project> {
45
36
46
37
configureGradleProperties(target)
47
38
48
- configureBuildDirs(target)
49
-
50
39
configureJava(target)
51
40
52
41
target.plugins.withType(KotlinBasePluginWrapper ::class .java) {
@@ -55,29 +44,9 @@ abstract class BasePlugin : Plugin<Project> {
55
44
56
45
configureTests(target)
57
46
58
- target.configurations.configureEach { config ->
59
- config.resolutionStrategy {
60
- it.force(target.libs.kotlin.metadata)
61
- }
62
- }
63
-
64
47
afterApply(target)
65
48
}
66
49
67
- /* *
68
- * Included builds need the `GROUP` and `VERSION_NAME` values from the main build's
69
- * `gradle.properties`. We can't just use a symlink because Windows exists.
70
- * See https://github.com/square/anvil/pull/763#discussion_r1379563691
71
- */
72
- private fun Project.copyRootProjectGradleProperties () {
73
- rootProject.file(" ../../gradle.properties" )
74
- .inputStream()
75
- .use { Properties ().apply { load(it) } }
76
- .forEach { key, value ->
77
- extras.set(key.toString(), value.toString())
78
- }
79
- }
80
-
81
50
private fun configureGradleProperties (target : Project ) {
82
51
target.version = target.property(" VERSION_NAME" ) as String
83
52
target.group = target.property(" GROUP" ) as String
@@ -123,38 +92,11 @@ abstract class BasePlugin : Plugin<Project> {
123
92
freeCompilerArgs.add(" -Xexplicit-api=strict" )
124
93
}
125
94
126
- jvmTarget.set(JvmTarget .fromInt(target.jvmTargetInt()))
127
- }
128
- }
129
- }
130
-
131
- /* *
132
- * The "anvil" projects exist in two different builds, they need two different build directories
133
- * so that there is no shared mutable state.
134
- */
135
- private fun configureBuildDirs (target : Project ) {
136
-
137
- when {
138
- ! target.isInAnvilBuild() -> return
95
+ languageVersion.set(KotlinVersion .KOTLIN_2_0 )
139
96
140
- target.isInAnvilRootBuild() -> {
141
- target.layout.buildDirectory.set(target.file(" build/root-build" ))
142
- }
143
-
144
- target.isInAnvilIncludedBuild() -> {
145
- target.layout.buildDirectory.set(target.file(" build/included-build" ))
97
+ jvmTarget.set(JvmTarget .fromInt(target.jvmTargetInt()))
146
98
}
147
99
}
148
-
149
- // Set the kase working directory ('<build directory>/kase/<test|gradleTest>') as a System property,
150
- // so that it's in the right place for projects with relocated directories.
151
- // https://github.com/rickbusarow/kase/blob/255db67f40d5ec83e31755bc9ce81b1a2b08cf11/kase/src/main/kotlin/com/rickbusarow/kase/files/HasWorkingDir.kt#L93-L96
152
- target.tasks.withType(Test ::class .java).configureEach { task ->
153
- task.systemProperty(
154
- " kase.baseWorkingDir" ,
155
- target.buildDir().resolve(" kase/${task.name} " ),
156
- )
157
- }
158
100
}
159
101
160
102
/* *
0 commit comments