11plugins {
2- id(" org.xbib.gradle.plugin.jflex" )
3-
42 id(" otel.java-conventions" )
53 id(" otel.animalsniffer-conventions" )
64 id(" otel.jacoco-conventions" )
@@ -10,7 +8,17 @@ plugins {
108
119group = " io.opentelemetry.instrumentation"
1210
11+ // JFlex configuration - manual integration for configuration cache compatibility
12+ configurations {
13+ val jflex by creating {
14+ isTransitive = true
15+ }
16+ }
17+
1318dependencies {
19+ " jflex" (" de.jflex:jflex:1.9.1" )
20+ " jflex" (" com.github.vbmacher:java-cup-runtime:11b-20160615" )
21+
1422 api(" io.opentelemetry.semconv:opentelemetry-semconv" )
1523 api(project(" :instrumentation-api" ))
1624 api(" io.opentelemetry:opentelemetry-api-incubator" )
@@ -24,6 +32,41 @@ dependencies {
2432 testImplementation(" io.opentelemetry.semconv:opentelemetry-semconv-incubating" )
2533}
2634
35+ // Manual JFlex task - configuration cache compatible
36+ val generateJflex by tasks.registering(JavaExec ::class ) {
37+ description = " Generate Java code from JFlex files"
38+ group = " build"
39+
40+ classpath = configurations.getByName(" jflex" )
41+ mainClass.set(" jflex.Main" )
42+
43+ val jflexSourceDir = file(" src/main/jflex" )
44+ val jflexOutputDir = file(" build/generated/sources/jflex" )
45+
46+ inputs.dir(jflexSourceDir)
47+ outputs.dir(jflexOutputDir)
48+
49+ doFirst {
50+ jflexOutputDir.mkdirs()
51+ }
52+
53+ args(
54+ " -d" , jflexOutputDir,
55+ " --nobak" ,
56+ " $jflexSourceDir /SqlSanitizer.jflex"
57+ )
58+ }
59+
60+ sourceSets {
61+ main {
62+ java.srcDir(generateJflex.map { it.outputs.files.singleFile })
63+ }
64+ }
65+
66+ tasks.compileJava {
67+ dependsOn(generateJflex)
68+ }
69+
2770tasks {
2871 // exclude auto-generated code
2972 named<Checkstyle >(" checkstyleMain" ) {
@@ -38,7 +81,11 @@ tasks {
3881 }
3982
4083 sourcesJar {
41- dependsOn(" generateJflex" )
84+ dependsOn(generateJflex)
85+ // Avoid configuration cache issue by not capturing task reference
86+ from(" src/main/jflex" ) {
87+ include(" **/*.java" )
88+ }
4289 }
4390
4491 val testStableSemconv by registering(Test ::class ) {
0 commit comments