diffplug / diffplug/spotless

Enabling Parrot Parser for Groovy Eclipse

Open
#975 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
5.6k
Forks
559
Avg merge
1d 14h
Merged PRs (30d)
43

Description

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](https://github.com/groovy/groovy-eclipse/wiki/4.2.0-Release-Notes#support-for-new-versions-of-groovy), 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?

Contributor guide

Open the contributing guide

Research direction

Start by tracing SpotlessTask and the Gradle configuration described in build.gradle, then reproduce the failure with Groovy 3+ syntax and the -Dgroovy.antlr4=true option. Done means a team can enable the Parrot Parser through build.gradle without manually adding a JVM option to each Gradle execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java
Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.