Alaric Dailey
Alaric Dailey

Reputation: 101

Grails TypeChecked / CompileStatic / GrailsCompileStatic

Is there a way to add the functionality for @TypeChecked, @GrailsCompileStatic, @CompileStatic to an entire grails project?

To explain code I am now working on is in grails, simple things that I would expect to be compilation failures simply pass, and sometimes work, other times it just wait for run time to throw failures. Other things like using Generics throw compilation errors.

@TypeChecked fixes the generic issues, @GrailsCompileStatic and @CompileStatic highlight a lot of other issues misnamed variables, things that don't exist, mismatched types, and other things that may or may not "automagically work".

Upvotes: 2

Views: 477

Answers (2)

virtualdogbert
virtualdogbert

Reputation: 481

While I do agree with what others say you will lose out in certain areas.

However, you could try the Enterprise Groovy Gradle plugin: https://virtualdogbert.github.io/enterprise-groovy-plugin/

This will give you static compilation by default, but will also slow you to white-list the places that need dynamic compilation. There is a Grails config that worked at one point for a simple app. Your mileage may vary. This project won't give you IDE support though like @CompileStatic will.

Also, full disclosure this is one of my side projects.

Upvotes: 1

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27200

Is there a way to add the functionality for @TypeChecked, @GrailsCompileStatic, @CompileStatic to an entire grails project?

No. There are aspects of Grails apps that require dynamic dispatch. You cannot statically type check and statically compile everything in a Grails app.

Upvotes: 2

Related Questions