Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolving: Groovyc: Internal groovyc error: code 1

I'm compiling a project that works OK in Eclipse, and builds fine with ant, but in IntelliJ IDEA gives:

  • Internal groovyc error: code 1

How can I resolve this? Other error messages include:

1:35:46 PM Unknown Natures Detected
           Imported projects contain unknown natures:
           org.eclipse.jdt.groovy.core.groovyNature
           Some settings may be lost after import.
1:43:55 PM Compilation completed with 1 error and 7 warnings in 20 sec
Groovyc: Cannot compile Groovy files: no Groovy library is defined for module

Groovy itself is installed on Linux. Adding it as a groovy compiler in settings does not affect the behavior:

> groovy --version
Groovy Version: 1.7.4 JVM: 1.6.0_24
like image 764
Bryce Avatar asked Jun 20 '13 22:06

Bryce


4 Answers

Apparently you tried to import an Eclipse project into IDEA, and that isn't good enough. (Groovy) Eclipse comes with its own version of Groovy, whereas in IDEA, you have to add groovy-all-1.7.4.jar (or whatever version you want to use) as a compile dependency.

like image 55
Peter Niederwieser Avatar answered Oct 20 '22 11:10

Peter Niederwieser


You have to add JAXB dependencies if you are using Groovy 2.5.3 + Java 11 (also check out Java 11 related change). Groovy comes with extra JAXB Jars so we can add them. Open 'Project Structure' dialog, then select 'Dependencies' tab and add the dependencies

like image 21
Kdn Krishna Avatar answered Oct 20 '22 11:10

Kdn Krishna


Changing the project SDK from Java 15 to Java 8 seemed to have magically fixed the same problem on my machine.

Steps:

  1. Go to File > Project structure... (may differ on Mac/Linux).

  2. Under Project Settings, select Project.

  3. In Project SDK: dropdown, choose a different version of the JDK installed.

  4. Click Apply & OK at the bottom of the dialog.

** Rerun your program.

like image 4
Dut A. Avatar answered Oct 20 '22 10:10

Dut A.


This worked for me!!

Read the log before the "Internal groovyc error: code 1", then it should show you a groovy version mismatch. Change your groovy version from the dependency list as per the log.

Ex. compile 'org.codehaus.groovy:groovy-all:2.4.11'

like image 3
Yunesh Shalika Senarathna Avatar answered Oct 20 '22 12:10

Yunesh Shalika Senarathna