-
Notifications
You must be signed in to change notification settings - Fork 69
/
build.gradle.kts
220 lines (182 loc) · 6.01 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.IOException
import java.time.Duration
plugins {
`build-scan`
`java-gradle-plugin`
`maven-publish`
signing
id("com.gradle.plugin-publish") version "0.10.0"
id("gradle.site") version "0.6"
kotlin("jvm") version "1.3.10"
}
val junitPlatformVersion = "1.1.0"
val spekVersion = "2.0.0-rc.1"
group = "org.gradle.plugins"
version = "0.6"
description = "Generates documentation in HTML for given project"
val webUrl = "https://gradle-guides.github.io/${project.name}/"
val githubUrl = "https://github.com/gradle-guides/${project.name}.git"
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
publishAlways()
fun execCommandWithOutput(input: String): String {
return try {
val parts = input.split("\\s".toRegex())
val proc = ProcessBuilder(*parts.toTypedArray())
.directory(rootDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
proc.waitFor(20, TimeUnit.SECONDS)
proc.inputStream.bufferedReader().readText()
} catch(e: IOException) {
"<empty>"
}
}
// Fastest way to safely check Git https://gist.github.com/sindresorhus/3898739
value("Git Branch", execCommandWithOutput("git symbolic-ref --short HEAD"))
value("Git Commit", execCommandWithOutput("git rev-parse --verify HEAD"))
val gitStatus = execCommandWithOutput("git status --porcelain")
if (gitStatus.isNotEmpty()) {
value("Git Local Changes", gitStatus)
tag("dirty")
}
if (!System.getenv("CI").isNullOrEmpty()) {
tag("CI")
}
}
site {
outputDir.set(file("$rootDir/docs"))
websiteUrl.set(webUrl)
vcsUrl.set(githubUrl)
}
// Separate integration tests from "fast" tests
// NOTE: deprecation warnings from the following lines are caused by the Kotlin plugin using a deprecated API when adding its own sourceSet management here
val intTest by sourceSets.creating {
compileClasspath += sourceSets.main.get().output + configurations.testRuntime.get()
runtimeClasspath += output + compileClasspath
}
val intTestImplementation by configurations.getting {
extendsFrom(configurations.testImplementation.get())
}
val intTestRuntimeOnly by configurations.getting {
extendsFrom(configurations.testRuntimeOnly.get())
}
val integrationTest by tasks.registering(Test::class) {
description = "Runs the functional tests"
group = JavaBasePlugin.VERIFICATION_GROUP
testClassesDirs = intTest.output.classesDirs
classpath = intTest.runtimeClasspath
shouldRunAfter(tasks.test)
reports {
html.destination = file("${html.destination}/functional")
junitXml.destination = file("${junitXml.destination}/functional")
}
timeout.set(Duration.ofMinutes(2))
}
val sourcesJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles sources JAR"
classifier = "sources"
from(sourceSets.main.get().allSource)
}
tasks {
withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
}
withType<Test>().configureEach {
useJUnitPlatform {
includeEngines("spek2")
}
}
check {
dependsOn(integrationTest.get())
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.freemarker:freemarker:2.3.26-incubating")
implementation(kotlin("stdlib-jdk8"))
testImplementation(kotlin("test"))
testImplementation("org.spekframework.spek2:spek-dsl-jvm:$spekVersion") {
exclude(group = "org.jetbrains.kotlin")
}
testRuntimeOnly(kotlin("reflect"))
testRuntimeOnly("org.spekframework.spek2:spek-runner-junit5:$spekVersion") {
exclude(group = "org.junit.platform")
exclude(group = "org.jetbrains.kotlin")
}
testImplementation("org.junit.platform:junit-platform-launcher:$junitPlatformVersion")
intTestImplementation("org.jsoup:jsoup:1.10.2") {
because("Integration tests parse generated HTML for verification")
}
intTestImplementation(gradleTestKit())
}
// Configure java-gradle-plugin
gradlePlugin {
plugins {
register("sitePlugin") {
id = "gradle.site"
implementationClass = "org.gradle.plugins.site.SitePlugin"
}
}
}
// Configure plugin-publish plugin
pluginBundle {
website = webUrl
vcsUrl = githubUrl
description = project.description
tags = listOf("documentation", "site")
plugins {
named("sitePlugin") {
// ID and implementation class are used from `gradlePlugin` config
displayName = "Gradle Site Plugin"
}
}
// Prefix group with "gradle.plugin" because plugin portal doesn't allow groups starting with "org.gradle"
mavenCoordinates {
groupId = "gradle.plugin.${project.group}"
}
}
artifacts {
add(configurations.archives.name, sourcesJar)
}
// Configure maven-publish plugin
publishing {
publications.withType<MavenPublication> {
artifact(sourcesJar.get())
pom {
name.set(project.name)
description.set(project.description)
url.set(webUrl)
scm {
url.set(githubUrl)
}
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("eriwen")
name.set("Eric Wendelin")
email.set("[email protected]")
}
}
}
}
}
signing {
useGpgCmd()
sign(configurations.archives.get())
setRequired(Callable {
gradle.taskGraph.hasTask("publishPlugins")
})
}