-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle.kts
144 lines (125 loc) · 3.97 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
import net.ltgt.gradle.errorprone.errorprone
plugins {
`java-library`
id("local.maven-publish")
alias(libs.plugins.errorprone)
alias(libs.plugins.spotless)
}
buildscript {
dependencyLocking {
lockAllConfigurations()
lockMode.set(LockMode.STRICT)
}
}
dependencyLocking {
lockAllConfigurations()
lockMode.set(LockMode.STRICT)
}
group = "org.gwtproject.http"
repositories {
mavenCentral()
}
dependencies {
errorprone(libs.errorprone.core)
errorproneJavac(libs.errorprone.javac)
implementation(libs.elemental2.dom)
implementation(libs.elemental2.core)
implementation(libs.jsinterop.base)
testImplementation(libs.junit)
testImplementation(libs.gwt.user)
testImplementation(libs.gwt.dev)
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.compilerArgs.addAll(arrayOf("-Werror", "-Xlint:all"))
if (JavaVersion.current().isJava9Compatible) {
options.release.set(8)
}
options.errorprone.disable("StringSplitter")
}
sourceSets {
test {
java {
// Code that is shared with J2Cl tests
srcDir("src/testFixtures/java")
}
}
}
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")
outputs.dirs(
mapOf(
"war" to warDir,
"work" to workDir,
"cache" to 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 HtmlUnit:Chrome"""
)
systemProperty("gwt.persistentunitcachedir", cacheDir)
}
javadoc {
(options as CoreJavadocOptions).addBooleanOption("Xdoclint:all,-missing", true)
if (JavaVersion.current().isJava9Compatible) {
(options as CoreJavadocOptions).addBooleanOption("html5", true)
}
// Workaround for https://github.com/gradle/gradle/issues/5630
(options as CoreJavadocOptions).addStringOption("sourcepath", "")
}
}
spotless {
java {
target(sourceSets.map { it.allJava }, fileTree("src/j2cl-test/java") { include("**/*.java") })
googleJavaFormat(libs.versions.googleJavaFormat.get())
licenseHeaderFile("LICENSE.header")
}
kotlinGradle {
ktlint(libs.versions.ktlint.get())
}
}
//
// 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)
// For the servlets
inputs.files(compileTestJava).withNormalizer(ClasspathNormalizer::class)
inputs.file("pom-j2cl-test.xml")
inputs.dir("src/testFixtures")
inputs.dir("src/j2cl-test")
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 }
}
}