Kamil Kłys
Kamil Kłys

Reputation: 2047

Maven dependency plugin - include files and folders

I have a Maven project with a structure:

Project
|---lib
|   |---<files and folders I want to include>
|
|---src
|   |---<regular files and folders>
|
|---pom.xml

In my pom.xml I have:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <id>copy-dependencies-third-party</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>target/dist/lib/third-party</outputDirectory>
                    <excludeGroupIds>...</excludeGroupIds>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

And it copies all my maven dependencies to target/dist/lib/third-party directory. How can I also include all files/folders from lib (see in structure above) folder to that location?

Upvotes: 1

Views: 1564

Answers (2)

Yuri G.
Yuri G.

Reputation: 4648

Since these files are configuration and properties files i would classify them as resources and would use the maven-resources-plugin to include them.

<resources>
   <!-- The resources in the lib folder -->
   <resource>
      <directory>lib</directory>
      <targetPath>${project.build.directory}/dist/lib/third-party</targetPath>

      <!-- add this if you want to define parameters in these resources -->
      <filtering>true</filtering>
   </resource>

   <!-- We need to redeclare the project resources again -->
   <resource>
      <directory>src/main/resources</directory>
      <filtering>true</filtering>
   </resource>
</resources>

Upvotes: 1

Steve Marion
Steve Marion

Reputation: 289

use maven-assembly-plugin

It answers exactly your question

Upvotes: 0

Related Questions