Skip to content

Commit 2d769e7

Browse files
committed
Polish "Stop limiting layer customization to external modules"
See gh-21207
1 parent 98644df commit 2d769e7

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayerResolver.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
import org.gradle.api.artifacts.ModuleVersionIdentifier;
2929
import org.gradle.api.artifacts.ResolvedArtifact;
3030
import org.gradle.api.artifacts.ResolvedConfiguration;
31-
import org.gradle.api.artifacts.component.ComponentIdentifier;
32-
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
33-
import org.gradle.api.artifacts.component.ProjectComponentIdentifier;
3431
import org.gradle.api.file.FileCopyDetails;
3532
import org.gradle.api.specs.Spec;
3633

@@ -137,16 +134,9 @@ private static class ResolvedConfigurationDependencies {
137134
private final Map<File, LibraryCoordinates> artifactCoordinates = new LinkedHashMap<>();
138135

139136
ResolvedConfigurationDependencies(ResolvedConfiguration resolvedConfiguration) {
140-
if (resolvedConfiguration != null) {
141-
for (ResolvedArtifact resolvedArtifact : resolvedConfiguration.getResolvedArtifacts()) {
142-
ComponentIdentifier identifier = resolvedArtifact.getId().getComponentIdentifier();
143-
if (identifier instanceof ModuleComponentIdentifier
144-
|| identifier instanceof ProjectComponentIdentifier) {
145-
this.artifactCoordinates.put(resolvedArtifact.getFile(),
146-
new ModuleVersionIdentifierLibraryCoordinates(
147-
resolvedArtifact.getModuleVersion().getId()));
148-
}
149-
}
137+
for (ResolvedArtifact resolvedArtifact : resolvedConfiguration.getResolvedArtifacts()) {
138+
this.artifactCoordinates.put(resolvedArtifact.getFile(),
139+
new ModuleVersionIdentifierLibraryCoordinates(resolvedArtifact.getModuleVersion().getId()));
150140
}
151141
}
152142

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarIntegrationTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void customLayers() throws IOException {
178178
}
179179

180180
@TestTemplate
181-
void projectDependenciesCanBeIncludedInCustomLayer() throws IOException {
181+
void multiModuleCustomLayers() throws IOException {
182182
writeSettingsGradle();
183183
writeMainClass();
184184
writeResource();
@@ -188,8 +188,8 @@ void projectDependenciesCanBeIncludedInCustomLayer() throws IOException {
188188
String layerToolsJar = "BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName();
189189
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
190190
assertThat(jarFile.getEntry(layerToolsJar)).isNotNull();
191-
assertThat(jarFile.getEntry("BOOT-INF/lib/foo-1.2.3.jar")).isNotNull();
192-
assertThat(jarFile.getEntry("BOOT-INF/lib/bar-1.2.3.jar")).isNotNull();
191+
assertThat(jarFile.getEntry("BOOT-INF/lib/alpha-1.2.3.jar")).isNotNull();
192+
assertThat(jarFile.getEntry("BOOT-INF/lib/bravo-1.2.3.jar")).isNotNull();
193193
assertThat(jarFile.getEntry("BOOT-INF/lib/commons-lang3-3.9.jar")).isNotNull();
194194
assertThat(jarFile.getEntry("BOOT-INF/lib/spring-core-5.2.5.RELEASE.jar")).isNotNull();
195195
assertThat(jarFile.getEntry("BOOT-INF/lib/spring-jcl-5.2.5.RELEASE.jar")).isNotNull();
@@ -203,8 +203,8 @@ void projectDependenciesCanBeIncludedInCustomLayer() throws IOException {
203203
"subproject-dependencies", "static", "app");
204204
assertThat(indexedLayers.keySet()).containsExactlyElementsOf(layerNames);
205205
Set<String> expectedSubprojectDependencies = new TreeSet<>();
206-
expectedSubprojectDependencies.add("BOOT-INF/lib/foo-1.2.3.jar");
207-
expectedSubprojectDependencies.add("BOOT-INF/lib/bar-1.2.3.jar");
206+
expectedSubprojectDependencies.add("BOOT-INF/lib/alpha-1.2.3.jar");
207+
expectedSubprojectDependencies.add("BOOT-INF/lib/bravo-1.2.3.jar");
208208
Set<String> expectedDependencies = new TreeSet<>();
209209
expectedDependencies.add("BOOT-INF/lib/spring-core-5.2.5.RELEASE.jar");
210210
expectedDependencies.add("BOOT-INF/lib/spring-jcl-5.2.5.RELEASE.jar");
@@ -261,9 +261,9 @@ private boolean isInIndex(List<String> index, String file) {
261261
}
262262

263263
private void writeSettingsGradle() {
264-
File settings = new File(this.gradleBuild.getProjectDir(), "settings.gradle");
265-
try (PrintWriter writer = new PrintWriter(new FileWriter(settings))) {
266-
writer.println("include 'foo', 'bar'");
264+
try (PrintWriter writer = new PrintWriter(
265+
new FileWriter(new File(this.gradleBuild.getProjectDir(), "settings.gradle")))) {
266+
writer.println("include 'alpha', 'bravo'");
267267
}
268268
catch (IOException ex) {
269269
throw new RuntimeException(ex);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ repositories {
4040
}
4141

4242
dependencies {
43-
implementation(project(':foo'))
44-
implementation(project(':bar'))
43+
implementation(project(':alpha'))
44+
implementation(project(':bravo'))
4545
implementation("commons-io:commons-io:2.7-SNAPSHOT")
4646
implementation("org.apache.commons:commons-lang3:3.9")
4747
implementation("org.springframework:spring-core:5.2.5.RELEASE")

0 commit comments

Comments
 (0)