-
Notifications
You must be signed in to change notification settings - Fork 519
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
142 lines (114 loc) · 4.35 KB
/
build.gradle.kts
File metadata and controls
142 lines (114 loc) · 4.35 KB
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
@file:Suppress("UnstableApiUsage")
import com.gradle.develocity.agent.gradle.test.ImportJUnitXmlReports
import com.gradle.develocity.agent.gradle.test.JUnitXmlDialect
plugins {
id("org.openrewrite.build.language-library")
id("org.openrewrite.build.moderne-source-available-license")
id("jvm-test-suite")
}
dependencies {
api(project(":rewrite-core"))
api(project(":rewrite-java"))
api("org.jetbrains:annotations:latest.release")
api("com.fasterxml.jackson.core:jackson-annotations")
implementation("io.moderne:jsonrpc:latest.integration")
compileOnly(project(":rewrite-test"))
testImplementation(project(":rewrite-test"))
testImplementation("io.moderne:jsonrpc:latest.integration")
testRuntimeOnly(project(":rewrite-java-21"))
}
tasks.withType<Javadoc>().configureEach {
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
exclude("**/G.java")
}
// Test fixtures for the GoMod conformance corpus are .gomod / .gosum / .json
// files; none of these formats accept a leading license header.
configure<nl.javadude.gradle.plugins.license.LicenseExtension> {
excludePatterns.addAll(listOf("**/*.gomod", "**/*.gosum", "**/*.json"))
}
val goBuild = tasks.register<Exec>("goBuild") {
workingDir = projectDir
// Use relative path to avoid absolute paths in cache key (Exec args are cache inputs)
commandLine("go", "build", "-o", layout.buildDirectory.file("rewrite-go-rpc").get().asFile.relativeTo(projectDir).path, "./cmd/rpc")
inputs.files(fileTree(projectDir) {
include("**/*.go")
include("go.mod")
include("go.sum")
exclude("build/**")
}).withPathSensitivity(PathSensitivity.RELATIVE)
outputs.file(layout.buildDirectory.file("rewrite-go-rpc"))
}
testing {
suites {
register<JvmTestSuite>("integTest") {
useJUnitJupiter()
targets {
all {
testTask.configure {
dependsOn(goBuild)
}
}
}
dependencies {
implementation(project())
implementation(project(":rewrite-java-21"))
implementation(project(":rewrite-test"))
implementation("org.assertj:assertj-core:latest.release")
}
}
}
}
// ============================================
// Go Test Support Tasks
// ============================================
// Configuration to collect classpath for the Java RPC server
val javaRpcClasspath by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
extendsFrom(configurations.getByName("runtimeClasspath"))
}
dependencies {
javaRpcClasspath(project(":rewrite-maven"))
}
// Task to generate classpath file for Java RPC server testing from Go
val generateTestClasspath by tasks.registering {
group = "golang"
description = "Generate classpath file for Java RPC server (used by Go tests)"
val outputFile = file("test-classpath.txt")
outputs.file(outputFile)
dependsOn(tasks.named("compileJava"))
doLast {
val classpath = (
javaRpcClasspath.files +
tasks.named("compileJava").get().outputs.files +
tasks.named("processResources").get().outputs.files
).distinctBy { it.absolutePath }
.joinToString(File.pathSeparator) { it.absolutePath }
outputFile.writeText(classpath)
logger.lifecycle("Generated test classpath to ${outputFile.absolutePath}")
}
}
val junitXmlFile = file("build/test-results/gotest/junit.xml")
val goTest = tasks.register<Exec>("goTest") {
group = "verification"
description = "Run Go tests"
workingDir = projectDir
commandLine("go", "run", "gotest.tools/gotestsum@latest",
"--junitfile", junitXmlFile.relativeTo(projectDir).path,
"--format", "standard-verbose",
"--", "-count=1", "./test/...")
dependsOn(generateTestClasspath)
inputs.files(fileTree(projectDir) {
include("**/*.go")
include("go.mod")
include("go.sum")
exclude("build/**")
}).withPathSensitivity(PathSensitivity.RELATIVE)
inputs.file(file("test-classpath.txt"))
outputs.file(junitXmlFile)
outputs.cacheIf { true }
}
ImportJUnitXmlReports.register(tasks, goTest, JUnitXmlDialect.GENERIC)
tasks.named("check") {
dependsOn(goTest)
}