This message was deleted.
# community-support
s
This message was deleted.
p
Could someone please help me?
a
could you share the relevant bits of the code so we don’t have to download zips? :) You can attach code snippets to Slack messages
p
This is problematic code :)
a
thanks!
👍 1
which version of Gradle are you using?
p
The problem occurs in these versions. But I have only tested these.
a
I’m certainly no Groovy dev, but I can’t see any obvious difference between your implementation and the one in Terraform
I think it’s pretty unusual to extend NamedDomainObjectContainer. Gradle types are usually not intended to be implemented by plugin authors, but such types are usually have Javadoc saying so
what version of Gradle are you using to build your project?
p
NamedDomainObjectContainer is an interface, not class 🙂
I'm using Gradle 8.2 🙂
a
my only guess would be that
@Delegate(interfaces = true)
works in Gradle 6.4, but no longer works in Gradle 8.2
oh…. does the Terraform plugin use
@Delegate(interfaces = true)
?
p
Yes, but this property is declared at the bottom of file
p
I added Gradle 6.4.1 to my tests and also failing with the same Exception
a
but your plugin would still be built using Gradle 8.2
p
I'm going to try several different versions of Gradle using Wrapper. Likewise, I will try different versions of Java.
👍 1
a
there’s a 1-to-1 link between the version of Gradle your plugin supports and the version of Gradle used to build the project (there’s a vague and complicated workaround for this, so I wouldn’t recommend it)
p
Wow! You were right! But how is that possible....
I will check also with Gradle 8.1....
a
Gradle v7 updated the Groovy version from v2 to v3, so perhaps it’s a Groovy change https://docs.gradle.org/current/userguide/upgrading_version_6.html#updates_to_bundled_gradle_dependencies
p
8.1.1 — tests fails 8.0.2 — tests fails 7.6.2 — tests fails 7.0.2 — fails during compile:
Copy code
> Task :compileGroovy FAILED
startup failed:
/tmp/exampleSourceSetsPlugin/src/main/groovy/com/example/internal/DefaultExampleSourceSets.groovy: 10: [Static type checking] - Cannot find matching method org.gradle.api.NamedDomainObjectContainer#add(com.example.ExampleSourceDirectorySet). Please check if the declared type is correct and if the method exists.
 @ line 10, column 5.
       @Delegate(interfaces = true)
       ^

1 error
6.9.1 — tests pass So as you wrote, it may have to do with the Groovy version. I'll try forcing an older version of Groovy in Plugin Development in that case.
a
just be aware that you might bump into some other problems with downgrading Groovy https://docs.gradle.org/current/userguide/compatibility.html#groovy
Gradle plugins written in Groovy must use Groovy 3.x for compatibility with Gradle and Groovy DSL build scripts.
p
I would like to check this for testing. On the other hand, the question arises, is this some kind of bug in Gradle, due to the new version of Groovy?
a
it’s a change in behaviour, but to me it doesn’t look like a bug
p
This is the complete list of methods that the
DefaultExampleSourceSets
class must implement as a result of implementing the
ExampleSourceSets
interface. I have highlighted those methods that I needed to define in the
DefaultExampleSourceSets
class. It seems that the @Delegate annotation in the new version of Groovy has a problem with methods that take
Class<T>
as a parameter.
I think I will contact the Groovy community. 🤔
@Adam Thanks for your help 🙂 At least I now know where to look next for answers.
a
my pleasure!
what might work is to manually create an instance of
DefaultExampleSourceSets
and then use ‘add’ instead of ‘create’. Then you wouldn’t have to worry about trying to be compatible with how Gradle instantiates types.