Skip to content

[Maven 4] Maven resources plugin - relative targetPath is not the same as in Maven 3.9.x #11381

@philippe-granet

Description

@philippe-granet

Affected version

Apache Maven 4.0.0-SNAPSHOT (b7f9178)

Bug description

With Maven 3.9.x and this configuration:

    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/rest</directory>
                <targetPath>target-dir</targetPath>
                <includes>
                    <include>**/*.yml</include>
                </includes>
            </resource>
        </resources>
    </build>

all files rest/**/*.yml are copied to target/classes/target-dir:

[INFO] --- resources:3.3.1:resources (default-resources) @ project1 ---
[INFO] Copying 36 resources from rest to target/classes/target-dir

But with Maven 4, with same version of Maven resources plugin, all files rest/**/*.yml are copied to root dir target-dir:

[INFO] --- resources:3.3.1:resources (default-resources) @ project1---
[INFO] Copying 36 resources from rest to target-dir
[INFO] ---------------------------------------------

It seams that relative targetPath is not the same as in Maven 3.9.x

A workaround is to prefix targetPath with ${project.build.outputDirectory}/, it works both on Maven 3 and 4:

    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/rest</directory>
                <targetPath>${project.build.outputDirectory}/target-dir</targetPath>
                <includes>
                    <include>**/*.yml</include>
                </includes>
            </resource>
        </resources>
    </build>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions