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

Set the rootDir as / instead of // if the project is in the root of the filesystem #732

Merged
merged 2 commits into from
Nov 16, 2020

Conversation

rudolfv
Copy link

@rudolfv rudolfv commented Nov 13, 2020

This PR is to fix a bug if a gradle project is in the root of a filesystem. Normally this would not be an issue as projects would are generally not at the root, but in the case of a Docker or other container, the situation could arise:

	Caused by: java.lang.IllegalArgumentException: Expected '/src/main/java/com/acme/MyApplication.java' to start with '//'
		at com.diffplug.spotless.FileSignature.subpath(FileSignature.java:203)
		at com.diffplug.spotless.extra.GitAttributesLineEndings$CachedEndings.endingFor(GitAttributesLineEndings.java:126)
		at com.diffplug.spotless.extra.GitAttributesLineEndings$RelocatablePolicy.getEndingFor(GitAttributesLineEndings.java:95)
		at com.diffplug.spotless.Formatter.computeLineEndings(Formatter.java:211)
		at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:203)
		at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:188)
		at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:71)
		at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:57)
		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I've read the instructions about adding to the CHANGES.md file, but I don't see a -SNAPSHOT section. I did see the below however, so I presume it is no longer necessary?

@nedtwigg
Copy link
Member

Thanks for the fix!

If you update each of the changelogs (root, gradle, and maven) along these lines:

## [Unreleased]
### Fixed
* Fixed a bug which occurred if the root directory of the project was also the filesystem root ([#732](https://github.com/diffplug/spotless/pull/732))

then I'll push the release button.

@rudolfv
Copy link
Author

rudolfv commented Nov 16, 2020

Thanks for the update, @nedtwigg! I have made the requested changelog changes.

@nedtwigg nedtwigg merged commit 23f8d69 into diffplug:main Nov 16, 2020
@nedtwigg
Copy link
Member

Published in plugin-gradle 5.8.2 and plugin-maven 2.6.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants