-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
159 lines (140 loc) · 5.17 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
plugins {
id("com.diffplug.spotless") version "7.0.2"
id("com.github.ben-manes.versions") version "0.51.0"
id("com.gradle.plugin-publish") version "1.3.0"
id("io.github.davidburstrom.version-compatibility") version "0.5.0"
id("net.ltgt.errorprone") version "4.1.0"
id("org.gradle.signing")
}
val errorProneVersion = "2.36.0"
val googleJavaFormatVersion = "1.16.0"
val ktlintVersion = "1.5.0"
version = "0.1.0-SNAPSHOT"
group = "io.github.davidburstrom.gradle.recursive-wrapper"
val pluginId = "io.github.davidburstrom.recursive-wrapper"
val packageName = "io.github.davidburstrom.gradle.recursivewrapper"
repositories {
mavenCentral()
}
configurations {
register("dependencyUpdates")
}
dependencies {
"dependencyUpdates"("com.pinterest.ktlint:ktlint-bom:$ktlintVersion")
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
testImplementation("com.google.truth:truth:1.4.4")
testImplementation("com.vdurmont:semver4j:3.1.0")
errorprone("com.google.errorprone:error_prone_core:$errorProneVersion")
}
configure<JavaPluginExtension> {
toolchain {
// Could theoretically be version 8, but it's not compatible with
// ErrorProne. Therefore, the JavaCompile release option is used.
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.named<JavaCompile>("compileJava").configure {
options.release = 8
}
tasks.named<JavaCompile>("compileTestJava").configure {
options.release = 11
}
tasks.withType(JavaCompile::class).configureEach {
options.compilerArgs.add("-Werror")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.test {
systemProperty("GRADLE_VERSION", GradleVersion.current().version)
}
tasks.withType<Test> {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
maxHeapSize = "48m"
}
spotless {
java {
googleJavaFormat()
licenseHeaderFile(rootProject.file("config/license-header.txt"))
}
kotlinGradle {
target("**/*.gradle.kts")
ktlint(ktlintVersion).editorConfigOverride(mapOf("ktlint_standard_trailing-comma-on-call-site" to "disabled"))
}
}
versionCompatibility {
tests {
dimensions {
register("Gradle") {
versions = listOf("6.0.1", "6.1.1", "6.2.2", "6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "6.8.3", "6.9.4", "7.0.2", "7.1.1", "7.2", "7.3.3", "7.4.2", "7.5.1", "7.6.3", "8.0.2", "8.1.1", "8.2.1", "8.3", "8.4", "8.5", "8.6", "8.7", "8.8", "8.9", "8.10.2", "8.11.1", "8.12")
if (GradleVersion.current().version !in versions.get()) {
throw GradleException("Could not find ${gradle.gradleVersion} in the compatibility test versions")
}
}
}
eachTestTask {
val (gradleVersion) = versions
testTask.systemProperty("GRADLE_VERSION", gradleVersion)
testTask.javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
}
}
}
tasks.named("build").configure {
dependsOn("testCompatibility")
}
gradlePlugin {
website = "https://github.com/davidburstrom/recursive-wrapper-gradle-plugin"
vcsUrl = "https://github.com/davidburstrom/recursive-wrapper-gradle-plugin"
plugins.register("plugin") {
id = pluginId
implementationClass = "$packageName.RecursiveWrapperPlugin"
displayName = "Recursive Wrapper Gradle Plugin"
description = "Updates the Gradle wrapper for all included projects in a single invocation."
tags = listOf("wrapper", "update", "composite", "recursive", "included", "project")
}
}
val constantsGenerator by tasks.registering {
val constantsDir = project.layout.buildDirectory.dir("generated/sources/constants/java")
val outputFile =
constantsDir.get().file("${packageName.replace(".", "/")}/Constants.java").asFile
val licenseFile = rootProject.file("config/license-header.txt")
inputs.file(licenseFile)
inputs.property("version", version)
inputs.property("pluginId", pluginId)
inputs.property("group", project.group)
inputs.property("id", project.name)
inputs.property("packageName", packageName)
outputs.dir(constantsDir)
doLast {
outputFile.parentFile.mkdirs()
val properties = inputs.properties
val pluginId by properties
val group by properties
val id by properties
val version by properties
val packageName by properties
outputFile.writeText(
licenseFile.readText() +
"package $packageName;\n" +
"\n" +
"/** Holds the current build version. */\n" +
"public final class Constants {\n" +
" private Constants() {}\n" +
"\n" +
" public static final String PLUGIN_ID = \"$pluginId\";\n" +
" public static final String GROUP = \"$group\";\n" +
" public static final String ID = \"$id\";\n" +
" public static final String VERSION = \"$version\";\n" +
"}\n"
)
}
}
sourceSets.main {
java.srcDir(constantsGenerator)
}