1
1
package dev.adamko.kotlin.binary_compatibility_validator
2
2
3
3
import dev.adamko.kotlin.binary_compatibility_validator.internal.globToRegex
4
+ import dev.adamko.kotlin.binary_compatibility_validator.targets.BCVTargetSpec
5
+ import javax.inject.Inject
4
6
import org.gradle.api.Plugin
5
7
import org.gradle.api.Project
6
8
import org.gradle.api.initialization.Settings
9
+ import org.gradle.api.model.ObjectFactory
7
10
import org.gradle.api.provider.SetProperty
8
11
import org.gradle.kotlin.dsl.apply
12
+ import org.gradle.kotlin.dsl.configure
9
13
import org.gradle.kotlin.dsl.create
14
+ import org.gradle.kotlin.dsl.newInstance
10
15
11
- abstract class BCVSettingsPlugin : Plugin <Settings > {
16
+ abstract class BCVSettingsPlugin @Inject constructor(
17
+ private val objects : ObjectFactory
18
+ ) : Plugin<Settings> {
12
19
13
20
override fun apply (settings : Settings ) {
14
- val extension = settings.extensions.create(" bcvSettings" , Extension ::class ).apply {
21
+ val extension = settings.extensions.create<Extension >(
22
+ " bcvSettings" ,
23
+ objects.newInstance<BCVTargetSpec >(),
24
+ ).apply {
15
25
ignoredProjects.convention(emptySet())
26
+
27
+ defaultTargetValues {
28
+ enabled.convention(true )
29
+ ignoredClasses.convention(emptySet())
30
+ ignoredMarkers.convention(emptySet())
31
+ ignoredPackages.convention(emptySet())
32
+ }
16
33
}
17
34
18
35
settings.gradle.beforeProject {
@@ -22,11 +39,24 @@ abstract class BCVSettingsPlugin : Plugin<Settings> {
22
39
}
23
40
) {
24
41
project.pluginManager.apply (BCVProjectPlugin ::class )
42
+ project.extensions.configure<BCVProjectExtension > {
43
+ enabled.convention(extension.defaultTargetValues.enabled)
44
+ ignoredClasses.convention(extension.defaultTargetValues.ignoredClasses)
45
+ ignoredMarkers.convention(extension.defaultTargetValues.ignoredMarkers)
46
+ ignoredPackages.convention(extension.defaultTargetValues.ignoredPackages)
47
+ }
25
48
}
26
49
}
27
50
}
28
51
29
- interface Extension {
52
+ abstract class Extension @Inject constructor(
53
+
54
+ /* *
55
+ * Set [BCVTargetSpec] values that will be used as defaults for all
56
+ * [BCVProjectExtension.targets] in subprojects.
57
+ */
58
+ val defaultTargetValues : BCVTargetSpec
59
+ ) {
30
60
31
61
/* *
32
62
* Paths of projects.
@@ -37,6 +67,10 @@ abstract class BCVSettingsPlugin : Plugin<Settings> {
37
67
* - `*` will match zero, or many characters, excluding `:`
38
68
* - `**` will match 0 to many characters, including `:`
39
69
*/
40
- val ignoredProjects: SetProperty <String >
70
+ abstract val ignoredProjects: SetProperty <String >
71
+
72
+
73
+ fun defaultTargetValues (configure : BCVTargetSpec .() -> Unit ) =
74
+ defaultTargetValues.configure()
41
75
}
42
76
}
0 commit comments