Skip to content

Commit 452884d

Browse files
committed
Include missing --add-exports flags for Java 9+ Gradle builds
Previously, we didn't include the necessary `--add-exports` flags when indexing Java 17 builds with Gradle that don't use toolchains. This commit fixes that bug so we can correctly index repos like airbytehq/airbyte.
1 parent 441a0d8 commit 452884d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/GradleBuildTool.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
144144
val dependenciesPath = targetroot.resolve("dependencies.txt")
145145
val kotlinSemanticdbVersion = BuildInfo.semanticdbKotlincVersion
146146
Files.deleteIfExists(dependenciesPath)
147+
val javaModuleOptions =
148+
if (Properties.isJavaAtLeast(9)) {
149+
// Include --add-exports flags for Java 9+
150+
BuildInfo
151+
.javacModuleOptions
152+
.map(option => s""""$option"""")
153+
.mkString(",")
154+
} else {
155+
// No --add-exports flags for Java 8
156+
""
157+
}
147158
val script =
148159
s"""|allprojects {
149160
| gradle.projectsEvaluated {
@@ -160,6 +171,7 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
160171
| tasks.withType(JavaCompile) {
161172
| options.fork = true
162173
| options.incremental = false
174+
| options.forkOptions.jvmArgs.addAll([$javaModuleOptions])
163175
| $executable
164176
| }
165177
| }

0 commit comments

Comments
 (0)