virtualdogbert / enterprise-groovy-plugin

A gradle plugin for adding @CompileStatic by default with optional configurable enforcement.
Apache License 2.0
8 stars 2 forks source link

Templates compilation issue #5

Closed apryamostanov closed 5 years ago

apryamostanov commented 5 years ago

Hi @virtualdogbert ,

Please kindly take a look at Pull request: https://github.com/virtualdogbert/enterprise-groovy/pull/1

It contains a failing test script for Template compilation (make):

> Task :test FAILED

com.virtualgodbert.ast.egp.TemplateCompilationTest > test FAILED
    groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
    SimpleTemplateScript1.groovy: 1: [Static type checking] - The variable [out] is undeclared.
     @ line 1, column 1.
       out.print("""$thisShouldWork""");

Since this is a global AST transformation, I believe it should not affect runtime compilation that would have been working before adding the library into the classpath. Probably only build-time compilation should be affected.

Not sure how to fix this though now.

apryamostanov commented 5 years ago

Note: this is not a synthetic test case - I tried adding the Enterprise Groovy Plugin to my project Bobbin (https://github.com/INFINITE-TECHNOLOGY/BOBBIN) but the test cases containing Template Make failed.

apryamostanov commented 5 years ago

I believe the plugin should not affect Test sources.

virtualdogbert commented 5 years ago

The plugin doesn't discriminate based on where the class is. I think a valid workaround would be to whitelist your tests. The white list used a contains on the fully qualified name of the class, so you can , either be very specific, whitelist by package, or by names that contain test or spec. I've noticed that most of your tests don't end with the postfix test, which is common when using junit, where spec is common when using spock.

Another work around is to use @CompileDynamic .

apryamostanov commented 5 years ago

Is blocked by #6 and #7

apryamostanov commented 5 years ago

will be retested after #6 and #7 are fixed