Dmitry
Dmitry

Reputation: 3038

Maven Resource Custom File Path

Good time!

I have such a pom snippet:

<build>
        <resources>

            <resource>
                <directory>${project.build.directory}/additional-resources</directory>
                <targetPath>targetDir</targetPath>
                <includes>
                    <include>copied/bindings/**/*</include>
                </includes>
            </resource>

        </resources>

        ...

</build>

After a compilation phase, I see such a hierarchy in the build directory: targetDir/copied/bindings/test/... which fully copies the path in the generated-sources directory.

Is there a way to tell Maven to make the build/targetDir/test/... (trim the path) directory?

Upvotes: 0

Views: 166

Answers (1)

user944849
user944849

Reputation: 14951

As far as I know, the Maven resources plugin does not provide a way to trim the path like you need. I can think of two ways to solve this.

  1. Change whatever is generating the resources so they are in the final directory structure required (e.g. ${project.build.directory}/additional-resources/test/...) . That way when the resources plugin copies the structure, it will be what you want.
  2. Use ant, via the maven-antrun-plugin. Ant has a concept of a "flatten mapper" which allows you to configure the target directory structure during the copy.

Upvotes: 1

Related Questions