Skip to content

fix(build): make build.gradle work with Gradle 7+ (#1) - #2

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/gradle7-compileonly
Jun 2, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/gradle7-compileonly

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Closes #1.

Gradle 7+ (and 8/9) reject resolving the compileOnly configuration directly:

Resolving dependency configuration 'compileOnly' is not allowed as it is defined as 'canBeResolved=false'.

The build redefined compileOnly and set compileGroovy.classpath = configurations.compileOnly + ..., which triggers this.

Fix

The groovy plugin already provides compileOnly and wires it into compileClasspath, so the custom plumbing is unnecessary:

  • drop the redundant compileOnly declaration (keep testImplementation.extendsFrom compileOnly so tests still see those deps)
  • remove the manual compileGroovy.classpath override — the plugin's default already includes compileOnly deps

I used the convention-following fix rather than the compileOnly { canBeResolved = true } workaround from the issue, since redefining a standard configuration as resolvable fights Gradle's design.

Verification

Reproduced the original canBeResolved error on Gradle 9.5.1, confirmed it's gone after the fix. (The build then surfaces a separate @CompileStatic type-checking bug in SpawnTaskHandler.groovy — filed separately.)

Gradle 7+ rejects resolving the `compileOnly` configuration directly
("Resolving dependency configuration 'compileOnly' is not allowed as it is
defined as 'canBeResolved=false'"). The build redefined `compileOnly` and set
`compileGroovy.classpath = configurations.compileOnly + ...`, which trips this.

The `groovy` plugin already provides `compileOnly` and wires it into
`compileClasspath`, so:
- drop the redundant `compileOnly` configuration declaration (keep the
  testImplementation.extendsFrom so tests still see those deps)
- remove the manual `compileGroovy.classpath` override entirely — the plugin's
  default classpath already includes compileOnly deps

Verified the `canBeResolved` error no longer occurs (Gradle 9.5.1).
Closes #1.
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.

build.gradle incompatible with Gradle 7+: compileOnly not resolvable

1 participant