Assembly descriptor: Unpack-include exclusively?

匆匆过客 提交于 2019-12-24 16:07:47

问题


Description

While working through a large multi-module project I discovered a custom Assembly Descriptor file. What I don't fully understand is the following, especially the includes section.

<assembly [...]>
    [...]
    <dependencySets>
        <dependencySet>
            <scope>provided</scope>
            <unpack>true</unpack>
            <unpackOptions>
                <includes>
                    <include>defaults*.properties</include>
                </includes>
            </unpackOptions>
            <outputFileNameMapping>
                ${artifact.artifactId}
            </outputFileNameMapping>
            <includes>
                <include>${project.groupId}:[project]-settings</include>
            </includes>
        </dependencySet>
    </dependencySets>
    [...]
</assembly>

The assembly documentation describes the include section as a "file and/or directory pattern for matching items to be included from an archive as it is unpacked".

The includes property documentation of dependencySet states the following:

If none is present, then represents all valid values.

Question

Does include work exclusively? Can I therefore expect only the defaults*.properties to be regarded as provided (according to this particular section)?

How do unpackOptions-includes interfer with the basic includes (last section of dependencySet)?


回答1:


How do unpackOptions-includes interfer with the basic includes (last section of dependencySet)?

They control two very different things and do not interfere together:

  • Includes in unpackOptions control which files inside the artifact are to be unpacked. In your example, it means that, in every dependency that has the scope provided, only the files matching the pattern defaults*.properties will be unpacked and therefore kept.
  • Includes in dependencySet control which artifacts are to be included in this set. In your example, only the artifacts matching ${project.groupId}:[project]-settings will be included in this set.

Finally, the assembly descriptor you have will consider every provided dependency, whose name match ${project.groupId}:[project]-settings. In each of those artifacts, it will unpack all the files matching the pattern defaults*.properties.

Does include work exclusively?

Yes. By default, everything is included. If you override that configuration, what will be included is what you configured in this tag. Similarly, by default, nothing is excluded (and if you override that configuration, note that the exclusions rules apply on what whas previously included).



来源:https://stackoverflow.com/questions/33165755/assembly-descriptor-unpack-include-exclusively

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!