Skip to content

Commit 585286e

Browse files
committed
Revert "Resolve errors in layers.xsd" for 2.5
Revert layers.xsd fix to reduce risk of a regression since it has not yet made it into a 2.5 release. This reverts commit f185b07, reversing changes made to bf3c6df. See gh-31126
1 parent 9af1937 commit 585286e

File tree

7 files changed

+18
-63
lines changed

7 files changed

+18
-63
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,22 @@ dependencies {
6464
versionProperties(project(path: ":spring-boot-project:spring-boot-dependencies", configuration: "effectiveBom"))
6565
}
6666

67-
ext {
68-
versionElements = version.split("\\.")
69-
xsdVersion = versionElements[0] + "." + versionElements[1]
70-
}
71-
7267
syncDocumentationSourceForAsciidoctor {
7368
from(documentPluginGoals) {
7469
into "asciidoc/goals"
7570
}
7671
}
7772

7873
sourceSets {
79-
main {
80-
output.dir("${buildDir}/generated/resources/xsd", builtBy: "xsdResources")
81-
}
8274
intTest {
8375
output.dir("${buildDir}/generated-resources", builtBy: "extractVersionProperties")
8476
}
8577
}
8678

8779
tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
8880
doFirst {
89-
attributes "spring-boot-xsd-version" : project.ext.xsdVersion
81+
def versionEl = version.split("\\.")
82+
attributes "spring-boot-xsd-version": versionEl[0] + '.' + versionEl[1]
9083
}
9184
}
9285

@@ -136,12 +129,6 @@ task zip(type: Zip) {
136129
}
137130
}
138131

139-
task xsdResources(type: Sync) {
140-
from "src/main/xsd/layers-${project.ext.xsdVersion}.xsd"
141-
into "${buildDir}/generated/resources/xsd/org/springframework/boot/maven"
142-
rename { fileName -> "layers.xsd" }
143-
}
144-
145132
prepareMavenBinaries {
146133
versions "3.8.1", "3.6.3", "3.5.4"
147134
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -171,7 +171,6 @@ private CustomLayers getCustomLayers(File configuration) {
171171
private Document getDocumentIfAvailable(File xmlFile) throws Exception {
172172
InputSource inputSource = new InputSource(new FileInputStream(xmlFile));
173173
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
174-
factory.setNamespaceAware(true);
175174
DocumentBuilder builder = factory.newDocumentBuilder();
176175
return builder.parse(inputSource);
177176
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CustomLayersProvider.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,24 +16,16 @@
1616

1717
package org.springframework.boot.maven;
1818

19-
import java.io.IOException;
2019
import java.util.ArrayList;
2120
import java.util.Collections;
2221
import java.util.List;
2322
import java.util.function.Function;
2423
import java.util.stream.Collectors;
2524

26-
import javax.xml.XMLConstants;
27-
import javax.xml.transform.dom.DOMSource;
28-
import javax.xml.validation.Schema;
29-
import javax.xml.validation.SchemaFactory;
30-
import javax.xml.validation.Validator;
31-
3225
import org.w3c.dom.Document;
3326
import org.w3c.dom.Element;
3427
import org.w3c.dom.Node;
3528
import org.w3c.dom.NodeList;
36-
import org.xml.sax.SAXException;
3729

3830
import org.springframework.boot.loader.tools.Layer;
3931
import org.springframework.boot.loader.tools.Library;
@@ -53,35 +45,13 @@
5345
class CustomLayersProvider {
5446

5547
CustomLayers getLayers(Document document) {
56-
validate(document);
5748
Element root = document.getDocumentElement();
5849
List<ContentSelector<String>> applicationSelectors = getApplicationSelectors(root);
5950
List<ContentSelector<Library>> librarySelectors = getLibrarySelectors(root);
6051
List<Layer> layers = getLayers(root);
6152
return new CustomLayers(layers, applicationSelectors, librarySelectors);
6253
}
6354

64-
private void validate(Document document) {
65-
Schema schema = loadSchema();
66-
try {
67-
Validator validator = schema.newValidator();
68-
validator.validate(new DOMSource(document));
69-
}
70-
catch (SAXException | IOException ex) {
71-
throw new IllegalStateException("Invalid layers.xml configuration", ex);
72-
}
73-
}
74-
75-
private Schema loadSchema() {
76-
try {
77-
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
78-
return factory.newSchema(getClass().getResource("layers.xsd"));
79-
}
80-
catch (SAXException ex) {
81-
throw new IllegalStateException("Unable to load layers XSD");
82-
}
83-
}
84-
8555
private List<ContentSelector<String>> getApplicationSelectors(Element root) {
8656
return getSelectors(root, "application", (element) -> getSelector(element, ApplicationContentFilter::new));
8757
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.3.xsd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<xsd:element name="layers" type="layersType" />
77
<xsd:complexType name="layersType">
88
<xsd:sequence>
9-
<xsd:element name="application" type="applicationType" minOccurs="0"/>
10-
<xsd:element name="dependencies" type="dependenciesType" minOccurs="0"/>
11-
<xsd:element name="layerOrder" type="layerOrderType" minOccurs="0"/>
9+
<xsd:element name="application" type="applicationType" />
10+
<xsd:element name="dependencies" type="dependenciesType" />
11+
<xsd:element name="layerOrder" type="layerOrderType" />
1212
</xsd:sequence>
1313
</xsd:complexType>
1414
<xsd:complexType name="applicationType">

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.4.xsd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<xsd:element name="layers" type="layersType" />
77
<xsd:complexType name="layersType">
88
<xsd:sequence>
9-
<xsd:element name="application" type="applicationType" minOccurs="0"/>
10-
<xsd:element name="dependencies" type="dependenciesType" minOccurs="0"/>
11-
<xsd:element name="layerOrder" type="layerOrderType" minOccurs="0"/>
9+
<xsd:element name="application" type="applicationType" />
10+
<xsd:element name="dependencies" type="dependenciesType" />
11+
<xsd:element name="layerOrder" type="layerOrderType" />
1212
</xsd:sequence>
1313
</xsd:complexType>
1414
<xsd:complexType name="applicationType">
@@ -78,14 +78,14 @@
7878
<xsd:complexContent>
7979
<xsd:extension base="intoType">
8080
<xsd:choice minOccurs="0">
81-
<xsd:element type="xsd:string" name="includeModuleDependencies" minOccurs="0">
81+
<xsd:element type="xsd:string" name="includeProjectDependencies" minOccurs="0">
8282
<xsd:annotation>
8383
<xsd:documentation><![CDATA[
8484
Include dependencies on other modules in the build.
8585
]]></xsd:documentation>
8686
</xsd:annotation>
8787
</xsd:element>
88-
<xsd:element type="xsd:string" name="excludeModuleDependencies" minOccurs="0">
88+
<xsd:element type="xsd:string" name="excludeProjectDependencies" minOccurs="0">
8989
<xsd:annotation>
9090
<xsd:documentation><![CDATA[
9191
Exclude dependencies on other modules in the build.

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/xsd/layers-2.5.xsd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<xsd:element name="layers" type="layersType" />
77
<xsd:complexType name="layersType">
88
<xsd:sequence>
9-
<xsd:element name="application" type="applicationType" minOccurs="0"/>
10-
<xsd:element name="dependencies" type="dependenciesType" minOccurs="0"/>
11-
<xsd:element name="layerOrder" type="layerOrderType" minOccurs="0"/>
9+
<xsd:element name="application" type="applicationType" />
10+
<xsd:element name="dependencies" type="dependenciesType" />
11+
<xsd:element name="layerOrder" type="layerOrderType" />
1212
</xsd:sequence>
1313
</xsd:complexType>
1414
<xsd:complexType name="applicationType">
@@ -78,14 +78,14 @@
7878
<xsd:complexContent>
7979
<xsd:extension base="intoType">
8080
<xsd:choice minOccurs="0">
81-
<xsd:element type="xsd:string" name="includeModuleDependencies" minOccurs="0">
81+
<xsd:element type="xsd:string" name="includeProjectDependencies" minOccurs="0">
8282
<xsd:annotation>
8383
<xsd:documentation><![CDATA[
8484
Include dependencies on other modules in the build.
8585
]]></xsd:documentation>
8686
</xsd:annotation>
8787
</xsd:element>
88-
<xsd:element type="xsd:string" name="excludeModuleDependencies" minOccurs="0">
88+
<xsd:element type="xsd:string" name="excludeProjectDependencies" minOccurs="0">
8989
<xsd:annotation>
9090
<xsd:documentation><![CDATA[
9191
Exclude dependencies on other modules in the build.

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/CustomLayersProviderTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -97,7 +97,6 @@ private Document getDocument(String resourceName) throws Exception {
9797
ClassPathResource resource = new ClassPathResource(resourceName);
9898
InputSource inputSource = new InputSource(resource.getInputStream());
9999
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
100-
factory.setNamespaceAware(true);
101100
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
102101
return documentBuilder.parse(inputSource);
103102
}

0 commit comments

Comments
 (0)