Skip to content

gradle: Properly configure sourceSet compile and runtime classpaths#7313

Merged
bjhargrave merged 1 commit into
bndtools:masterfrom
bjhargrave:issues/7306
Jul 9, 2026
Merged

gradle: Properly configure sourceSet compile and runtime classpaths#7313
bjhargrave merged 1 commit into
bndtools:masterfrom
bjhargrave:issues/7306

Conversation

@bjhargrave

Copy link
Copy Markdown
Member

This fix is for Bnd Workspace builds.

We use jarLibraryElements to process configurations to require jar elements (instead of output folders). We do this since Bnd can add content to the jar which is sourced from the classpath of the jar task.

So, we now set the sourceSet compile and runtime classpaths using the jarLibraryElements file collection from the compile and runtime classpath configurations, respectively, preceeded with the necessary sourceSet outputs for each classpath.

  • main compile: compileClasspath configuration
  • main runtime: main output + runtimeClasspath configuration
  • test compile: main output + testCompileClasspath configuration
  • test runtime: test output + main output + testRuntimeClasspath configuration

We no longer set the classpath or destination dir in the compile task since it will use the related sourceSet compile classpath and destination dir.

We also remove the incorrect setting of the runtimeOnly and testRuntimeOnly configurations.

Fixes #7306

This fix is for Bnd Workspace builds.

We use jarLibraryElements to process configurations to require
jar elements (instead of output folders). We do this since Bnd can add
content to the jar which is sourced from the classpath of the jar task.

So, we now set the sourceSet compile and runtime classpaths using
the jarLibraryElements file collection from the compile and runtime
classpath configurations, respectively, preceeded with the necessary
sourceSet outputs for each classpath.

- main compile: compileClasspath configuration
- main runtime: main output + runtimeClasspath configuration
- test compile: main output + testCompileClasspath configuration
- test runtime: test output + main output + testRuntimeClasspath configuration

We no longer set the classpath or destination dir in the compile task
since it will use the related sourceSet compile classpath and
destination dir.

We also remove the incorrect setting of the runtimeOnly and
testRuntimeOnly configurations.

Fixes bndtools#7306

Signed-off-by: BJ Hargrave <bj@hargrave.dev>
@bjhargrave bjhargrave merged commit 82005b8 into bndtools:master Jul 9, 2026
11 checks passed
@bjhargrave bjhargrave deleted the issues/7306 branch July 9, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Gradle Plugin: compileTestJava fails when using overlay file for a class found in a bundle on the buildpath

1 participant