I am working on a Java web project that uses Liquibase groovy DSL to managae DB changes.
For the sake of this topic, it could be any other 3rd party library that uses *.groovy
files as sources.
The project is built with gradle.
In one of my modules (dao-base
) under the src/main/resources
folder I have groovy files (changelog01.groovy, master_changelog.groovy
etc.). these files should be loaded by the liquibase jar at runtime.
Now when I try to make the project in IntelliJ it gives the following error message:
Groovyc: Cannot compile Groovy files: no Groovy library is defined for module 'dao-base'.
I understood that the groovy plugin detects *.groovy
files, tries to compile them and unsurprisingly fails. these are groovy DSL files that should be loaded only by the 3rd party liquibase parser and I don't need IntelliJ's groovy plugin to try and compile them.
I managed to come up with 2 partial solutions:
1. disabling groovy plugin in intellij.
The problem with this solution is that the gradle plugin depends on the groovy plugin and thus is automatically disabled when disabling the groovy plugin. I need the gradle plugin enabled.
2. excluding the src/main/resources
folder in project settings --> modules --> dao-base
(my module) --> sources tab.
The problem with this solution is that when I build the project and deploy to tomcat, the files from the resources folder are missing and since the files in it are required in runtime, I get file not found exception when the war loads.
I was hoping someone could come up with a better solution for this problem.
Try removing the groovy file suffix from the compiler's resources list:
Settings -> Compiler