Repository navigation
fix(build): make build.gradle work with Gradle 7+ (#1) - #2
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1.
Gradle 7+ (and 8/9) reject resolving the
compileOnlyconfiguration directly:The build redefined
compileOnlyand setcompileGroovy.classpath = configurations.compileOnly + ..., which triggers this.Fix
The
groovyplugin already providescompileOnlyand wires it intocompileClasspath, so the custom plumbing is unnecessary:compileOnlydeclaration (keeptestImplementation.extendsFrom compileOnlyso tests still see those deps)compileGroovy.classpathoverride — the plugin's default already includes compileOnly depsI 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
canBeResolvederror on Gradle 9.5.1, confirmed it's gone after the fix. (The build then surfaces a separate@CompileStatictype-checking bug inSpawnTaskHandler.groovy— filed separately.)