question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enabling Parrot Parser for Groovy Eclipse

See original GitHub issue

Since spotless depends on groovy-eclipse for groovy parsing/formatting, and since groovy-eclipse doesn’t enable the parrot parser by default, Spotless fails when configured for groovy code that utilizes Groovy 3+ syntax.

After experiencing some pain with spotless + groovy, I stumbled upon #246 which led me to dig into groovy-eclipse. Turns out groovy-eclipse leaves the new antlr4 based Parrot Parser disabled by default, which means any newer Groovy 3 syntax that contains, for example, Java lambdas, blows up.

I can manually add -Dgroovy.antlr4=true to my Gradle execution and that gets it working for me locally, but there should be some way to configure this right within build.gradle? I’m trying to find a solution that is more amenable to a team environment.

In the past I’ve modified JavaExec tasks and the like to include forked JVM options. But there seems to be no way to do that for SpotlessTask.

Am I missing something obvious here?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fvghcommented, Oct 27, 2021

For the Eclipse WTP formatter you cannot configure everything per project. Some things are still configured for per workspace. The WTP stores them statically. The spotless user doesn’t see this difference. In a multi-project build, you can configure multiple WTP based formatters.

So I propose for groovy.antlr4:

  1. Store value statically
  2. If GrEclipseFormatterStepImpl is called is twice with different values, throw an IllegalArgumentException
0reactions
jamesdhcommented, Oct 27, 2021

That could be solved by declaring this option as not changeable, as we did it for WTP.

I’m struggling to understand what you mean by this. Could you give a bit more context? Thanks for the help already!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable parrot parser on build.gradle : r/groovy - Reddit
I've got a project that has both eclipse and IntelliJ contributors. Groovy-eclipse's parrot parser support is still in basically alpha ...
Read more >
Parrot parser not used because IDEA ignores 'Main-Class ...
It is difficult to set up IDEA to compile with Groovy-Eclipse using the Parrot parser in order to support Groovy 3 support for...
Read more >
Release notes for Groovy 3.0
Groovy 3.0, has a new parser that is far more flexible and maintainable than the parser in previous versions of Groovy. It's called...
Read more >
How to disable parrot parser on build.gradle - r/groovy
I've got a project that has both eclipse and IntelliJ contributors. Groovy-eclipse's parrot parser support is still in basically alpha status.
Read more >
Download - The Apache Groovy programming language
Refer to the appropriate Apache Groovy jars from your build tools. ... of Groovy designed for JDK8+ with a new more flexible parser...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found