Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private <T> List<T> map(List<T> resources, Function<T, T> mapper) {

private Resource alignToBaseDirectory(Resource resource, Path basedir) {
if (resource != null) {
String newDir = alignToBaseDirectory(resource.getDirectory(), basedir);
String newDir = mayAlignToBaseDirectoryOrNull(resource.getDirectory(), basedir);
if (newDir != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be changed to if (!Objects.equals(newDir, resource.getDirectory())

return resource.withDirectory(newDir);
}
Expand All @@ -116,6 +116,17 @@ private Resource alignToBaseDirectory(Resource resource, Path basedir) {
}

private String alignToBaseDirectory(String path, Path basedir) {
String newPath = mayAlignToBaseDirectoryOrNull(path, basedir);
if (newPath != null) {
return newPath;
}
return path;
}

/**
* Returns aligned path or {@code null} if no need for change.
*/
private String mayAlignToBaseDirectoryOrNull(String path, Path basedir) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this new method.

String newPath = pathTranslator.alignToBaseDirectory(path, basedir);
return Objects.equals(path, newPath) ? null : newPath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the above line should be removed.

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private <T> List<T> map(List<T> resources, Function<T, T> mapper) {

private Resource alignToBaseDirectory(Resource resource, Path basedir) {
if (resource != null) {
String newDir = alignToBaseDirectory(resource.getDirectory(), basedir);
String newDir = mayAlignToBaseDirectoryOrNull(resource.getDirectory(), basedir);
if (newDir != null) {
return resource.withDirectory(newDir);
}
Expand All @@ -125,6 +125,17 @@ private Resource alignToBaseDirectory(Resource resource, Path basedir) {
}

private String alignToBaseDirectory(String path, Path basedir) {
String newPath = mayAlignToBaseDirectoryOrNull(path, basedir);
if (newPath != null) {
return newPath;
}
return path;
}

/**
* Returns aligned path or {@code null} if no need for change.
*/
private String mayAlignToBaseDirectoryOrNull(String path, Path basedir) {
String newPath = pathTranslator.alignToBaseDirectory(path, basedir);
return Objects.equals(path, newPath) ? null : newPath;
}
Expand Down