java - Maven 依赖插件 - 包含文件和文件夹

标签 java maven

我有一个 Maven 项目,其结构为:

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

在我的 pom.xml 中,我有:

<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>

它将我的所有 Maven 依赖项复制到 target/dist/lib/third-party 目录。我怎样才能将 lib(参见上面的结构)文件夹中的所有文件/文件夹包含到该位置?

最佳答案

由于这些文件是配置和属性文件,我将它们分类为资源并使用 maven-resources-plugin包括他们。

<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>

关于java - Maven 依赖插件 - 包含文件和文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32229650/

相关文章:

java - 在流口水中迭代列表

java - ionic Android 构建停止工作

java - 我对 org.springframework.mock.web 缺少什么依赖项?

java - 对文件递归执行 Maven 命令

java - 应用程序类(应用程序监听器)org.springframework.web.context.ContextLoaderListner 的配置错误

maven - Grails装置:grails运行应用程序有效,但mvn grails:run-app无法运行

Java HttpRequest 超时意外抛出 HttpConnectTimeoutException

java - 当我从命令行设置参数(例如 -DrunIT=true)时,从配置文件的 Maven 故障安全插件运行集成测试

java - 如何解决 Tomcat 8/Library/Tomcat/work/Catalina/localhost 目录中缺少的 servlet 类?

java - Jboss 内置的 hibernate jar 在 eclipse 中看不到,为什么?关于库部署最佳实践的问题