20

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
4
  • 2
    Have you tried adding groovy as a Global Library in project's platform settings in IntelliJ? Commented Jun 20, 2013 at 22:19
  • 2
    Have you tried a more recent version of Groovy? 1.7.4 is almost 3 years old Commented Jun 20, 2013 at 22:24
  • Agree. There are various useful features available in recent version which is not present in Groovy 1.7.*. Speaking out of experience transitioning older version of Grails project to recent. :) Commented Jun 20, 2013 at 23:25
  • It's the most recent groovy available on my distribution... any why would it work from ant and not IntelliJ? Commented Jun 21, 2013 at 4:50

10 Answers 10

8

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.

Sign up to request clarification or add additional context in comments.

Comments

7

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.

Comments

4

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

3 Comments

Thanks. I just switched back to Java 8 for this project.
For me I found the going to "Project Settings">"Libraries", clicking on "+" , then on "From Maven..." and then pasting org.openjax.jaxb:xjc:0.8.5 .This worked for me after a lengthy scanning and indexing progress bar.
@Sled This should probably be an answer rather than a comment.
3

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'

1 Comment

It didn't show the mismatch error for me but matching the groovy-all dependency version with local Groovy version (groovy -v) did solve the problem.
2

Move the Groovy dependency in the module settings to the top right after JDK.

Comments

1

I could make it work just by reestart intellij and invalidate the caches.

It can be found (for intelliJ 2018.1):

File -> Invalidate Caches/restart -> Invalidate and Restart

Comments

0

I found this solution which worked totally for me. You can use this link for fixing this problem

resolving-groovyc-internal-groovyc-error-code-1

1 Comment

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
0

I had to reinstall groovy SDK and it started working.

Comments

0

i was use wrong SDK ,please cheak your SDK version

Comments

0

I had this problem while using IntelliJ 2023.3 version (with java 8) and found this useful workaround: https://youtrack.jetbrains.com/issue/IDEA-337831/Building-non-tiny-Groovy-projects-using-JPS-on-Java-8-fully-broken-in-2023.3#focus=Comments-27-8611612.0-0

(just for the record, it was fixed on 2023.3.2)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.