-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle.kts
169 lines (145 loc) · 4.88 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
plugins {
id("java-library")
id("maven")
id("net.ltgt.errorprone") version "1.3.0"
id("com.diffplug.spotless") version "5.10.2"
id("local.maven-publish")
}
buildscript {
dependencyLocking {
lockAllConfigurations()
lockMode.set(LockMode.STRICT)
}
}
dependencyLocking {
lockAllConfigurations()
lockMode.set(LockMode.STRICT)
}
group = "org.gwtproject.user.history"
repositories {
mavenCentral()
}
dependencies {
errorprone("com.google.errorprone:error_prone_core:2.5.1")
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
api("org.gwtproject.event:gwt-logical-event:1.0.0-RC1")
implementation("org.gwtproject.user.window:gwt-window:1.0.0-RC2")
implementation("com.google.elemental2:elemental2-dom:1.1.0")
implementation("com.google.elemental2:elemental2-core:1.1.0")
testImplementation("junit:junit:4.13.2")
testImplementation("com.google.gwt:gwt-user:2.9.0")
testImplementation("com.google.gwt:gwt-dev:2.9.0")
}
java.sourceCompatibility = JavaVersion.VERSION_1_8
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.addAll(arrayOf("-Werror", "-Xlint:all"))
if (JavaVersion.current().isJava9Compatible) {
options.release.set(8)
}
}
sourceSets {
test {
java {
srcDir("src/test/gwt2")
}
}
}
tasks {
jar {
from(sourceSets.main.map { it.allJava })
}
test {
val warDir = file("$buildDir/gwt/www-test")
val workDir = file("$buildDir/gwt/work")
val cacheDir = file("$buildDir/gwt/cache")
doFirst {
mkdir(warDir)
mkdir(workDir)
mkdir(cacheDir)
}
classpath += sourceSets.main.get().allJava.sourceDirectories + sourceSets.test.get().allJava.sourceDirectories
include("**/*Suite.class")
systemProperty(
"gwt.args",
"-ea -draftCompile -batch module -war \"$warDir\" -workDir \"$workDir\" " +
"-runStyle ${project.findProperty("test.gwt.runStyle") ?: "HtmlUnit:Chrome"}"
)
systemProperty("gwt.persistentunitcachedir", cacheDir)
testLogging {
events("STANDARD_OUT")
}
}
val validateGwtModule by registering(JavaExec::class) {
val workDir = file("$buildDir/gwt/work")
val cacheDir = file("$buildDir/gwt/cache")
val outFile = file("$buildDir/gwt/validateGwtModule")
doFirst {
mkdir(workDir)
mkdir(cacheDir)
standardOutput = outFile.outputStream()
errorOutput = standardOutput
}
doLast {
standardOutput.close()
}
inputs.files(sourceSets.main.map { it.allJava })
outputs.file(outFile)
main = "com.google.gwt.dev.Compiler"
classpath = sourceSets.test.get().runtimeClasspath + sourceSets.main.get().allJava.sourceDirectories
args("-strict", "-validateOnly", "-workDir", workDir, "org.gwtproject.user.history.History")
systemProperty("gwt.persistentunitcachedir", cacheDir)
}
check { dependsOn(validateGwtModule) }
javadoc {
(options as CoreJavadocOptions).apply {
addBooleanOption("Xdoclint:all,-missing", true)
if (JavaVersion.current().isJava9Compatible) {
addBooleanOption("html5", true)
}
// Workaround for https://github.com/gradle/gradle/issues/5630
addStringOption("sourcepath", "")
}
}
}
spotless {
java {
target(sourceSets.map { it.allJava }, fileTree("src/test/j2cl") { include("**/*.java") })
googleJavaFormat("1.7")
licenseHeaderFile("LICENSE.header")
}
kotlinGradle {
ktlint("0.40.0")
}
}
//
// J2Cl tests
//
// Because there's only Maven tooling for J2Cl (and specifically tests), we publish
// the JAR to the local Maven repository under a fixed (non-snapshot) version, and
// then fork a Maven build.
//
val j2clTestPublication = publishing.publications.create<MavenPublication>("j2clTest") {
from(components["java"])
version = "LOCAL"
}
tasks {
val j2clTest by registering(Exec::class) {
shouldRunAfter(test)
dependsOn("publishJ2clTestPublicationToMavenLocal")
inputs.files(sourceSets.main.map { it.runtimeClasspath }).withNormalizer(ClasspathNormalizer::class)
inputs.file("pom-j2cl-test.xml")
inputs.dir("src/test/java")
inputs.dir("src/test/j2cl")
outputs.dir("target")
val webdriver = findProperty("j2clTest.webdriver") ?: "htmlunit"
inputs.property("webdriver", webdriver)
commandLine("mvn", "-V", "-B", "-ntp", "-U", "-e", "-f", "pom-j2cl-test.xml", "verify", "-Dwebdriver=$webdriver")
}
check {
dependsOn(j2clTest)
}
withType<PublishToMavenRepository>().configureEach {
onlyIf { publication != j2clTestPublication }
}
}