Chr*_*ams 8 xml maven-2 pom.xml
我有一个现有的pom文件,其中包含一个maven-jar-plugin部分.它运行test-jar目标,目前不包括几个目录:
<excludes>
<exclude>...</exclude>
<exclude>...</exclude>
<exclude>somedir/**</exclude>
</excludes>
Run Code Online (Sandbox Code Playgroud)
我需要在somedir目录中包含一个文件,但遗漏somedir目录中的其余文件.我已经读过,包括优先于排除,所以我添加了类似下面的内容(之前没有包含部分):
<includes>
<include>somedir/somefile.xml</include>
</includes>
Run Code Online (Sandbox Code Playgroud)
这最终创建了一个用于测试的jar文件,其中只有几个文件(只是META-INF中的东西).我包含的文件也不在jar中.我期望的是一个jar,它与我在包含一个额外文件的更改之前创建的jar相同.
我在这里错过了什么?
Pas*_*ent 11
首先,如果你没有指定任何includes,那么maven jar插件将**/**用作默认模式(参见o.a.m.p.j.AbstractJarMojo),即它将包含所有内容.如果您覆盖此默认模式,插件显然只包含您告诉他包含的内容.
其次,目录扫描最后由完成o.c.p.u.DirectoryScanner,这就是该类的javadoc所说的:
* The idea is simple. A given directory is recursively scanned for all files * and directories. Each file/directory is matched against a set of selectors, * including special support for matching against filenames with include and * and exclude patterns. Only files/directories which match at least one * pattern of the include pattern list or other file selector, and don't match * any pattern of the exclude pattern list or fail to match against a required * selector will be placed in the list of files/directories found.
因此,使用您当前的一组includes和excludes模式,只有一个文件将匹配包含模式,但也匹配排除模式,因此不会被选中,您将得到一个几乎为空的存档(只有默认清单,请参阅o.a.m.p.j.AbstractJarMojo#createArchive()).
我不能在这里给你确切的解决方案,但你显然需要重新考虑包含/排除文件的方式(例如添加更多includes模式,删除<exclude>somedir/**</exclude>或includes仅使用 ,或excludes仅使用).
| 归档时间: |
|
| 查看次数: |
14030 次 |
| 最近记录: |