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

FileTreeElement.getPath() returns absolute system dependent filepath #6656

Closed
Larusso opened this issue Sep 6, 2018 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@Larusso
Copy link

Larusso commented Sep 6, 2018

With Gradle 4.10 the result of FileTreeElement.getPath() changed in a breaking way.

Expected Behavior

From the method documentation:

Returns the path of this file, relative to the root of the containing file tree. Always uses '/' as the hierarchy separator, regardless of platform file separator. Same as calling getRelativePath().getPathString().

The expected String path should be relative to the FileTree and use / as file seperators even on windows environments.

Current Behavior

With Gradle 4.10 this changed. The resulting String is an absolute system dependent path.

Context

In my plugin I provide a default FileCollection which is constructed with the help of PatternFilterable include(Spec<FileTreeElement> includeSpec); API.
In my Spec<FileTreeElement> implementation I retrieve the file path with `element.getPath() and do some checks based on the asumption that it is relative and normalized.

In gradle <= 4.9 the FileTreeElement was implemented as a DefaultFileVisitDetails which calls getRelativePath().getPathString(); as advertised in the docs.
As of gradle 4.10 some elements are implemented as PathBackedFileTreeElement which implements getPath() as follows:

@Override
public String getPath() {
return path.toString();
}

Steps to Reproduce (for bugs)

https://github.com/wooga/atlas-build-unity in branch gradle/issue_6656

running the test specs from UnityBuildPlayerTaskIntegrationSpec will work from gradle version 3.5 - 4.9 and start to fail on 4.10.

Your Environment

I can verify this issue both on macOS and windows systems.

@oehme oehme added this to the 4.10.1 milestone Sep 6, 2018
@wolfs
Copy link
Member

wolfs commented Sep 6, 2018

@Larusso Thank you for the report! That really seems to be a problem and we will fix it for 4.10.1.

I cannot reproduce the test failure for your project. I have been running:

GRADLE_VERSION=4.10 ./gradlew integrationTest --tests="*UnityBuildPlayerTaskIntegrationSpec*"

See https://scans.gradle.com/s/d5lyvljx62jke/tests

@Larusso
Copy link
Author

Larusso commented Sep 6, 2018

Ah sorry I already fixed it with the last commit by using ‘getRelativePath().getPathString();’ instead. I could push a branch without the patch if needed.

@Larusso
Copy link
Author

Larusso commented Sep 6, 2018

I pushed a branch (gradle/issue_6656) to replicate the issue.

GRADLE_VERSION=4.9 ./gradlew integrationTest --tests="*UnityBuildPlayerTaskIntegrationSpec*" works

GRADLE_VERSION=4.10 ./gradlew integrationTest --tests="*UnityBuildPlayerTaskIntegrationSpec*" fails

@wolfs
Copy link
Member

wolfs commented Sep 7, 2018

Fixed via #6667.

@wolfs wolfs closed this as completed Sep 7, 2018
@mark-vieira mark-vieira modified the milestones: 4.10.1, 4.10 Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants