-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
138 lines (115 loc) · 4.01 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
138 lines (115 loc) · 4.01 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
plugins {
id("otel.java-conventions")
id("otel.animalsniffer-conventions")
id("otel.jacoco-conventions")
id("otel.publish-conventions")
id("otel.nullaway-conventions")
}
group = "io.opentelemetry.instrumentation"
val jflex = configurations.create("jflex")
dependencies {
jflex("de.jflex:jflex:1.9.1")
api("io.opentelemetry.semconv:opentelemetry-semconv")
api(project(":instrumentation-api"))
api("io.opentelemetry:opentelemetry-api-incubator")
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")
testImplementation("io.opentelemetry.javaagent:opentelemetry-testing-common")
testImplementation("io.opentelemetry:opentelemetry-sdk")
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
}
val jflexSourceDir = layout.projectDirectory.dir("src/main/jflex")
val jflexOutputDir = layout.buildDirectory.dir("generated/sources/jflex")
val generateJflex = tasks.register<JavaExec>("generateJflex") {
classpath(jflex)
mainClass.set("jflex.Main")
inputs.dir(jflexSourceDir)
outputs.dir(jflexOutputDir)
val sourceDir = jflexSourceDir
val outputDirProvider = jflexOutputDir
doFirst {
val outputDir = outputDirProvider.get().asFile
outputDir.mkdirs()
val specFiles = listOf(
sourceDir.asFile.resolve("SqlSanitizer.jflex"),
sourceDir.asFile.resolve("SqlSanitizerWithSummary.jflex"),
)
args(
listOf("-d", outputDir.absolutePath, "--nobak") + specFiles.map { it.absolutePath },
)
}
}
sourceSets {
main {
java.srcDir(jflexOutputDir)
}
}
tasks.compileJava {
dependsOn(generateJflex)
}
tasks {
// exclude auto-generated code
named<Checkstyle>("checkstyleMain") {
exclude("**/AutoSqlSanitizer.java")
exclude("**/AutoSqlSanitizerWithSummary.java")
}
// Work around https://github.com/jflex-de/jflex/issues/762
compileJava {
with(options) {
compilerArgs.add("-Xlint:-fallthrough")
}
}
test {
inputs.dir(jflexOutputDir)
}
sourcesJar {
dependsOn(generateJflex)
// Avoid configuration cache issue by not capturing task reference
from("src/main/jflex") {
include("**/*.java")
}
}
val testStableSemconv = register<Test>("testStableSemconv") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
jvmArgs("-Dotel.semconv-stability.opt-in=database,code,service.peer,rpc")
jvmArgs("-Dotel.semconv-stability.preview=messaging")
inputs.dir(jflexOutputDir)
}
val testBothSemconv = register<Test>("testBothSemconv") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
jvmArgs("-Dotel.semconv-stability.opt-in=database/dup,code/dup,service.peer/dup,rpc/dup")
jvmArgs("-Dotel.semconv-stability.preview=messaging/dup")
inputs.dir(jflexOutputDir)
}
val testV3Preview = register<Test>("testV3Preview") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
jvmArgs("-Dotel.instrumentation.common.v3-preview=true")
jvmArgs("-Dotel.semconv-stability.preview=messaging")
inputs.dir(jflexOutputDir)
}
val testExceptionSignalLogs = register<Test>("testExceptionSignalLogs") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
jvmArgs("-Dotel.semconv.exception.signal.preview=logs")
inputs.dir(jflexOutputDir)
}
val testExceptionSignalLogsDup = register<Test>("testExceptionSignalLogsDup") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
jvmArgs("-Dotel.semconv.exception.signal.preview=logs/dup")
inputs.dir(jflexOutputDir)
}
check {
dependsOn(
testStableSemconv,
testBothSemconv,
testV3Preview,
testExceptionSignalLogs,
testExceptionSignalLogsDup,
)
}
}