Maven - 如何包含空目录 [英] Maven - how to include empty directories

查看:42
本文介绍了Maven - 如何包含空目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,maven 在构建过程中会删除空目录.
不知道能不能在pom中指定一个参数来指示maven在生成的target/test-classes文件夹中包含空目录?

By default during the build process maven is removing the empty directories.
Do you know if a parameter can be specified in the pom to instruct maven to include empty directories in the generated target/test-classes folder?

推荐答案

根据这张票 MRESOURCES-36,应该有一个 元素,但仅限于 Maven 资源插件 2.3.

According to this ticket MRESOURCES-36, there should be a <includeEmptyDirs> element, but only for Maven Resources Plugin 2.3.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.3</version>
  <configuration>
    <includeEmptyDirs>true</includeEmptyDirs>
  </configuration>
</plugin>

<小时>

对于包含旧版本资源插件的 Maven 版本:


For Maven versions which included an older version of the Resources plugin:

在解决此问题之前,这是我一直在成功使用的解决方法.
将此插件元素添加到 pom.xml 中的 project/build/plugins 中,并更改 mkdir 任务中的目录.

Until this issue is fixed, here is a workaround I've been using successfully.
Add this plugin element into project/build/plugins in your pom.xml, and change the dir in the mkdir task.

对于多个目录,您可以有多个 元素.如果目录已经被资源插件复制,mkdir 任务什么都不做.

You can have multiple <mkdir> elements for multiple directories. The mkdir task does nothing if the directory has already been copied by the resources plugin.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>create-empty-directory</id>
      <phase>process-classes</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <tasks>
          <mkdir dir="${basedir}/target/classes/empty" />
        </tasks>
      </configuration>
    </execution>
  </executions>
</plugin>

这最初来自 openejb-standalone pom.xml 在 openejb 项目中.

This originally came from the openejb-standalone pom.xml in the openejb project.

这篇关于Maven - 如何包含空目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆