简体   繁体   English

这两个Maven资源定义之间有什么区别?

[英]What are the differences between these two Maven resource definitions?

Could somebody explain me the differences between these two resource definitions? 有人可以向我解释这两种资源定义之间的区别吗? Why the jar files are excluded but in the second resource included? 为什么将jar文件排除在外,但在第二个资源中呢? I don't understand these two declarations: 我不明白这两个声明:

 <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <excludes>
                <exclude>**/*.jar</exclude>
                <exclude>myDummyPath/war/l10n/*.*</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
            <includes>
                <include>**/*.jar</include>
            </includes>
        </resource>
 </resources>

The first difference is obviously the paths: 第一个区别显然是路径:

<excludes>
    <exclude>**/*.jar</exclude>
    <exclude>myDummyPath/war/l10n/*.*</exclude>
</excludes>

And: 和:

<includes>
    <include>**/*.jar</include>
</includes>

Obviously the first declaration excludes all .jar files and everything under I10n . 显然,第一个声明排除了所有.jar文件以及I10n下的所有内容。 The second path, on the other, includes only .jar files. 另一方面,第二个路径包含.jar文件。

Next the first declaration enables filtering and the second disables it. 接下来,第一个声明启用过滤,第二个声明禁用过滤。 In maven, filtering (by default) replaces all variable placeholders ${...} with their values - for more information read the documentation . 在maven中,过滤(默认情况下)将所有变量占位符${...}替换为其值-有关更多信息,请阅读文档

So in the first declaration, all resources except .jar files and localisation files, are filtered by maven - substitution in values for placeholders such as ${project.name} . 因此,在第一个声明中,除.jar文件和本地化文件外,所有资源都通过maven替换占位符(例如${project.name}

In the second declaration, all .jar resources are copied over, without filtering. 在第二个声明中,将复制所有.jar资源,而不进行过滤。

Look at the different filtering settings. 查看不同的filtering设置。 The author wants Maven to replace placeholders in some files (maybe config files) but not to break binary jar files. 作者希望Maven替换某些文件(可能是配置文件)中的占位符,但不要破坏二进制jar文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM