Rename spring-boot-loader to spring-boot-loader-classic

Rename the `spring-boot-loader` module to `spring-boot-loader-classic`
so that we can introduce an alternative loader implementation.

See gh-37669
This commit is contained in:
Phillip Webb
2023-09-18 13:41:31 -07:00
parent c22548982a
commit aeb6537f57
105 changed files with 67 additions and 67 deletions

View File

@@ -1,44 +0,0 @@
plugins {
id "java"
id "org.springframework.boot.conventions"
id "org.springframework.boot.integration-test"
}
description = "Spring Boot Loader Integration Tests"
configurations {
app
}
dependencies {
app project(path: ":spring-boot-project:spring-boot-dependencies", configuration: "mavenRepository")
app project(path: ":spring-boot-project:spring-boot-tools:spring-boot-gradle-plugin", configuration: "mavenRepository")
app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-web", configuration: "mavenRepository")
intTestImplementation(enforcedPlatform(project(":spring-boot-project:spring-boot-parent")))
intTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
intTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
intTestImplementation("org.testcontainers:junit-jupiter")
intTestImplementation("org.testcontainers:testcontainers")
}
task syncMavenRepository(type: Sync) {
from configurations.app
into "${buildDir}/int-test-maven-repository"
}
task syncAppSource(type: org.springframework.boot.build.SyncAppSource) {
sourceDirectory = file("spring-boot-loader-tests-app")
destinationDirectory = file("${buildDir}/spring-boot-loader-tests-app")
}
task buildApp(type: GradleBuild) {
dependsOn syncAppSource, syncMavenRepository
dir = "${buildDir}/spring-boot-loader-tests-app"
startParameter.buildCacheEnabled = false
tasks = ["build"]
}
intTest {
dependsOn buildApp
}

View File

@@ -1,18 +0,0 @@
plugins {
id "java"
id "org.springframework.boot"
}
apply plugin: "io.spring.dependency-management"
repositories {
maven { url "file:${rootDir}/../int-test-maven-repository"}
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.webjars:jquery:3.5.0")
}

View File

@@ -1,15 +0,0 @@
pluginManagement {
repositories {
maven { url "file:${rootDir}/../int-test-maven-repository"}
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "org.springframework.boot") {
useModule "org.springframework.boot:spring-boot-gradle-plugin:${requested.version}"
}
}
}
}

View File

@@ -1,59 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.loaderapp;
import java.io.File;
import java.net.JarURLConnection;
import java.net.URL;
import java.util.Arrays;
import jakarta.servlet.ServletContext;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.util.FileCopyUtils;
@SpringBootApplication
public class LoaderTestApplication {
@Bean
public CommandLineRunner commandLineRunner(ServletContext servletContext) {
return (args) -> {
File temp = new File(System.getProperty("java.io.tmpdir"));
URL resourceUrl = servletContext.getResource("webjars/jquery/3.5.0/jquery.js");
JarURLConnection connection = (JarURLConnection) resourceUrl.openConnection();
String jarName = connection.getJarFile().getName();
System.out.println(">>>>> jar file " + jarName);
if(jarName.contains(temp.getAbsolutePath())) {
System.out.println(">>>>> jar written to temp");
}
byte[] resourceContent = FileCopyUtils.copyToByteArray(resourceUrl.openStream());
URL directUrl = new URL(resourceUrl.toExternalForm());
byte[] directContent = FileCopyUtils.copyToByteArray(directUrl.openStream());
String message = (!Arrays.equals(resourceContent, directContent)) ? "NO MATCH"
: directContent.length + " BYTES";
System.out.println(">>>>> " + message + " from " + resourceUrl);
};
}
public static void main(String[] args) {
SpringApplication.run(LoaderTestApplication.class, args).close();
}
}

View File

@@ -1,131 +0,0 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.loader;
import java.io.File;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.ToStringConsumer;
import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy;
import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
import org.springframework.boot.system.JavaVersion;
import org.springframework.boot.testsupport.testcontainers.DisabledIfDockerUnavailable;
import org.springframework.util.Assert;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests loader that supports uber jars.
*
* @author Phillip Webb
* @author Moritz Halbritter
*/
@DisabledIfDockerUnavailable
class LoaderIntegrationTests {
private final ToStringConsumer output = new ToStringConsumer();
@ParameterizedTest
@MethodSource("javaRuntimes")
void readUrlsWithoutWarning(JavaRuntime javaRuntime) {
try (GenericContainer<?> container = createContainer(javaRuntime)) {
container.start();
System.out.println(this.output.toUtf8String());
assertThat(this.output.toUtf8String()).contains(">>>>> 287649 BYTES from")
.doesNotContain("WARNING:")
.doesNotContain("illegal")
.doesNotContain("jar written to temp");
}
}
private GenericContainer<?> createContainer(JavaRuntime javaRuntime) {
return javaRuntime.getContainer()
.withLogConsumer(this.output)
.withCopyFileToContainer(MountableFile.forHostPath(findApplication().toPath()), "/app.jar")
.withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5)))
.withCommand("java", "-jar", "app.jar");
}
private File findApplication() {
String name = String.format("build/%1$s/build/libs/%1$s.jar", "spring-boot-loader-tests-app");
File jar = new File(name);
Assert.state(jar.isFile(), () -> "Could not find " + name + ". Have you built it?");
return jar;
}
static Stream<JavaRuntime> javaRuntimes() {
List<JavaRuntime> javaRuntimes = new ArrayList<>();
javaRuntimes.add(JavaRuntime.openJdk(JavaVersion.SEVENTEEN));
javaRuntimes.add(JavaRuntime.openJdk(JavaVersion.TWENTY_ONE));
javaRuntimes.add(JavaRuntime.oracleJdk17());
return javaRuntimes.stream().filter(JavaRuntime::isCompatible);
}
static final class JavaRuntime {
private final String name;
private final JavaVersion version;
private final Supplier<GenericContainer<?>> container;
private JavaRuntime(String name, JavaVersion version, Supplier<GenericContainer<?>> container) {
this.name = name;
this.version = version;
this.container = container;
}
private boolean isCompatible() {
return this.version.isEqualOrNewerThan(JavaVersion.getJavaVersion());
}
GenericContainer<?> getContainer() {
return this.container.get();
}
@Override
public String toString() {
return this.name;
}
static JavaRuntime openJdk(JavaVersion version) {
String imageVersion = version.toString();
DockerImageName image = DockerImageName.parse("bellsoft/liberica-openjdk-debian:" + imageVersion);
return new JavaRuntime("OpenJDK " + imageVersion, version, () -> new GenericContainer<>(image));
}
static JavaRuntime oracleJdk17() {
String arch = System.getProperty("os.arch");
String dockerFile = ("aarch64".equals(arch)) ? "Dockerfile-aarch64" : "Dockerfile";
ImageFromDockerfile image = new ImageFromDockerfile("spring-boot-loader/oracle-jdk-17")
.withFileFromFile("Dockerfile", new File("src/intTest/resources/conf/oracle-jdk-17/" + dockerFile));
return new JavaRuntime("Oracle JDK 17", JavaVersion.SEVENTEEN, () -> new GenericContainer<>(image));
}
}
}

View File

@@ -1,8 +0,0 @@
FROM ubuntu:jammy-20230624
RUN apt-get update && \
apt-get install -y software-properties-common curl && \
mkdir -p /opt/oraclejdk && \
cd /opt/oraclejdk && \
curl -L https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz | tar zx --strip-components=1
ENV JAVA_HOME /opt/oraclejdk
ENV PATH $JAVA_HOME/bin:$PATH

View File

@@ -1,8 +0,0 @@
FROM ubuntu:jammy-20230624
RUN apt-get update && \
apt-get install -y software-properties-common curl && \
mkdir -p /opt/oraclejdk && \
cd /opt/oraclejdk && \
curl -L https://download.oracle.com/java/17/archive/jdk-17.0.8_linux-aarch64_bin.tar.gz | tar zx --strip-components=1
ENV JAVA_HOME /opt/oraclejdk
ENV PATH $JAVA_HOME/bin:$PATH

View File

@@ -1,5 +0,0 @@
This folder contains a Dockerfile that will create an Oracle JDK instance for use in integration tests.
The resulting Docker image should not be published.
Oracle JDK is subject to the https://www.oracle.com/downloads/licenses/no-fee-license.html["Oracle No-Fee Terms and Conditions" License (NFTC)] license.
We are specifically using the unmodified JDK for the purposes of developing and testing.

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
</configuration>