Commit 952e5297 authored by Madhura Bhave's avatar Madhura Bhave

Rename "classes" to "application" in custom layer configuration

Closes gh-20539
parent 29c89f3c
...@@ -23,7 +23,7 @@ bootJar { ...@@ -23,7 +23,7 @@ bootJar {
} }
} }
} }
classes { application {
layerContent("resources") { layerContent("resources") {
locations { locations {
include "META-INF/resources/**", "resources/**" include "META-INF/resources/**", "resources/**"
......
...@@ -21,7 +21,7 @@ tasks.getByName<BootJar>("bootJar") { ...@@ -21,7 +21,7 @@ tasks.getByName<BootJar>("bootJar") {
} }
} }
} }
classes { application {
layerContent("resources") { layerContent("resources") {
locations { locations {
include("META-INF/resources/**", "resources/**") include("META-INF/resources/**", "resources/**")
......
...@@ -214,7 +214,7 @@ public class BootJar extends Jar implements BootArchive { ...@@ -214,7 +214,7 @@ public class BootJar extends Jar implements BootArchive {
else { else {
List<Layer> customLayers = this.layerConfiguration.getLayersOrder().stream().map(Layer::new) List<Layer> customLayers = this.layerConfiguration.getLayersOrder().stream().map(Layer::new)
.collect(Collectors.toList()); .collect(Collectors.toList());
this.layers = new CustomLayers(customLayers, this.layerConfiguration.getClasses(), this.layers = new CustomLayers(customLayers, this.layerConfiguration.getApplication(),
this.layerConfiguration.getLibraries()); this.layerConfiguration.getLibraries());
} }
......
...@@ -79,16 +79,16 @@ public class LayerConfiguration { ...@@ -79,16 +79,16 @@ public class LayerConfiguration {
} }
@Input @Input
public List<ResourceStrategy> getClasses() { public List<ResourceStrategy> getApplication() {
return this.resourceStrategies; return this.resourceStrategies;
} }
public void classes(ResourceStrategy... resourceStrategies) { public void application(ResourceStrategy... resourceStrategies) {
assertLayersOrderConfigured(); assertLayersOrderConfigured();
this.resourceStrategies = Arrays.asList(resourceStrategies); this.resourceStrategies = Arrays.asList(resourceStrategies);
} }
public void classes(Action<LayerConfiguration> config) { public void application(Action<LayerConfiguration> config) {
assertLayersOrderConfigured(); assertLayersOrderConfigured();
this.strategySpec = StrategySpec.forResources(); this.strategySpec = StrategySpec.forResources();
config.execute(this); config.execute(this);
...@@ -135,7 +135,8 @@ public class LayerConfiguration { ...@@ -135,7 +135,8 @@ public class LayerConfiguration {
} }
public void locations(Action<LayerConfiguration> config) { public void locations(Action<LayerConfiguration> config) {
Assert.state(this.strategySpec.isResourcesStrategy(), "The 'locations' filter must be used only with classes"); Assert.state(this.strategySpec.isResourcesStrategy(),
"The 'locations' filter must be used only with application");
this.strategySpec.newFilter(); this.strategySpec.newFilter();
config.execute(this); config.execute(this);
this.strategySpec this.strategySpec
......
...@@ -126,7 +126,7 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> { ...@@ -126,7 +126,7 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
configuration.libraries(createLibraryStrategy("my-snapshot-deps", "com.example:*:*.SNAPSHOT"), configuration.libraries(createLibraryStrategy("my-snapshot-deps", "com.example:*:*.SNAPSHOT"),
createLibraryStrategy("my-internal-deps", "com.example:*:*"), createLibraryStrategy("my-internal-deps", "com.example:*:*"),
createLibraryStrategy("my-deps", "*:*")); createLibraryStrategy("my-deps", "*:*"));
configuration.classes(createResourceStrategy("resources", "static/**"), configuration.application(createResourceStrategy("resources", "static/**"),
createResourceStrategy("application", "**")); createResourceStrategy("application", "**"));
}); });
List<String> entryNames = getEntryNames(jar); List<String> entryNames = getEntryNames(jar);
......
...@@ -12,7 +12,7 @@ bootJar { ...@@ -12,7 +12,7 @@ bootJar {
layerContent("commons-dependencies") { coordinates { include "org.apache.commons:*" } } layerContent("commons-dependencies") { coordinates { include "org.apache.commons:*" } }
layerContent("dependencies") { coordinates { include "*:*" } } layerContent("dependencies") { coordinates { include "*:*" } }
} }
classes { application {
layerContent("static") { layerContent("static") {
locations { locations {
include "META-INF/resources/**", "resources/**" include "META-INF/resources/**", "resources/**"
......
...@@ -164,7 +164,7 @@ The following example shows what the implicit layer configuration described abov ...@@ -164,7 +164,7 @@ The following example shows what the implicit layer configuration described abov
</coordinates> </coordinates>
</layer-content> </layer-content>
</libraries> </libraries>
<classes> <application>
<layer-content layer="resources"> <layer-content layer="resources">
<locations> <locations>
<include>META-INF/resources/**</include> <include>META-INF/resources/**</include>
...@@ -178,7 +178,7 @@ The following example shows what the implicit layer configuration described abov ...@@ -178,7 +178,7 @@ The following example shows what the implicit layer configuration described abov
<include>**</include> <include>**</include>
</locations> </locations>
</layer-content> </layer-content>
</classes> </application>
</layers-configuration> </layers-configuration>
---- ----
...@@ -589,9 +589,9 @@ This allows to reuse the cache for external dependencies when an internal depend ...@@ -589,9 +589,9 @@ This allows to reuse the cache for external dependencies when an internal depend
</coordinates> </coordinates>
</layer-content> </layer-content>
</libraries> </libraries>
<classes> <application>
... ...
</classes> </application>
</layers-configuration> </layers-configuration>
---- ----
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</coordinates> </coordinates>
</layer-content> </layer-content>
</libraries> </libraries>
<classes> <application>
<layer-content layer="configuration"> <layer-content layer="configuration">
<locations> <locations>
<include>**/application*.*</include> <include>**/application*.*</include>
...@@ -31,5 +31,5 @@ ...@@ -31,5 +31,5 @@
<include>**</include> <include>**</include>
</locations> </locations>
</layer-content> </layer-content>
</classes> </application>
</layers-configuration> </layers-configuration>
\ No newline at end of file
...@@ -71,7 +71,7 @@ public class CustomLayersProvider { ...@@ -71,7 +71,7 @@ public class CustomLayersProvider {
(StrategyFactory<LibraryFilter, LibraryStrategy>) FilteredLibraryStrategy::new, (StrategyFactory<LibraryFilter, LibraryStrategy>) FilteredLibraryStrategy::new,
CoordinateFilter::new, "coordinates"::equals)); CoordinateFilter::new, "coordinates"::equals));
} }
if ("classes".equals(nodeName)) { if ("application".equals(nodeName)) {
resourceStrategies.addAll(getStrategies(contents, resourceStrategies.addAll(getStrategies(contents,
(StrategyFactory<ResourceFilter, ResourceStrategy>) FilteredResourceStrategy::new, (StrategyFactory<ResourceFilter, ResourceStrategy>) FilteredResourceStrategy::new,
LocationFilter::new, "locations"::equals)); LocationFilter::new, "locations"::equals));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<xsd:sequence> <xsd:sequence>
<xsd:element type="layersType" name="layers"/> <xsd:element type="layersType" name="layers"/>
<xsd:element type="librariesType" name="libraries" minOccurs="0"/> <xsd:element type="librariesType" name="libraries" minOccurs="0"/>
<xsd:element type="classesType" name="classes" minOccurs="0"/> <xsd:element type="applicationType" name="application" minOccurs="0"/>
</xsd:sequence> </xsd:sequence>
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="layersType"> <xsd:complexType name="layersType">
...@@ -48,25 +48,25 @@ ...@@ -48,25 +48,25 @@
</xsd:sequence> </xsd:sequence>
<xsd:attribute type="xsd:string" name="layer" use="required"/> <xsd:attribute type="xsd:string" name="layer" use="required"/>
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="classesType"> <xsd:complexType name="applicationType">
<xsd:annotation> <xsd:annotation>
<xsd:documentation><![CDATA[ <xsd:documentation><![CDATA[
Strategies that should be applied to classes. If no strategies are defined, a single Strategies that should be applied to application classes and resources. If no strategies are defined, a single
"application" layer is created out-of-the-box. "application" layer is created out-of-the-box.
]]></xsd:documentation> ]]></xsd:documentation>
</xsd:annotation> </xsd:annotation>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element type="classesLayerContentType" name="layer-content" maxOccurs="unbounded" <xsd:element type="applicationLayerContentType" name="layer-content" maxOccurs="unbounded"
minOccurs="0"> minOccurs="0">
<xsd:annotation> <xsd:annotation>
<xsd:documentation><![CDATA[ <xsd:documentation><![CDATA[
Strategy to apply on classes. Strategy to apply on application classes and resources.
]]></xsd:documentation> ]]></xsd:documentation>
</xsd:annotation> </xsd:annotation>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="classesLayerContentType" mixed="true"> <xsd:complexType name="applicationLayerContentType" mixed="true">
<xsd:sequence> <xsd:sequence>
<xsd:element type="filterType" name="locations" minOccurs="0"/> <xsd:element type="filterType" name="locations" minOccurs="0"/>
</xsd:sequence> </xsd:sequence>
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</coordinates> </coordinates>
</layer-content> </layer-content>
</libraries> </libraries>
<classes> <application>
<layer-content layer="my-resources"> <layer-content layer="my-resources">
<locations> <locations>
<include>META-INF/resources/**</include> <include>META-INF/resources/**</include>
...@@ -43,5 +43,5 @@ ...@@ -43,5 +43,5 @@
<include>**</include> <include>**</include>
</locations> </locations>
</layer-content> </layer-content>
</classes> </application>
</layers-configuration> </layers-configuration>
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<layers> <layers>
<layer>my-layer</layer> <layer>my-layer</layer>
</layers> </layers>
<classes> <application>
<layer-content layer="my-layer"/> <layer-content layer="my-layer"/>
</classes> </application>
</layers-configuration> </layers-configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment