I found some inconsistencies between maven plugin documentation and code, which one should I use?
The contents of the document are as follows
<layers xmlns="http://www.springframework.org/schema/boot/layers"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/boot/layers
https://www.springframework.org/schema/boot/layers/layers-2.6.xsd">
<application>
<into layer="spring-boot-loader">
<include>org/springframework/boot/loader/**</include>
</into>
<into layer="application" />
</application>
<dependencies>
<into layer="application">
<includeModuleDependencies />
</into>
<into layer="snapshot-dependencies">
<include>*:*:*SNAPSHOT</include>
</into>
<into layer="dependencies" />
</dependencies>
<layerOrder>
<layer>dependencies</layer>
<layer>spring-boot-loader</layer>
<layer>snapshot-dependencies</layer>
<layer>application</layer>
</layerOrder>
</layers>
It also provides
<includeModuleDependencies />and<excludeModuleDependencies />elements that can be used to include or exclude local module dependencies.
Code
layers-2.6.xsd
<xsd:complexType name="dependenciesIntoType">
<xsd:complexContent>
<xsd:extension base="intoType">
<xsd:choice minOccurs="0">
<xsd:element type="xsd:string" name="includeProjectDependencies" minOccurs="0">
<xsd:annotation>
<xsd:documentation><![CDATA[
Include dependencies on other modules in the build.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element type="xsd:string" name="excludeProjectDependencies" minOccurs="0">
<xsd:annotation>
<xsd:documentation><![CDATA[
Exclude dependencies on other modules in the build.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Here is includeProjectDependencies and excludeProjectDependencies.
CustomLayersProvider.java
private <T> ContentSelector<Library> getLibrarySelector(Element element,
Function<String, ContentFilter<Library>> filterFactory) {
Layer layer = new Layer(element.getAttribute("layer"));
List<String> includes = getChildNodeTextContent(element, "include");
List<String> excludes = getChildNodeTextContent(element, "exclude");
Element includeModuleDependencies = getChildElement(element, "includeModuleDependencies");
Element excludeModuleDependencies = getChildElement(element, "excludeModuleDependencies");
List<ContentFilter<Library>> includeFilters = includes.stream().map(filterFactory).collect(Collectors.toList());
if (includeModuleDependencies != null) {
includeFilters = new ArrayList<>(includeFilters);
includeFilters.add(Library::isLocal);
}
List<ContentFilter<Library>> excludeFilters = excludes.stream().map(filterFactory).collect(Collectors.toList());
if (excludeModuleDependencies != null) {
excludeFilters = new ArrayList<>(excludeFilters);
excludeFilters.add(Library::isLocal);
}
return new IncludeExcludeContentSelector<>(layer, includeFilters, excludeFilters);
}
Here is includeModuleDependencies and excludeModuleDependencies.
Comment From: philwebb
Thanks very much @abel533 for your first Spring Boot contribution. I've applied this fix along with the @wilkinsona's suggestion of validating the XML files when it's loaded.
Comment From: wilkinsona
I wonder if we should validate against the version of the XSD declared in the XML file rather than always using the XSD that matches the version of the Maven plugin?
Comment From: wilkinsona
I've just noticed that this was merged into 2.5.x. Was that intentional, @philwebb?
Comment From: philwebb
I've just noticed that this was merged into 2.5.x. Was that intentional, @philwebb?
No! I obviously have too many IDEs open and got confused. I'll move this one and we can use the forward-merge issue (#31127) for 2.6.