This repository has been archived by the owner on Sep 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbuild.gradle.kts
158 lines (130 loc) · 4.74 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins {
`java-gradle-plugin`
groovy
id("com.gradle.plugin-publish") version "0.9.10"
id("com.github.sherter.google-java-format") version "0.7.1"
id("net.ltgt.errorprone") version "0.0.15"
}
googleJavaFormat {
toolVersion = "1.6"
}
group = "net.ltgt.gradle"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
if (JavaVersion.current().isJava9Compatible) {
tasks.withType<JavaCompile> { options.compilerArgs.addAll(arrayOf("--release", "8")) }
tasks.withType<GroovyCompile> { options.compilerArgs.addAll(arrayOf("--release", "8")) }
}
gradle.taskGraph.whenReady {
if (hasTask(tasks["publishPlugins"])) {
check("git diff --quiet --exit-code".execute(null, rootDir).waitFor() == 0, { "Working tree is dirty" })
val process = "git describe --exact-match".execute(null, rootDir)
check(process.waitFor() == 0, { "Version is not tagged" })
version = process.text.trim().removePrefix("v")
}
}
repositories {
jcenter()
}
dependencies {
errorprone("com.google.errorprone:error_prone_core:2.3.1")
annotationProcessor("com.uber.nullaway:nullaway:0.4.7")
testImplementation(localGroovy())
testImplementation("com.netflix.nebula:nebula-test:6.7.1")
testImplementation("org.spockframework:spock-core:1.1-groovy-2.4") {
exclude(group = "org.codehaus.groovy")
}
}
tasks.withType<JavaCompile> {
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror"))
}
tasks.getByName<JavaCompile>("compileJava") {
options.compilerArgs.add("-XepOpt:NullAway:AnnotatedPackages=net.ltgt.gradle.errorprone")
}
val integTest by configurations.creating
val integTest2 by configurations.creating
dependencies {
integTest("com.google.errorprone:error_prone_core:2.3.1")
integTest2("com.google.errorprone:error_prone_core:2.3.0")
}
val prepareIntegTestDependencies by tasks.creating(Copy::class) {
from(integTest)
into("$buildDir/integTestDependencies")
}
val prepareIntegTest2Dependencies by tasks.creating(Copy::class) {
from(integTest2)
into("$buildDir/integTest2Dependencies")
}
val test by tasks.getting(Test::class) {
val jar: Jar by tasks.getting
val testGradleVersion = project.findProperty("test.gradle-version")
testGradleVersion?.also { systemProperty("test.gradle-version", testGradleVersion) }
inputs.files(prepareIntegTestDependencies).withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(prepareIntegTest2Dependencies).withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(jar).withPathSensitivity(PathSensitivity.NONE)
systemProperty("dependencies", prepareIntegTestDependencies.destinationDir)
systemProperty("dependencies-old", prepareIntegTest2Dependencies.destinationDir)
systemProperty("plugin", jar.archivePath)
testLogging {
showExceptions = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}
}
gradlePlugin {
(plugins) {
"errorpronePlugin" {
id = "net.ltgt.errorprone"
implementationClass = "net.ltgt.gradle.errorprone.ErrorPronePlugin"
}
"errorproneBasePlugin" {
id = "net.ltgt.errorprone-base"
implementationClass = "net.ltgt.gradle.errorprone.ErrorProneBasePlugin"
}
}
}
pluginBundle {
website = "https://github.com/tbroyer/gradle-errorprone-plugin"
vcsUrl = "https://github.com/tbroyer/gradle-errorprone-plugin"
description = "Gradle plugin to use the error-prone compiler for Java"
tags = listOf("javac", "error-prone")
(plugins) {
"errorpronePlugin" {
id = "net.ltgt.errorprone"
displayName = "Gradle error-prone plugin"
}
"errorproneBasePlugin" {
id = "net.ltgt.errorprone-base"
displayName = "Gradle error-prone base plugin"
}
}
mavenCoordinates {
groupId = project.group.toString()
artifactId = project.name
}
}
val ktlint by configurations.creating
dependencies {
ktlint("com.github.shyiko:ktlint:0.24.0")
}
val verifyKtlint by tasks.creating(JavaExec::class) {
description = "Check Kotlin code style."
classpath = ktlint
main = "com.github.shyiko.ktlint.Main"
args("**/*.gradle.kts", "**/*.kt")
}
tasks["check"].dependsOn(verifyKtlint)
task("ktlint", JavaExec::class) {
description = "Fix Kotlin code style violations."
classpath = verifyKtlint.classpath
main = verifyKtlint.main
args("-F")
args(verifyKtlint.args)
}
fun String.execute(envp: Array<String>?, workingDir: File?) =
Runtime.getRuntime().exec(this, envp, workingDir)
val Process.text: String
get() = inputStream.bufferedReader().readText()