Last active
August 26, 2021 19:56
-
-
Save bitsnaps/ed418ec6385aa6f1465e4696f2595a2a to your computer and use it in GitHub Desktop.
Activate Type Checking and Compile Static for all Groovy classes in Gradle (or Android) project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We know we can apply type checking and compile static on all groovy classes, the good news you can do this on gradle build, so it'll be applied in every class in your project, this works in android project. | |
/*/ In gradle project: | |
apply plugin: 'groovy' | |
compileGroovy.groovyOptions.configurationScript = file('gradle/config/groovyc.groovy') | |
// In Android project (app/build.gradle) | |
androidGroovy { | |
options { | |
configure(groovyOptions) { | |
configurationScript = file("$projectDir/config/groovyc.groovy") | |
} | |
} | |
}*/ | |
// file: $projectDir/config/groovyc.groovy | |
import groovy.transform.CompileStatic | |
import groovy.transform.TypeChecked | |
withConfig(configuration) { | |
ast(CompileStatic) | |
ast(TypeChecked) | |
} | |
// credits to: https://medium.com/@jonashavers/how-to-activate-type-checking-for-all-groovy-classes-57ce785d5028 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment