Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to format document #218

Open
CodingKoopa opened this issue Feb 7, 2021 · 5 comments
Open

Unable to format document #218

CodingKoopa opened this issue Feb 7, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@CodingKoopa
Copy link

CodingKoopa commented Feb 7, 2021

I have a Gradle project that I would like to format using this extension. This is my build.gradle, with the spotless configuration at the end of the file.

When I run gradle spotlessApply outside of VSCode, Gradle is successful, and issues in the files are fixed.

When I run the spotlessApply task using the Gradle Tasks extension, it is successful and works.

When I format the document, though, the issues are not fixed. I get this notification in VSCode:
image
The following is logged to the Gradle Tasks output:

[info] Completed build: spotlessApply -PspotlessIdeHook=/home/koopa/Documents/Projects/Java/Robot/Robot2021/src/main/java/frc/robot/Robot.java -PspotlessIdeHookUseStdIn -PspotlessIdeHookUseStdOut --quiet

The following is logged to the Spotless Gradle output:

[info] Running spotlessApply on Robot.java
[error] Unable to apply formatting: No status received from Spotless

Some other notes:

  • If this is the first time I'm formatting since reloading VSCode, the notification goes away in a second.
  • When formatting for the second time, the notification does not seem to go away. It seems that the build hangs after the first attempt. When cancelling this task, the following is logged to Gradle Tasks:
[info] Cancel build: Cancel build requested
[info] Build cancelled: spotlessApply -PspotlessIdeHook=/home/koopa/Documents/Projects/Java/Robot/Robot2021/src/main/java/frc/robot/Robot.java -PspotlessIdeHookUseStdIn -PspotlessIdeHookUseStdOut --quiet: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-6.0.1-bin.zip'.
  • After cancelling the second format, it's inconsistent as to whether or not it hangs.
  • When manually running the command from the Gradle Tasks output, the issues in the code are not fixed.

OS: Arch Linux
Gradle Version: 6.0.1
Gradle Tasks Version: 3.5.2
Spotless Gradle Version: 1.1.3

@CodingKoopa CodingKoopa added the bug Something isn't working label Feb 7, 2021
@pierrickrouxel
Copy link

Hello,

I experience the same problem with a basic config.

spotless {
  java {
    googleJavaFormat()
  }
} 

@pierrickrouxel
Copy link

In my case it was because my projects have modules. I added target:

spotless {
  java {
    googleJavaFormat()

    target 'src/*/java/**/*.java', 'modules/**/src/*/java/**/*.java'
  }
}

It solves my problem.

@badsyntax
Copy link
Owner

@CodingKoopa are you able to provide a repository/example project that demonstrates this issue?

@CodingKoopa
Copy link
Author

Going back in time, I added the spotless config in this commit, so the tree at that point is about as minimal as an example as I have. The Gradle file there is basically the same as the one in the OP.

I hadn't tested whether this can be triggered with a simpler config as @pierrickrouxel, and I don't really intend on going back to these projects to try it again. What's more is that my teammates who have taken over the project do report great success with this extension. If the issue is not easily reproduced by you, I wouldn't mind this being closed.

@weilbith
Copy link

I have also issues with this. As soon as I add the -PspotlessIdeHookUseStdIn parameter, it stops working. Running in the plain terminal it tells me it is waiting for input, even though I piped it to the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants