Ignore resolution of copied configuration
When a Configuration is copied, any before and after resolve actions that are registered with its ResolvableDependencies are also copied over. This means that, when a copied configuration is resolved the resolution actions may be called on a ResolvableDependencies instances that isn't the one to which they were added. Previously, the above-described Gradle behaviour would result in BootJar accessed the ResolvedConfiguration of a Configuration that may not have yet been resolved. At best this would trigger Configuration resolution and at worst it would fail. A failure could occur if the configuration had been copied so that it could be made resolvable. The afterResolve action would then try to access the ResolvedConfiguration of the original Configuration. This would trigger a resolution attempt that fails due to the original configuration being marked as unresolvable. This commit updates the afterResolve action in BootJar to check that the ResolvableDependencies with which it is called matches the ResolvableDependencies with which it was original registered. Only when the two match, and therefore the configuration has actually been resolved, does processing proceed. Fixes gh-24072pull/24106/head
parent
e2af680f02
commit
409e3ccecf
@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
task resolveResolvableCopyOfUnresolvableConfiguration {
|
||||
doFirst {
|
||||
def copy = configurations.implementation.copyRecursive()
|
||||
copy.canBeResolved = true
|
||||
copy.resolve()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue