1

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?

3
  • What would you like to achieve? Looks like a distribution archive? If yes than maven-dependency-plugin is the wrong way... Commented Aug 26, 2015 at 14:43
  • what kind of the files that are stored in lib/? is it jar or another binary artifact or is it a source code? Commented Aug 26, 2015 at 14:49
  • those are some configuration files and property files (required by some other third-party jar) Commented Aug 26, 2015 at 14:50

2 Answers 2

1

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>
Sign up to request clarification or add additional context in comments.

Comments

0

use maven-assembly-plugin

It answers exactly your question

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.