Use os.SameFile() to check for mvnw working-dir echo bug
@@ -35,6 +35,11 @@ func getDependencies(cmd *exec.Cmd) ([]string, error) {
return nil, err
}
+ cmdDirInfo, err := os.Stat(cmd.Dir)
+ if err != nil {
+ return nil, err
+ }
+
// Parses stdout for the dependencies, one per line
lines := strings.Split(string(stdout), "\n")
@@ -44,12 +49,6 @@ func getDependencies(cmd *exec.Cmd) ([]string, error) {
continue
}
- // TODO(coollog): Remove this once Jib deps are prepended with special sequence.
- // Skips the project directory itself. This is necessary as some wrappers print the project directory for some reason.
- if dep == cmd.Dir {
- continue
- }
-
// Resolves directories recursively.
info, err := os.Stat(dep)
if err != nil {
@@ -60,6 +59,12 @@ func getDependencies(cmd *exec.Cmd) ([]string, error) {
return nil, errors.Wrapf(err, "unable to stat file %s", dep)
}
+ // TODO(coollog): Remove this once Jib deps are prepended with special sequence.
+ // Skips the project directory itself. This is necessary as some wrappers print the project directory for some reason.
+ if os.SameFile(cmdDirInfo, info) {
+ continue
+ }
+
if !info.IsDir() {
deps = append(deps, dep)
continue
