Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ + groovy DSL: How to exclude files from being compiled by groovy plugin?

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.

like image 697
Doron Gold Avatar asked Jul 18 '13 14:07

Doron Gold


People also ask

How do I debug a Groovy script in IntelliJ?

Test a Groovy applicationPress Ctrl+Shift+T and select Create New Test. In the dialog that opens, specify your test settings and click OK. Open the test in the editor, add code and press Ctrl+Shift+F10 or right-click the test class and from the context menu select Run 'test name'.

What is Groovy Eclipse compiler?

Groovy-Eclipse provides a compiler adapter plugin for Maven, making it is possible to co-locate and compile your Groovy and Java sources using the Groovy-Eclipse batch compiler.


1 Answers

Try removing the groovy file suffix from the compiler's resources list:

Settings -> Compiler

IntelliJ IDEA Compiler Settings

like image 58
Anton Arhipov Avatar answered Sep 22 '22 18:09

Anton Arhipov