Skip to content

Logging: destination path missing when destination equals basedir in DefaultMavenResourcesFiltering #337

@mguelton

Description

@mguelton

Affected version

3.x

Bug description

When DefaultMavenResourcesFiltering.filterResources() logs copy operations it uses Path.relativize against the project's base directory. If the destination path equals basedir (i.e. copy to the basedir directory), basedir.relativize(destination) returns an empty string, so the log message ends with "to ".
For example: "Copying 1 resource from sourcedir to ".

Current code:

LOGGER.info("Copying " + includedFiles.size() + " resource" + (includedFiles.size() > 1 ? "s" : "")
                        + " from "
                        + basedir.relativize(resourceDirectory.toAbsolutePath())
                        + " to "
                        + basedir.relativize(destination));

The log message should show the destination path:

  • "." or
  • the absolute path or
  • "basedir" / "project base directory"

Suggested code change:

LOGGER.info("Copying " + includedFiles.size() + " resource" + (includedFiles.size() > 1 ? "s" : "")
                        + " from "
                        + basedir.relativize(resourceDirectory.toAbsolutePath())
                        + " to "
                        + (basedir.equals(destination) ? "." : basedir.relativize(destination)));

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions