Merge branch '2.7.x' into 3.0.x

Closes gh-35035
pull/35377/head
Andy Wilkinson 2 years ago
commit 284e4d6f6d

@ -19,6 +19,9 @@ tasks.named<BootJar>("bootJar") {
intoLayer("application") intoLayer("application")
} }
dependencies { dependencies {
intoLayer("application") {
includeProjectDependencies()
}
intoLayer("snapshot-dependencies") { intoLayer("snapshot-dependencies") {
include("*:*:*SNAPSHOT") include("*:*:*SNAPSHOT")
} }

@ -175,18 +175,20 @@ public abstract class LayeredSpec {
/** /**
* Base class for specs that control the layers to which a category of content should * Base class for specs that control the layers to which a category of content should
* belong. * belong.
*
* @param <S> the type of {@link IntoLayerSpec} used by this spec
*/ */
public abstract static class IntoLayersSpec implements Serializable { public abstract static class IntoLayersSpec<S extends IntoLayerSpec> implements Serializable {
private final List<IntoLayerSpec> intoLayers; private final List<IntoLayerSpec> intoLayers;
private final Function<String, IntoLayerSpec> specFactory; private final Function<String, S> specFactory;
boolean isEmpty() { boolean isEmpty() {
return this.intoLayers.isEmpty(); return this.intoLayers.isEmpty();
} }
IntoLayersSpec(Function<String, IntoLayerSpec> specFactory, IntoLayerSpec... spec) { IntoLayersSpec(Function<String, S> specFactory, IntoLayerSpec... spec) {
this.intoLayers = new ArrayList<>(Arrays.asList(spec)); this.intoLayers = new ArrayList<>(Arrays.asList(spec));
this.specFactory = specFactory; this.specFactory = specFactory;
} }
@ -195,8 +197,8 @@ public abstract class LayeredSpec {
this.intoLayers.add(this.specFactory.apply(layer)); this.intoLayers.add(this.specFactory.apply(layer));
} }
public void intoLayer(String layer, Action<IntoLayerSpec> action) { public void intoLayer(String layer, Action<S> action) {
IntoLayerSpec spec = this.specFactory.apply(layer); S spec = this.specFactory.apply(layer);
action.execute(spec); action.execute(spec);
this.intoLayers.add(spec); this.intoLayers.add(spec);
} }
@ -330,7 +332,7 @@ public abstract class LayeredSpec {
* An {@link IntoLayersSpec} that controls the layers to which application classes and * An {@link IntoLayersSpec} that controls the layers to which application classes and
* resources belong. * resources belong.
*/ */
public static class ApplicationSpec extends IntoLayersSpec { public static class ApplicationSpec extends IntoLayersSpec<IntoLayerSpec> {
@Inject @Inject
public ApplicationSpec() { public ApplicationSpec() {
@ -364,7 +366,7 @@ public abstract class LayeredSpec {
/** /**
* An {@link IntoLayersSpec} that controls the layers to which dependencies belong. * An {@link IntoLayersSpec} that controls the layers to which dependencies belong.
*/ */
public static class DependenciesSpec extends IntoLayersSpec implements Serializable { public static class DependenciesSpec extends IntoLayersSpec<DependenciesIntoLayerSpec> implements Serializable {
@Inject @Inject
public DependenciesSpec() { public DependenciesSpec() {
@ -384,10 +386,11 @@ public abstract class LayeredSpec {
(spec) -> ((DependenciesIntoLayerSpec) spec).asLibrarySelector(LibraryContentFilter::new)); (spec) -> ((DependenciesIntoLayerSpec) spec).asLibrarySelector(LibraryContentFilter::new));
} }
private static final class IntoLayerSpecFactory implements Function<String, IntoLayerSpec>, Serializable { private static final class IntoLayerSpecFactory
implements Function<String, DependenciesIntoLayerSpec>, Serializable {
@Override @Override
public IntoLayerSpec apply(String layer) { public DependenciesIntoLayerSpec apply(String layer) {
return new DependenciesIntoLayerSpec(layer); return new DependenciesIntoLayerSpec(layer);
} }

Loading…
Cancel
Save