Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generateLock task throws exception with newer Guava version (affects older versions) #215

Open
lptr opened this issue Jun 21, 2021 · 0 comments

Comments

@lptr
Copy link

lptr commented Jun 21, 2021

Note: this seems to be fixed already in 11.2.0, but is a problem for 8.8.0, 9.4.1 and 10.1.0.

I'm trying to upgrade the Guava version used by Gradle itself, and after the upgrade this plugin fails to run. The culprit seems to be on line 60 here where the private size field is referred instead of the public size() method:

static boolean safelyHasAResolutionAlternative(Configuration configuration) {
// 'getResolutionAlternatives' is a method on DefaultConfiguration as of Gradle 6.0
def method = configuration.metaClass.getMetaMethod('getResolutionAlternatives')
if (method != null) {
def alternatives = configuration.getResolutionAlternatives()
if (alternatives != null && alternatives.size > 0) {
return true
}
}
return false
}

The fix should be to simply replace the field reference with the method reference.

Here's the exception I get:

> Task :generateLock FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateLock'.
> Exception evaluating property 'size' for com.google.common.collect.RegularImmutableList, Reason: groovy.lang.MissingPropertyException: No such property: size for class: java.lang.String

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
...
Caused by: groovy.lang.MissingPropertyException: Exception evaluating property 'size' for com.google.common.collect.RegularImmutableList, Reason: groovy.lang.MissingPropertyException: No such property: size for class: java.lang.String
	at nebula.plugin.dependencylock.utils.ConfigurationFilters.safelyHasAResolutionAlternative(ConfigurationFilters.groovy:60)
	at nebula.plugin.dependencylock.utils.ConfigurationFilters$safelyHasAResolutionAlternative.call(Unknown Source)
	at nebula.plugin.dependencylock.tasks.GenerateLockTask$_lockableConfigurations_closure3.doCall(GenerateLockTask.groovy:102)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.gradle.api.specs.internal.ClosureSpec.isSatisfiedBy(ClosureSpec.java:33)
	at org.gradle.api.internal.collections.CollectionFilter.filter(CollectionFilter.java:46)
	at org.gradle.api.internal.collections.FilteredCollection$FilteringIterator.findNext(FilteredCollection.java:122)
	at org.gradle.api.internal.collections.FilteredCollection$FilteringIterator.next(FilteredCollection.java:140)
	at org.gradle.api.internal.DefaultDomainObjectCollection.findAll(DefaultDomainObjectCollection.java:442)
	at org.gradle.api.internal.DefaultNamedDomainObjectSet.findAll(DefaultNamedDomainObjectSet.java:82)
	at org.gradle.api.NamedDomainObjectSet$findAll$0.call(Unknown Source)
	at nebula.plugin.dependencylock.tasks.GenerateLockTask.lockableConfigurations(GenerateLockTask.groovy:100)
	at nebula.plugin.dependencylock.tasks.GenerateLockTask$lockableConfigurations.callStatic(Unknown Source)
	at nebula.plugin.dependencylock.tasks.GenerateLockTask.lock(GenerateLockTask.groovy:91)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
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

No branches or pull requests

1 participant