Using GroovyDSL with @TypeChecked: Build Project fails

Cross-posting from Stack Overflow.

 

I have a `jenkins.gdsl` file defining some bindings I'm using in my Groovy script. In addition, I'd like to use the `@TypeChecked` annotation on my methods to get some guarantees about built code.

My `jenkins.gdsl` file looks like:

```groovy
contributor(context(scope: scriptScope())) {
// some definitions
}
```

And then my `script.groovy` looks like:

```groovy
@TypeChecked(extensions='jenkins.gdsl')
void doStuff() {
// ...
}
```

IntelliJ IDEA autocomplete works, but when building my project I get an error in my `jenkins.gdsl` file:

```
Error:Groovyc: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.scriptScope() is applicable for argument types: () values: []
```

Removing `(extensions='jenkins.gdsl')` gets rid of this error, but then I lose my GDSL definitions when building.

It feels like the solution would involve bringing in IntelliJ IDEA's `standardDsls`: https://github.com/JetBrains/intellij-community/tree/master/plugins/groovy/groovy-psi/resources/standardDsls

I am not at all sure how to do this, or whether it is in fact the correct approach.

0

请先登录再写评论。