Home / Function/ customLayers() — spring-boot Function Reference

customLayers() — spring-boot Function Reference

Architecture documentation for the customLayers() function in AbstractBootArchiveIntegrationTests.java from the spring-boot codebase.

Entity Profile

Dependency Diagram

graph TD
  65ec8caa_353b_1f02_52f6_cd4484a86a76["customLayers()"]
  c1d87296_7b81_712e_cfb5_8a0a1fef6968["writeMainClass()"]
  65ec8caa_353b_1f02_52f6_cd4484a86a76 -->|calls| c1d87296_7b81_712e_cfb5_8a0a1fef6968
  2537bd26_f68f_0773_f0ef_19e3a06ef3b7["writeResource()"]
  65ec8caa_353b_1f02_52f6_cd4484a86a76 -->|calls| 2537bd26_f68f_0773_f0ef_19e3a06ef3b7
  4411a1be_530d_c0d4_e4d4_669711600b98["readLayerIndex()"]
  65ec8caa_353b_1f02_52f6_cd4484a86a76 -->|calls| 4411a1be_530d_c0d4_e4d4_669711600b98
  c312f8db_dbba_3214_8e81_013a94f3f3ca["getExpectedApplicationLayerContents()"]
  65ec8caa_353b_1f02_52f6_cd4484a86a76 -->|calls| c312f8db_dbba_3214_8e81_013a94f3f3ca
  f135ea13_1496_d12c_baa5_7d8c5094e579["assertExtractedLayers()"]
  65ec8caa_353b_1f02_52f6_cd4484a86a76 -->|calls| f135ea13_1496_d12c_baa5_7d8c5094e579
  style 65ec8caa_353b_1f02_52f6_cd4484a86a76 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

build-plugin/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java lines 436–486

	@TestTemplate
	void customLayers() throws IOException {
		writeMainClass();
		writeResource();
		BuildResult build = this.gradleBuild.build(this.taskName);
		BuildTask task = build.task(":" + this.taskName);
		assertThat(task).isNotNull();
		assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
		Map<String, List<String>> indexedLayers;
		String toolsJar = this.libPath + JarModeLibrary.TOOLS.getName();
		try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
			assertThat(jarFile.getEntry(toolsJar)).isNotNull();
			assertThat(jarFile.getEntry(this.libPath + "commons-lang3-3.9.jar")).isNotNull();
			assertThat(jarFile.getEntry(this.libPath + "spring-core-5.2.5.RELEASE.jar")).isNotNull();
			assertThat(jarFile.getEntry(this.libPath + "spring-jcl-5.2.5.RELEASE.jar")).isNotNull();
			assertThat(jarFile.getEntry(this.libPath + "library-1.0-SNAPSHOT.jar")).isNotNull();
			assertThat(jarFile.getEntry(this.classesPath + "example/Main.class")).isNotNull();
			assertThat(jarFile.getEntry(this.classesPath + "static/file.txt")).isNotNull();
			assertThat(jarFile.getEntry(this.indexPath + "layers.idx")).isNotNull();
			indexedLayers = readLayerIndex(jarFile);
		}
		List<String> layerNames = Arrays.asList("dependencies", "commons-dependencies", "snapshot-dependencies",
				"static", "app");
		assertThat(indexedLayers.keySet()).containsExactlyElementsOf(layerNames);
		Set<String> expectedDependencies = new TreeSet<>();
		expectedDependencies.add(this.libPath + "spring-core-5.2.5.RELEASE.jar");
		expectedDependencies.add(this.libPath + "spring-jcl-5.2.5.RELEASE.jar");
		List<String> expectedSnapshotDependencies = new ArrayList<>();
		expectedSnapshotDependencies.add(this.libPath + "library-1.0-SNAPSHOT.jar");
		(toolsJar.contains("SNAPSHOT") ? expectedSnapshotDependencies : expectedDependencies).add(toolsJar);
		assertThat(indexedLayers.get("dependencies")).containsExactlyElementsOf(expectedDependencies);
		assertThat(indexedLayers.get("commons-dependencies")).containsExactly(this.libPath + "commons-lang3-3.9.jar");
		assertThat(indexedLayers.get("snapshot-dependencies")).containsExactlyElementsOf(expectedSnapshotDependencies);
		assertThat(indexedLayers.get("static")).containsExactly(this.classesPath + "static/");
		List<String> appLayer = new ArrayList<>(indexedLayers.get("app"));
		String[] appLayerContents = getExpectedApplicationLayerContents(this.classesPath + "example/");
		assertThat(appLayer).containsSubsequence(appLayerContents);
		appLayer.removeAll(Arrays.asList(appLayerContents));
		assertThat(appLayer).containsExactly("org/");
		BuildResult listLayers = this.gradleBuild.build("listLayers");
		task = listLayers.task(":listLayers");
		assertThat(task).isNotNull();
		assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
		String listLayersOutput = listLayers.getOutput();
		assertThat(new BufferedReader(new StringReader(listLayersOutput)).lines()).containsSequence(layerNames);
		BuildResult extractLayers = this.gradleBuild.build("extractLayers");
		task = extractLayers.task(":extractLayers");
		assertThat(task).isNotNull();
		assertThat(task.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
		assertExtractedLayers(layerNames, indexedLayers);
	}

Domain

Subdomains

Frequently Asked Questions

What does customLayers() do?
customLayers() is a function in the spring-boot codebase.
What does customLayers() call?
customLayers() calls 5 function(s): assertExtractedLayers, getExpectedApplicationLayerContents, readLayerIndex, writeMainClass, writeResource.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free