Commit 2d769e76 authored by Andy Wilkinson's avatar Andy Wilkinson

Polish "Stop limiting layer customization to external modules"

See gh-21207
parent 98644df6
...@@ -28,9 +28,6 @@ import org.gradle.api.artifacts.Configuration; ...@@ -28,9 +28,6 @@ import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ModuleVersionIdentifier; import org.gradle.api.artifacts.ModuleVersionIdentifier;
import org.gradle.api.artifacts.ResolvedArtifact; import org.gradle.api.artifacts.ResolvedArtifact;
import org.gradle.api.artifacts.ResolvedConfiguration; import org.gradle.api.artifacts.ResolvedConfiguration;
import org.gradle.api.artifacts.component.ComponentIdentifier;
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
import org.gradle.api.artifacts.component.ProjectComponentIdentifier;
import org.gradle.api.file.FileCopyDetails; import org.gradle.api.file.FileCopyDetails;
import org.gradle.api.specs.Spec; import org.gradle.api.specs.Spec;
...@@ -137,16 +134,9 @@ class LayerResolver { ...@@ -137,16 +134,9 @@ class LayerResolver {
private final Map<File, LibraryCoordinates> artifactCoordinates = new LinkedHashMap<>(); private final Map<File, LibraryCoordinates> artifactCoordinates = new LinkedHashMap<>();
ResolvedConfigurationDependencies(ResolvedConfiguration resolvedConfiguration) { ResolvedConfigurationDependencies(ResolvedConfiguration resolvedConfiguration) {
if (resolvedConfiguration != null) { for (ResolvedArtifact resolvedArtifact : resolvedConfiguration.getResolvedArtifacts()) {
for (ResolvedArtifact resolvedArtifact : resolvedConfiguration.getResolvedArtifacts()) { this.artifactCoordinates.put(resolvedArtifact.getFile(),
ComponentIdentifier identifier = resolvedArtifact.getId().getComponentIdentifier(); new ModuleVersionIdentifierLibraryCoordinates(resolvedArtifact.getModuleVersion().getId()));
if (identifier instanceof ModuleComponentIdentifier
|| identifier instanceof ProjectComponentIdentifier) {
this.artifactCoordinates.put(resolvedArtifact.getFile(),
new ModuleVersionIdentifierLibraryCoordinates(
resolvedArtifact.getModuleVersion().getId()));
}
}
} }
} }
......
...@@ -178,7 +178,7 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests { ...@@ -178,7 +178,7 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
} }
@TestTemplate @TestTemplate
void projectDependenciesCanBeIncludedInCustomLayer() throws IOException { void multiModuleCustomLayers() throws IOException {
writeSettingsGradle(); writeSettingsGradle();
writeMainClass(); writeMainClass();
writeResource(); writeResource();
...@@ -188,8 +188,8 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests { ...@@ -188,8 +188,8 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
String layerToolsJar = "BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName(); String layerToolsJar = "BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName();
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) { try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
assertThat(jarFile.getEntry(layerToolsJar)).isNotNull(); assertThat(jarFile.getEntry(layerToolsJar)).isNotNull();
assertThat(jarFile.getEntry("BOOT-INF/lib/foo-1.2.3.jar")).isNotNull(); assertThat(jarFile.getEntry("BOOT-INF/lib/alpha-1.2.3.jar")).isNotNull();
assertThat(jarFile.getEntry("BOOT-INF/lib/bar-1.2.3.jar")).isNotNull(); assertThat(jarFile.getEntry("BOOT-INF/lib/bravo-1.2.3.jar")).isNotNull();
assertThat(jarFile.getEntry("BOOT-INF/lib/commons-lang3-3.9.jar")).isNotNull(); assertThat(jarFile.getEntry("BOOT-INF/lib/commons-lang3-3.9.jar")).isNotNull();
assertThat(jarFile.getEntry("BOOT-INF/lib/spring-core-5.2.5.RELEASE.jar")).isNotNull(); assertThat(jarFile.getEntry("BOOT-INF/lib/spring-core-5.2.5.RELEASE.jar")).isNotNull();
assertThat(jarFile.getEntry("BOOT-INF/lib/spring-jcl-5.2.5.RELEASE.jar")).isNotNull(); assertThat(jarFile.getEntry("BOOT-INF/lib/spring-jcl-5.2.5.RELEASE.jar")).isNotNull();
...@@ -203,8 +203,8 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests { ...@@ -203,8 +203,8 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
"subproject-dependencies", "static", "app"); "subproject-dependencies", "static", "app");
assertThat(indexedLayers.keySet()).containsExactlyElementsOf(layerNames); assertThat(indexedLayers.keySet()).containsExactlyElementsOf(layerNames);
Set<String> expectedSubprojectDependencies = new TreeSet<>(); Set<String> expectedSubprojectDependencies = new TreeSet<>();
expectedSubprojectDependencies.add("BOOT-INF/lib/foo-1.2.3.jar"); expectedSubprojectDependencies.add("BOOT-INF/lib/alpha-1.2.3.jar");
expectedSubprojectDependencies.add("BOOT-INF/lib/bar-1.2.3.jar"); expectedSubprojectDependencies.add("BOOT-INF/lib/bravo-1.2.3.jar");
Set<String> expectedDependencies = new TreeSet<>(); Set<String> expectedDependencies = new TreeSet<>();
expectedDependencies.add("BOOT-INF/lib/spring-core-5.2.5.RELEASE.jar"); expectedDependencies.add("BOOT-INF/lib/spring-core-5.2.5.RELEASE.jar");
expectedDependencies.add("BOOT-INF/lib/spring-jcl-5.2.5.RELEASE.jar"); expectedDependencies.add("BOOT-INF/lib/spring-jcl-5.2.5.RELEASE.jar");
...@@ -261,9 +261,9 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests { ...@@ -261,9 +261,9 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
} }
private void writeSettingsGradle() { private void writeSettingsGradle() {
File settings = new File(this.gradleBuild.getProjectDir(), "settings.gradle"); try (PrintWriter writer = new PrintWriter(
try (PrintWriter writer = new PrintWriter(new FileWriter(settings))) { new FileWriter(new File(this.gradleBuild.getProjectDir(), "settings.gradle")))) {
writer.println("include 'foo', 'bar'"); writer.println("include 'alpha', 'bravo'");
} }
catch (IOException ex) { catch (IOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
......
...@@ -40,8 +40,8 @@ repositories { ...@@ -40,8 +40,8 @@ repositories {
} }
dependencies { dependencies {
implementation(project(':foo')) implementation(project(':alpha'))
implementation(project(':bar')) implementation(project(':bravo'))
implementation("commons-io:commons-io:2.7-SNAPSHOT") implementation("commons-io:commons-io:2.7-SNAPSHOT")
implementation("org.apache.commons:commons-lang3:3.9") implementation("org.apache.commons:commons-lang3:3.9")
implementation("org.springframework:spring-core:5.2.5.RELEASE") implementation("org.springframework:spring-core:5.2.5.RELEASE")
......
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