Merge branch '2.7.x' into 3.0.x
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -87,7 +87,7 @@ abstract class AbstractArchiveIntegrationTests {
|
||||
}
|
||||
else if (line.startsWith(entryPrefix)) {
|
||||
index.computeIfAbsent(layer, (key) -> new ArrayList<>())
|
||||
.add(line.substring(entryPrefix.length() + 1, line.length() - 1));
|
||||
.add(line.substring(entryPrefix.length() + 1, line.length() - 1));
|
||||
}
|
||||
line = reader.readLine();
|
||||
}
|
||||
@@ -146,7 +146,7 @@ abstract class AbstractArchiveIntegrationTests {
|
||||
withJarFile((jarFile) -> {
|
||||
withEntries(jarFile, (entries) -> {
|
||||
Optional<JarEntry> match = entries.filter((entry) -> entry.getName().startsWith(prefix))
|
||||
.findFirst();
|
||||
.findFirst();
|
||||
assertThat(match).hasValueSatisfying((entry) -> assertThat(entry.getComment()).isNull());
|
||||
});
|
||||
});
|
||||
@@ -157,9 +157,9 @@ abstract class AbstractArchiveIntegrationTests {
|
||||
withJarFile((jarFile) -> {
|
||||
withEntries(jarFile, (entries) -> {
|
||||
Optional<JarEntry> match = entries.filter((entry) -> entry.getName().startsWith(prefix))
|
||||
.findFirst();
|
||||
.findFirst();
|
||||
assertThat(match).as("Name starting with %s", prefix)
|
||||
.hasValueSatisfying((entry) -> assertThat(entry.getComment()).startsWith("UNPACK:"));
|
||||
.hasValueSatisfying((entry) -> assertThat(entry.getComment()).startsWith("UNPACK:"));
|
||||
});
|
||||
});
|
||||
return this;
|
||||
@@ -169,7 +169,7 @@ abstract class AbstractArchiveIntegrationTests {
|
||||
withJarFile((jarFile) -> {
|
||||
withEntries(jarFile, (entries) -> {
|
||||
Optional<JarEntry> match = entries.filter((entry) -> entry.getName().startsWith(prefix))
|
||||
.findFirst();
|
||||
.findFirst();
|
||||
assertThat(match).isNotPresent();
|
||||
});
|
||||
});
|
||||
@@ -178,8 +178,10 @@ abstract class AbstractArchiveIntegrationTests {
|
||||
|
||||
ListAssert<String> entryNamesInPath(String path) {
|
||||
List<String> matches = new ArrayList<>();
|
||||
withJarFile((jarFile) -> withEntries(jarFile, (entries) -> matches.addAll(entries.map(ZipEntry::getName)
|
||||
.filter((name) -> name.startsWith(path) && name.length() > path.length()).toList())));
|
||||
withJarFile((jarFile) -> withEntries(jarFile,
|
||||
(entries) -> matches.addAll(entries.map(ZipEntry::getName)
|
||||
.filter((name) -> name.startsWith(path) && name.length() > path.length())
|
||||
.toList())));
|
||||
return new ListAssert<>(matches);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -44,7 +44,7 @@ class AotTests {
|
||||
mavenBuild.project("aot").goals("package").execute((project) -> {
|
||||
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
|
||||
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
|
||||
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.java"));
|
||||
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.java"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class AotTests {
|
||||
mavenBuild.project("aot-class-proxy").goals("package").execute((project) -> {
|
||||
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
|
||||
assertThat(collectRelativePaths(aotDirectory.resolve("classes")))
|
||||
.contains(Path.of("org", "test", "SampleRunner$$SpringCGLIB$$0.class"));
|
||||
.contains(Path.of("org", "test", "SampleRunner$$SpringCGLIB$$0.class"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class AotTests {
|
||||
mavenBuild.project("aot-profile").goals("package").execute((project) -> {
|
||||
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
|
||||
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
|
||||
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
|
||||
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class AotTests {
|
||||
mavenBuild.project("aot-arguments").goals("package").execute((project) -> {
|
||||
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
|
||||
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
|
||||
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
|
||||
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class AotTests {
|
||||
mavenBuild.project("aot-jvm-arguments").goals("package").execute((project) -> {
|
||||
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
|
||||
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
|
||||
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
|
||||
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,14 +120,16 @@ class AotTests {
|
||||
mavenBuild.project("aot-release").goals("package").execute((project) -> {
|
||||
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
|
||||
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
|
||||
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.java"));
|
||||
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.java"));
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenAotRunsWithInvalidCompilerArgumentsCompileFails(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("aot-compiler-arguments").goals("package").executeAndFail(
|
||||
(project) -> assertThat(buildLog(project)).contains("invalid flag: --invalid-compiler-arg"));
|
||||
mavenBuild.project("aot-compiler-arguments")
|
||||
.goals("package")
|
||||
.executeAndFail(
|
||||
(project) -> assertThat(buildLog(project)).contains("invalid flag: --invalid-compiler-arg"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@@ -135,7 +137,7 @@ class AotTests {
|
||||
mavenBuild.project("aot").goals("package").execute((project) -> {
|
||||
Path classesDirectory = project.toPath().resolve("target/classes");
|
||||
assertThat(collectRelativePaths(classesDirectory))
|
||||
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.class"));
|
||||
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.class"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -156,7 +158,7 @@ class AotTests {
|
||||
mavenBuild.project("aot-class-proxy").goals("package").execute((project) -> {
|
||||
Path classesDirectory = project.toPath().resolve("target/classes/");
|
||||
assertThat(collectRelativePaths(classesDirectory))
|
||||
.contains(Path.of("org", "test", "SampleRunner$$SpringCGLIB$$0.class"));
|
||||
.contains(Path.of("org", "test", "SampleRunner$$SpringCGLIB$$0.class"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -177,7 +179,8 @@ class AotTests {
|
||||
List<Path> collectRelativePaths(Path sourceDirectory) {
|
||||
try (Stream<Path> pathStream = Files.walk(sourceDirectory)) {
|
||||
return pathStream.filter(Files::isRegularFile)
|
||||
.map((path) -> path.subpath(sourceDirectory.getNameCount(), path.getNameCount())).toList();
|
||||
.map((path) -> path.subpath(sourceDirectory.getNameCount(), path.getNameCount()))
|
||||
.toList();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* 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.
|
||||
@@ -47,7 +47,7 @@ class BuildImageRegistryIntegrationTests extends AbstractArchiveIntegrationTests
|
||||
|
||||
@Container
|
||||
static final RegistryContainer registry = new RegistryContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(3));
|
||||
.withStartupTimeout(Duration.ofMinutes(3));
|
||||
|
||||
DockerClient dockerClient;
|
||||
|
||||
@@ -64,17 +64,20 @@ class BuildImageRegistryIntegrationTests extends AbstractArchiveIntegrationTests
|
||||
void whenBuildImageIsInvokedWithPublish(MavenBuild mavenBuild) {
|
||||
String repoName = "test-image";
|
||||
String imageName = this.registryAddress + "/" + repoName;
|
||||
mavenBuild.project("build-image-publish").goals("package")
|
||||
.systemProperty("spring-boot.build-image.imageName", imageName).execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image").contains("Successfully built image")
|
||||
.contains("Pushing image '" + imageName + ":latest" + "'")
|
||||
.contains("Pushed image '" + imageName + ":latest" + "'");
|
||||
ImageReference imageReference = ImageReference.of(imageName);
|
||||
DockerApi.ImageApi imageApi = new DockerApi().image();
|
||||
Image pulledImage = imageApi.pull(imageReference, UpdateListener.none());
|
||||
assertThat(pulledImage).isNotNull();
|
||||
imageApi.remove(imageReference, false);
|
||||
});
|
||||
mavenBuild.project("build-image-publish")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.imageName", imageName)
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("Successfully built image")
|
||||
.contains("Pushing image '" + imageName + ":latest" + "'")
|
||||
.contains("Pushed image '" + imageName + ":latest" + "'");
|
||||
ImageReference imageReference = ImageReference.of(imageName);
|
||||
DockerApi.ImageApi imageApi = new DockerApi().image();
|
||||
Image pulledImage = imageApi.pull(imageReference, UpdateListener.none());
|
||||
assertThat(pulledImage).isNotNull();
|
||||
imageApi.remove(imageReference, false);
|
||||
});
|
||||
}
|
||||
|
||||
private static class RegistryContainer extends GenericContainer<RegistryContainer> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -49,333 +49,386 @@ class BuildImageTests extends AbstractArchiveIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithoutRepackageTheArchiveIsRepackagedOnTheFly(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project, "target/build-image-0.0.1.BUILD-SNAPSHOT.jar.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project, "target/build-image-0.0.1.BUILD-SNAPSHOT.jar.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedOnTheCommandLineWithoutRepackageTheArchiveIsRepackagedOnTheFly(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-cmd-line").goals("spring-boot:build-image")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-cmd-line-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project, "target/build-image-cmd-line-0.0.1.BUILD-SNAPSHOT.jar.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-cmd-line:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-cmd-line", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-cmd-line")
|
||||
.goals("spring-boot:build-image")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-cmd-line-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project, "target/build-image-cmd-line-0.0.1.BUILD-SNAPSHOT.jar.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-cmd-line:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-cmd-line", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithClassifierWithoutRepackageTheArchiveIsRepackagedOnTheFly(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-classifier").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-classifier-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File classifier = new File(project, "target/build-image-classifier-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(classifier).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-classifier:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-classifier", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-classifier")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-classifier-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File classifier = new File(project, "target/build-image-classifier-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(classifier).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-classifier:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-classifier", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithClassifierSourceWithoutRepackageTheArchiveIsRepackagedOnTheFly(
|
||||
MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-classifier-source").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-classifier-source:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-classifier-source", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-classifier-source")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-classifier-source:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-classifier-source", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithRepackageTheExistingArchiveIsUsed(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-with-repackage").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-with-repackage-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-with-repackage-0.0.1.BUILD-SNAPSHOT.jar.original");
|
||||
assertThat(original).isFile();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-with-repackage:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-with-repackage", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-with-repackage")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-with-repackage-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-with-repackage-0.0.1.BUILD-SNAPSHOT.jar.original");
|
||||
assertThat(original).isFile();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-with-repackage:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-with-repackage", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithClassifierAndRepackageTheExistingArchiveIsUsed(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-classifier-with-repackage").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
File jar = new File(project,
|
||||
"target/build-image-classifier-with-repackage-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-classifier-with-repackage-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(original).isFile();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-classifier-with-repackage:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-classifier-with-repackage", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-classifier-with-repackage")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-classifier-with-repackage-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-classifier-with-repackage-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(original).isFile();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-classifier-with-repackage:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-classifier-with-repackage", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithClassifierSourceAndRepackageTheExistingArchiveIsUsed(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-classifier-source-with-repackage").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
File jar = new File(project,
|
||||
"target/build-image-classifier-source-with-repackage-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-classifier-source-with-repackage-0.0.1.BUILD-SNAPSHOT-test.jar.original");
|
||||
assertThat(original).isFile();
|
||||
assertThat(buildLog(project)).contains("Building image").contains(
|
||||
"docker.io/library/build-image-classifier-source-with-repackage:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-classifier-source-with-repackage", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-classifier-source-with-repackage")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
File jar = new File(project,
|
||||
"target/build-image-classifier-source-with-repackage-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-classifier-source-with-repackage-0.0.1.BUILD-SNAPSHOT-test.jar.original");
|
||||
assertThat(original).isFile();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-classifier-source-with-repackage:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-classifier-source-with-repackage", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithWarPackaging(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-war-packaging").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
File war = new File(project, "target/build-image-war-packaging-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(war).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-war-packaging-0.0.1.BUILD-SNAPSHOT.war.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-war-packaging:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-war-packaging", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-war-packaging")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
File war = new File(project, "target/build-image-war-packaging-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(war).isFile();
|
||||
File original = new File(project, "target/build-image-war-packaging-0.0.1.BUILD-SNAPSHOT.war.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-war-packaging:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-war-packaging", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithCustomImageName(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-custom-name").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.systemProperty("spring-boot.build-image.imageName", "example.com/test/property-ignored:pom-preferred")
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-custom-name-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project,
|
||||
"target/build-image-custom-name-0.0.1.BUILD-SNAPSHOT.jar.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("example.com/test/build-image:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("example.com/test/build-image", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-custom-name")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.systemProperty("spring-boot.build-image.imageName", "example.com/test/property-ignored:pom-preferred")
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-custom-name-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
File original = new File(project, "target/build-image-custom-name-0.0.1.BUILD-SNAPSHOT.jar.original");
|
||||
assertThat(original).doesNotExist();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("example.com/test/build-image:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("example.com/test/build-image", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithCommandLineParameters(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.systemProperty("spring-boot.build-image.imageName", "example.com/test/cmd-property-name:v1")
|
||||
.systemProperty("spring-boot.build-image.builder",
|
||||
"projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1")
|
||||
.systemProperty("spring-boot.build-image.runImage",
|
||||
"projects.registry.vmware.com/springboot/run:tiny-cnb")
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("example.com/test/cmd-property-name:v1")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("example.com/test/cmd-property-name", "v1");
|
||||
});
|
||||
mavenBuild.project("build-image")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.systemProperty("spring-boot.build-image.imageName", "example.com/test/cmd-property-name:v1")
|
||||
.systemProperty("spring-boot.build-image.builder",
|
||||
"projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1")
|
||||
.systemProperty("spring-boot.build-image.runImage", "projects.registry.vmware.com/springboot/run:tiny-cnb")
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("example.com/test/cmd-property-name:v1")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("example.com/test/cmd-property-name", "v1");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithCustomBuilderImageAndRunImage(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-custom-builder").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT").execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-v2-builder:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("docker.io/library/build-image-v2-builder", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-custom-builder")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-v2-builder:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("docker.io/library/build-image-v2-builder", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithEmptyEnvEntry(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-empty-env-entry").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource).execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-empty-env-entry:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building").contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-empty-env-entry", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-empty-env-entry")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-empty-env-entry:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("---> Test Info buildpack done")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-empty-env-entry", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithZipPackaging(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-zip-packaging").goals("package").prepare(this::writeLongNameResource)
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT").execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-zip-packaging-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-zip-packaging:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Main-Class: org.springframework.boot.loader.PropertiesLauncher")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-zip-packaging", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-zip-packaging")
|
||||
.goals("package")
|
||||
.prepare(this::writeLongNameResource)
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.execute((project) -> {
|
||||
File jar = new File(project, "target/build-image-zip-packaging-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar).isFile();
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-zip-packaging:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Main-Class: org.springframework.boot.loader.PropertiesLauncher")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-zip-packaging", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithBuildpacks(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-custom-buildpacks").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT").execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-custom-buildpacks:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-custom-buildpacks", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-custom-buildpacks")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-custom-buildpacks:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-custom-buildpacks", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithBinding(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-bindings").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT").execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-bindings:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("binding: ca-certificates/type=ca-certificates")
|
||||
.contains("binding: ca-certificates/test.crt=---certificate one---")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-bindings", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-bindings")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-bindings:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("binding: ca-certificates/type=ca-certificates")
|
||||
.contains("binding: ca-certificates/test.crt=---certificate one---")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-bindings", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithNetworkModeNone(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-network").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT").execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-network:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Network status: curl failed").contains("Successfully built image");
|
||||
removeImage("build-image-network", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-network")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-network:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Network status: curl failed")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-network", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedOnMultiModuleProjectWithPackageGoal(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-multi-module").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT").execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-multi-module-app:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-multi-module-app", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
mavenBuild.project("build-image-multi-module")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-multi-module-app:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-multi-module-app", "0.0.1.BUILD-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithTags(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-tags").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT").execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-tags:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Successfully built image").contains("docker.io/library/build-image-tags:latest")
|
||||
.contains("Successfully created image tag");
|
||||
removeImage("build-image-tags", "0.0.1.BUILD-SNAPSHOT");
|
||||
removeImage("build-image-tags", "latest");
|
||||
});
|
||||
mavenBuild.project("build-image-tags")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-tags:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Successfully built image")
|
||||
.contains("docker.io/library/build-image-tags:latest")
|
||||
.contains("Successfully created image tag");
|
||||
removeImage("build-image-tags", "0.0.1.BUILD-SNAPSHOT");
|
||||
removeImage("build-image-tags", "latest");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildImageIsInvokedWithVolumeCaches(MavenBuild mavenBuild) {
|
||||
String testBuildId = randomString();
|
||||
mavenBuild.project("build-image-caches").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.systemProperty("test-build-id", testBuildId).execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-caches:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-caches", "0.0.1.BUILD-SNAPSHOT");
|
||||
deleteVolumes("cache-" + testBuildId + ".build", "cache-" + testBuildId + ".launch");
|
||||
});
|
||||
mavenBuild.project("build-image-caches")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.systemProperty("test-build-id", testBuildId)
|
||||
.execute((project) -> {
|
||||
assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("docker.io/library/build-image-caches:0.0.1.BUILD-SNAPSHOT")
|
||||
.contains("Successfully built image");
|
||||
removeImage("build-image-caches", "0.0.1.BUILD-SNAPSHOT");
|
||||
deleteVolumes("cache-" + testBuildId + ".build", "cache-" + testBuildId + ".launch");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void failsWhenBuildImageIsInvokedOnMultiModuleProjectWithBuildImageGoal(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-multi-module").goals("spring-boot:build-image")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT").executeAndFail(
|
||||
(project) -> assertThat(buildLog(project)).contains("Error packaging archive for image"));
|
||||
mavenBuild.project("build-image-multi-module")
|
||||
.goals("spring-boot:build-image")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project)).contains("Error packaging archive for image"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void failsWhenBuilderFails(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-builder-error").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("---> Test Info buildpack building").contains("Forced builder failure")
|
||||
.containsPattern("Builder lifecycle '.*' failed with status code"));
|
||||
mavenBuild.project("build-image-builder-error")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project)).contains("Building image")
|
||||
.contains("---> Test Info buildpack building")
|
||||
.contains("Forced builder failure")
|
||||
.containsPattern("Builder lifecycle '.*' failed with status code"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void failsWithBuildpackNotInBuilder(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-bad-buildpack").goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project))
|
||||
.contains("'urn:cnb:builder:example/does-not-exist:0.0.1' not found in builder"));
|
||||
mavenBuild.project("build-image-bad-buildpack")
|
||||
.goals("package")
|
||||
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project))
|
||||
.contains("'urn:cnb:builder:example/does-not-exist:0.0.1' not found in builder"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void failsWhenFinalNameIsMisconfigured(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-final-name").goals("package")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project)).contains("final-name.jar.original")
|
||||
.contains("is required for building an image"));
|
||||
mavenBuild.project("build-image-final-name")
|
||||
.goals("package")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project)).contains("final-name.jar.original")
|
||||
.contains("is required for building an image"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void failsWhenCachesAreConfiguredTwice(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-image-caches-multiple").goals("package")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project))
|
||||
.contains("Each image building cache can be configured only once"));
|
||||
mavenBuild.project("build-image-caches-multiple")
|
||||
.goals("package")
|
||||
.executeAndFail((project) -> assertThat(buildLog(project))
|
||||
.contains("Each image building cache can be configured only once"));
|
||||
}
|
||||
|
||||
private void writeLongNameResource(File project) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -42,67 +42,86 @@ class BuildInfoIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void buildInfoPropertiesAreGenerated(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-info").execute(buildInfo((buildInfo) -> assertThat(buildInfo)
|
||||
.hasBuildGroup("org.springframework.boot.maven.it").hasBuildArtifact("build-info")
|
||||
.hasBuildName("Generate build info").hasBuildVersion("0.0.1.BUILD-SNAPSHOT").containsBuildTime()));
|
||||
mavenBuild.project("build-info")
|
||||
.execute(buildInfo((buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
|
||||
.hasBuildArtifact("build-info")
|
||||
.hasBuildName("Generate build info")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
.containsBuildTime()));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void generatedBuildInfoIncludesAdditionalProperties(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-info-additional-properties").execute(buildInfo((buildInfo) -> assertThat(buildInfo)
|
||||
.hasBuildGroup("org.springframework.boot.maven.it").hasBuildArtifact("build-info-additional-properties")
|
||||
.hasBuildName("Generate build info with additional properties").hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
.containsBuildTime().containsEntry("build.foo", "bar").containsEntry("build.encoding", "UTF-8")
|
||||
mavenBuild.project("build-info-additional-properties")
|
||||
.execute(buildInfo((buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
|
||||
.hasBuildArtifact("build-info-additional-properties")
|
||||
.hasBuildName("Generate build info with additional properties")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
.containsBuildTime()
|
||||
.containsEntry("build.foo", "bar")
|
||||
.containsEntry("build.encoding", "UTF-8")
|
||||
.containsEntry("build.java.source", "1.8")));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void generatedBuildInfoUsesCustomBuildTime(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-info-custom-build-time").execute(buildInfo((buildInfo) -> assertThat(buildInfo)
|
||||
.hasBuildGroup("org.springframework.boot.maven.it").hasBuildArtifact("build-info-custom-build-time")
|
||||
.hasBuildName("Generate build info with custom build time").hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
mavenBuild.project("build-info-custom-build-time")
|
||||
.execute(buildInfo((buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
|
||||
.hasBuildArtifact("build-info-custom-build-time")
|
||||
.hasBuildName("Generate build info with custom build time")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
.hasBuildTime("2019-07-08T08:00:00Z")));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void generatedBuildInfoReproducible(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-info-reproducible")
|
||||
.execute(buildInfo((buildInfo) -> assertThat(buildInfo)
|
||||
.hasBuildGroup("org.springframework.boot.maven.it").hasBuildArtifact("build-reproducible")
|
||||
.hasBuildName("Generate build info with build time from project.build.outputTimestamp")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT").hasBuildTime("2021-04-21T11:22:33Z")));
|
||||
.execute(buildInfo((buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
|
||||
.hasBuildArtifact("build-reproducible")
|
||||
.hasBuildName("Generate build info with build time from project.build.outputTimestamp")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
.hasBuildTime("2021-04-21T11:22:33Z")));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void buildInfoPropertiesAreGeneratedToCustomOutputLocation(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-info-custom-file")
|
||||
.execute(buildInfo("target/build.info",
|
||||
(buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
|
||||
.hasBuildArtifact("build-info-custom-file").hasBuildName("Generate custom build info")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT").containsBuildTime()));
|
||||
.execute(buildInfo("target/build.info",
|
||||
(buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
|
||||
.hasBuildArtifact("build-info-custom-file")
|
||||
.hasBuildName("Generate custom build info")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
.containsBuildTime()));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildTimeIsDisabledIfDoesNotAppearInGeneratedBuildInfo(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-info-disable-build-time").execute(buildInfo((buildInfo) -> assertThat(buildInfo)
|
||||
.hasBuildGroup("org.springframework.boot.maven.it").hasBuildArtifact("build-info-disable-build-time")
|
||||
.hasBuildName("Generate build info with disabled build time").hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
mavenBuild.project("build-info-disable-build-time")
|
||||
.execute(buildInfo((buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
|
||||
.hasBuildArtifact("build-info-disable-build-time")
|
||||
.hasBuildName("Generate build info with disabled build time")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
.doesNotContainBuildTime()));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildTimeIsExcludedIfDoesNotAppearInGeneratedBuildInfo(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-info-exclude-build-time").execute(buildInfo((buildInfo) -> assertThat(buildInfo)
|
||||
.hasBuildGroup("org.springframework.boot.maven.it").hasBuildArtifact("build-info-exclude-build-time")
|
||||
.hasBuildName("Generate build info with excluded build time").hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
mavenBuild.project("build-info-exclude-build-time")
|
||||
.execute(buildInfo((buildInfo) -> assertThat(buildInfo).hasBuildGroup("org.springframework.boot.maven.it")
|
||||
.hasBuildArtifact("build-info-exclude-build-time")
|
||||
.hasBuildName("Generate build info with excluded build time")
|
||||
.hasBuildVersion("0.0.1.BUILD-SNAPSHOT")
|
||||
.doesNotContainBuildTime()));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenBuildPropertiesAreExcludedTheyDoNotAppearInGeneratedBuildInfo(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("build-info-exclude-build-properties").execute(
|
||||
buildInfo((buildInfo) -> assertThat(buildInfo).doesNotContainBuildGroup().doesNotContainBuildArtifact()
|
||||
.doesNotContainBuildName().doesNotContainBuildVersion().containsBuildTime()));
|
||||
mavenBuild.project("build-info-exclude-build-properties")
|
||||
.execute(buildInfo((buildInfo) -> assertThat(buildInfo).doesNotContainBuildGroup()
|
||||
.doesNotContainBuildArtifact()
|
||||
.doesNotContainBuildName()
|
||||
.doesNotContainBuildVersion()
|
||||
.containsBuildTime()));
|
||||
}
|
||||
|
||||
private ProjectCallback buildInfo(Consumer<AssertProvider<BuildInfoAssert>> buildInfo) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -59,14 +59,16 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
manifest.hasMainClass("org.springframework.boot.loader.JarLauncher");
|
||||
manifest.hasStartClass("some.random.Main");
|
||||
manifest.hasAttribute("Not-Used", "Foo");
|
||||
}).hasEntryWithNameStartingWith("BOOT-INF/lib/spring-context")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-core")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-jcl")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jakarta.servlet-api-6")
|
||||
.hasEntryWithName("BOOT-INF/classes/org/test/SampleApplication.class")
|
||||
.hasEntryWithName("org/springframework/boot/loader/JarLauncher.class");
|
||||
})
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-context")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-core")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-jcl")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jakarta.servlet-api-6")
|
||||
.hasEntryWithName("BOOT-INF/classes/org/test/SampleApplication.class")
|
||||
.hasEntryWithName("org/springframework/boot/loader/JarLauncher.class");
|
||||
assertThat(buildLog(project)).contains("Replacing main artifact with repackaged archive")
|
||||
.contains("Installing " + repackaged + " to").doesNotContain("Installing " + original + " to");
|
||||
.contains("Installing " + repackaged + " to")
|
||||
.doesNotContain("Installing " + original + " to");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -78,7 +80,8 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
File main = new File(project, "target/jar-attach-disabled-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(main).isFile();
|
||||
assertThat(buildLog(project)).contains("Updating main artifact " + main + " to " + original)
|
||||
.contains("Installing " + original + " to").doesNotContain("Installing " + main + " to");
|
||||
.contains("Installing " + original + " to")
|
||||
.doesNotContain("Installing " + main + " to");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,15 +90,16 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
MavenBuild mavenBuild) {
|
||||
mavenBuild.project("jar-classifier-main").goals("install").execute((project) -> {
|
||||
assertThat(new File(project, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT.jar.original"))
|
||||
.doesNotExist();
|
||||
.doesNotExist();
|
||||
File main = new File(project, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(main).isFile();
|
||||
File repackaged = new File(project, "target/jar-classifier-main-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/");
|
||||
assertThat(buildLog(project))
|
||||
.contains("Attaching repackaged archive " + repackaged + " with classifier test")
|
||||
.doesNotContain("Creating repackaged archive " + repackaged + " with classifier test")
|
||||
.contains("Installing " + main + " to").contains("Installing " + repackaged + " to");
|
||||
.contains("Attaching repackaged archive " + repackaged + " with classifier test")
|
||||
.doesNotContain("Creating repackaged archive " + repackaged + " with classifier test")
|
||||
.contains("Installing " + main + " to")
|
||||
.contains("Installing " + repackaged + " to");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +112,8 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
File repackaged = new File(project, "target/jar-classifier-source-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/");
|
||||
assertThat(buildLog(project)).contains("Replacing artifact with classifier test with repackaged archive")
|
||||
.doesNotContain("Installing " + original + " to").contains("Installing " + repackaged + " to");
|
||||
.doesNotContain("Installing " + original + " to")
|
||||
.contains("Installing " + repackaged + " to");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -122,9 +127,10 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
"target/jar-classifier-source-attach-disabled-0.0.1.BUILD-SNAPSHOT-test.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/");
|
||||
assertThat(buildLog(project))
|
||||
.doesNotContain("Attaching repackaged archive " + repackaged + " with classifier test")
|
||||
.contains("Updating artifact with classifier test " + repackaged + " to " + original)
|
||||
.contains("Installing " + original + " to").doesNotContain("Installing " + repackaged + " to");
|
||||
.doesNotContain("Attaching repackaged archive " + repackaged + " with classifier test")
|
||||
.contains("Updating artifact with classifier test " + repackaged + " to " + original)
|
||||
.contains("Installing " + original + " to")
|
||||
.doesNotContain("Installing " + repackaged + " to");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -161,10 +167,10 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-exclude-entry").goals("install").execute((project) -> {
|
||||
File repackaged = new File(project, "target/jar-exclude-entry-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-context")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-core")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-jcl")
|
||||
.doesNotHaveEntryWithName("BOOT-INF/lib/servlet-api-2.5.jar");
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-context")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-core")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-jcl")
|
||||
.doesNotHaveEntryWithName("BOOT-INF/lib/servlet-api-2.5.jar");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -173,10 +179,10 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-exclude-group").goals("install").execute((project) -> {
|
||||
File repackaged = new File(project, "target/jar-exclude-group-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-context")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-core")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-jcl")
|
||||
.doesNotHaveEntryWithName("BOOT-INF/lib/log4j-api-2.4.1.jar");
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-context")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-core")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-jcl")
|
||||
.doesNotHaveEntryWithName("BOOT-INF/lib/log4j-api-2.4.1.jar");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -186,7 +192,8 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
File repackaged = new File(project, "target/jar-executable-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/");
|
||||
assertThat(launchScript(repackaged)).contains("Spring Boot Startup Script")
|
||||
.contains("MyFullyExecutableJarName").contains("MyFullyExecutableJarDesc");
|
||||
.contains("MyFullyExecutableJarName")
|
||||
.contains("MyFullyExecutableJarDesc");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -195,10 +202,9 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-lib-name-conflict").execute((project) -> {
|
||||
File repackaged = new File(project, "test-project/target/test-project-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/")
|
||||
.hasEntryWithName(
|
||||
"BOOT-INF/lib/org.springframework.boot.maven.it-acme-lib-0.0.1.BUILD-SNAPSHOT.jar")
|
||||
.hasEntryWithName(
|
||||
"BOOT-INF/lib/org.springframework.boot.maven.it.another-acme-lib-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
.hasEntryWithName("BOOT-INF/lib/org.springframework.boot.maven.it-acme-lib-0.0.1.BUILD-SNAPSHOT.jar")
|
||||
.hasEntryWithName(
|
||||
"BOOT-INF/lib/org.springframework.boot.maven.it.another-acme-lib-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -244,7 +250,7 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-test-scope").execute((project) -> {
|
||||
File main = new File(project, "target/jar-test-scope-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(main)).doesNotHaveEntryWithNameStartingWith("BOOT-INF/lib/log4j")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-");
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -258,14 +264,15 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void whenAProjectIsBuiltWithALayoutPropertyTheSpecifiedLayoutIsUsed(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("jar-with-layout-property").goals("package", "-Dspring-boot.repackage.layout=ZIP")
|
||||
.execute((project) -> {
|
||||
File main = new File(project, "target/jar-with-layout-property-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(main)).manifest(
|
||||
(manifest) -> manifest.hasMainClass("org.springframework.boot.loader.PropertiesLauncher")
|
||||
.hasStartClass("org.test.SampleApplication"));
|
||||
assertThat(buildLog(project)).contains("Layout: ZIP");
|
||||
});
|
||||
mavenBuild.project("jar-with-layout-property")
|
||||
.goals("package", "-Dspring-boot.repackage.layout=ZIP")
|
||||
.execute((project) -> {
|
||||
File main = new File(project, "target/jar-with-layout-property-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(main))
|
||||
.manifest((manifest) -> manifest.hasMainClass("org.springframework.boot.loader.PropertiesLauncher")
|
||||
.hasStartClass("org.test.SampleApplication"));
|
||||
assertThat(buildLog(project)).contains("Layout: ZIP");
|
||||
});
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@@ -273,8 +280,8 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-with-zip-layout").execute((project) -> {
|
||||
File main = new File(project, "target/jar-with-zip-layout-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(main))
|
||||
.manifest((manifest) -> manifest.hasMainClass("org.springframework.boot.loader.PropertiesLauncher")
|
||||
.hasStartClass("org.test.SampleApplication"));
|
||||
.manifest((manifest) -> manifest.hasMainClass("org.springframework.boot.loader.PropertiesLauncher")
|
||||
.hasStartClass("org.test.SampleApplication"));
|
||||
assertThat(buildLog(project)).contains("Layout: ZIP");
|
||||
});
|
||||
}
|
||||
@@ -284,7 +291,7 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-with-unpack").execute((project) -> {
|
||||
File main = new File(project, "target/jar-with-unpack-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(main)).hasUnpackEntryWithNameStartingWith("BOOT-INF/lib/spring-core-")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-context-");
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/spring-context-");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -292,9 +299,9 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
void whenJarIsRepackagedWithACustomLayoutTheJarUsesTheLayout(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("jar-custom-layout").execute((project) -> {
|
||||
assertThat(jar(new File(project, "custom/target/custom-0.0.1.BUILD-SNAPSHOT.jar")))
|
||||
.hasEntryWithName("custom");
|
||||
.hasEntryWithName("custom");
|
||||
assertThat(jar(new File(project, "default/target/default-0.0.1.BUILD-SNAPSHOT.jar")))
|
||||
.hasEntryWithName("sample");
|
||||
.hasEntryWithName("sample");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -303,9 +310,10 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-layered").execute((project) -> {
|
||||
File repackaged = new File(project, "jar/target/jar-layered-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-snapshot").hasEntryWithNameStartingWith(
|
||||
"BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getCoordinates().getArtifactId());
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-snapshot")
|
||||
.hasEntryWithNameStartingWith(
|
||||
"BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getCoordinates().getArtifactId());
|
||||
try (JarFile jarFile = new JarFile(repackaged)) {
|
||||
Map<String, List<String>> layerIndex = readLayerIndex(jarFile);
|
||||
assertThat(layerIndex.keySet()).containsExactly("dependencies", "spring-boot-loader",
|
||||
@@ -313,7 +321,7 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
assertThat(layerIndex.get("application")).contains("BOOT-INF/lib/jar-release-0.0.1.RELEASE.jar",
|
||||
"BOOT-INF/lib/jar-snapshot-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(layerIndex.get("dependencies"))
|
||||
.anyMatch((dependency) -> dependency.startsWith("BOOT-INF/lib/log4j-api-2"));
|
||||
.anyMatch((dependency) -> dependency.startsWith("BOOT-INF/lib/log4j-api-2"));
|
||||
}
|
||||
catch (IOException ex) {
|
||||
}
|
||||
@@ -325,10 +333,10 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-layered-disabled").execute((project) -> {
|
||||
File repackaged = new File(project, "jar/target/jar-layered-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-snapshot")
|
||||
.doesNotHaveEntryWithName("BOOT-INF/layers.idx")
|
||||
.doesNotHaveEntryWithNameStartingWith("BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName());
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-snapshot")
|
||||
.doesNotHaveEntryWithName("BOOT-INF/layers.idx")
|
||||
.doesNotHaveEntryWithNameStartingWith("BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -337,10 +345,10 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-layered-no-layer-tools").execute((project) -> {
|
||||
File repackaged = new File(project, "jar/target/jar-layered-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-snapshot")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/layers.idx")
|
||||
.doesNotHaveEntryWithNameStartingWith("BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName());
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-snapshot")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/layers.idx")
|
||||
.doesNotHaveEntryWithNameStartingWith("BOOT-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -349,17 +357,17 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("jar-layered-custom").execute((project) -> {
|
||||
File repackaged = new File(project, "jar/target/jar-layered-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("BOOT-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-snapshot");
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("BOOT-INF/lib/jar-snapshot");
|
||||
try (JarFile jarFile = new JarFile(repackaged)) {
|
||||
Map<String, List<String>> layerIndex = readLayerIndex(jarFile);
|
||||
assertThat(layerIndex.keySet()).containsExactly("my-dependencies-name", "snapshot-dependencies",
|
||||
"configuration", "application");
|
||||
assertThat(layerIndex.get("application"))
|
||||
.contains("BOOT-INF/lib/jar-release-0.0.1.RELEASE.jar",
|
||||
"BOOT-INF/lib/jar-snapshot-0.0.1.BUILD-SNAPSHOT.jar",
|
||||
"BOOT-INF/lib/jar-classifier-0.0.1-bravo.jar")
|
||||
.doesNotContain("BOOT-INF/lib/jar-classifier-0.0.1-alpha.jar");
|
||||
.contains("BOOT-INF/lib/jar-release-0.0.1.RELEASE.jar",
|
||||
"BOOT-INF/lib/jar-snapshot-0.0.1.BUILD-SNAPSHOT.jar",
|
||||
"BOOT-INF/lib/jar-classifier-0.0.1-bravo.jar")
|
||||
.doesNotContain("BOOT-INF/lib/jar-classifier-0.0.1-alpha.jar");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -368,8 +376,8 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
void repackagedJarContainsClasspathIndex(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("jar").execute((project) -> {
|
||||
File repackaged = new File(project, "target/jar-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(jar(repackaged)).manifest(
|
||||
(manifest) -> manifest.hasAttribute("Spring-Boot-Classpath-Index", "BOOT-INF/classpath.idx"));
|
||||
assertThat(jar(repackaged))
|
||||
.manifest((manifest) -> manifest.hasAttribute("Spring-Boot-Classpath-Index", "BOOT-INF/classpath.idx"));
|
||||
assertThat(jar(repackaged)).hasEntryWithName("BOOT-INF/classpath.idx");
|
||||
try (JarFile jarFile = new JarFile(repackaged)) {
|
||||
List<String> index = readClasspathIndex(jarFile, "BOOT-INF/classpath.idx");
|
||||
@@ -395,8 +403,9 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
assertThat(repackaged.lastModified()).isEqualTo(1584352800000L);
|
||||
try (JarFile jar = new JarFile(repackaged)) {
|
||||
List<String> unreproducibleEntries = jar.stream()
|
||||
.filter((entry) -> entry.getLastModifiedTime().toMillis() != 1584352800000L)
|
||||
.map((entry) -> entry.getName() + ": " + entry.getLastModifiedTime()).toList();
|
||||
.filter((entry) -> entry.getLastModifiedTime().toMillis() != 1584352800000L)
|
||||
.map((entry) -> entry.getName() + ": " + entry.getLastModifiedTime())
|
||||
.toList();
|
||||
assertThat(unreproducibleEntries).isEmpty();
|
||||
jarHash.set(FileUtils.sha1Hash(repackaged));
|
||||
FileSystemUtils.deleteRecursively(project);
|
||||
@@ -416,8 +425,9 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
"BOOT-INF/lib/spring-beans", "BOOT-INF/lib/spring-boot-jarmode-layertools",
|
||||
"BOOT-INF/lib/spring-context", "BOOT-INF/lib/spring-core", "BOOT-INF/lib/spring-expression",
|
||||
"BOOT-INF/lib/spring-jcl");
|
||||
assertThat(jar(repackaged)).entryNamesInPath("BOOT-INF/lib/").zipSatisfy(sortedLibs,
|
||||
(String jarLib, String expectedLib) -> assertThat(jarLib).startsWith(expectedLib));
|
||||
assertThat(jar(repackaged)).entryNamesInPath("BOOT-INF/lib/")
|
||||
.zipSatisfy(sortedLibs,
|
||||
(String jarLib, String expectedLib) -> assertThat(jarLib).startsWith(expectedLib));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -157,9 +157,8 @@ class MavenBuild {
|
||||
|
||||
});
|
||||
String settingsXml = Files.readString(Paths.get("src", "intTest", "projects", "settings.xml"))
|
||||
.replace("@localCentralUrl@",
|
||||
new File("build/int-test-maven-repository").toURI().toURL().toString())
|
||||
.replace("@localRepositoryPath@", new File("build/local-maven-repository").getAbsolutePath());
|
||||
.replace("@localCentralUrl@", new File("build/int-test-maven-repository").toURI().toURL().toString())
|
||||
.replace("@localRepositoryPath@", new File("build/local-maven-repository").getAbsolutePath());
|
||||
Files.writeString(destination.resolve("settings.xml"), settingsXml, StandardOpenOption.CREATE_NEW);
|
||||
request.setBaseDirectory(this.temp);
|
||||
request.setJavaHome(new File(System.getProperty("java.home")));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -44,90 +44,104 @@ class RunIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void whenEnvironmentVariablesAreConfiguredTheyAreAvailableToTheApplication(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-envargs").goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
mavenBuild.project("run-envargs")
|
||||
.goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenExclusionsAreConfiguredExcludedDependenciesDoNotAppearOnTheClasspath(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-exclude").goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
mavenBuild.project("run-exclude")
|
||||
.goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenSystemPropertiesAndJvmArgumentsAreConfiguredTheyAreAvailableToTheApplication(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-jvm-system-props").goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
mavenBuild.project("run-jvm-system-props")
|
||||
.goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenJvmArgumentsAreConfiguredTheyAreAvailableToTheApplication(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-jvmargs").goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
mavenBuild.project("run-jvmargs")
|
||||
.goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenCommandLineSpecifiesJvmArgumentsTheyAreAvailableToTheApplication(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-jvmargs-commandline").goals("spring-boot:run")
|
||||
.systemProperty("spring-boot.run.jvmArguments", "-Dfoo=value-from-cmd")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
mavenBuild.project("run-jvmargs-commandline")
|
||||
.goals("spring-boot:run")
|
||||
.systemProperty("spring-boot.run.jvmArguments", "-Dfoo=value-from-cmd")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenPomAndCommandLineSpecifyJvmArgumentsThenPomOverrides(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-jvmargs").goals("spring-boot:run")
|
||||
.systemProperty("spring-boot.run.jvmArguments", "-Dfoo=value-from-cmd")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
mavenBuild.project("run-jvmargs")
|
||||
.goals("spring-boot:run")
|
||||
.systemProperty("spring-boot.run.jvmArguments", "-Dfoo=value-from-cmd")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenProfilesAreConfiguredTheyArePassedToTheApplication(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-profiles").goals("spring-boot:run", "-X").execute(
|
||||
(project) -> assertThat(buildLog(project)).contains("I haz been run with profile(s) 'foo,bar'"));
|
||||
mavenBuild.project("run-profiles")
|
||||
.goals("spring-boot:run", "-X")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run with profile(s) 'foo,bar'"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenUseTestClasspathIsEnabledTheApplicationHasTestDependenciesOnItsClasspath(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-use-test-classpath").goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
mavenBuild.project("run-use-test-classpath")
|
||||
.goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("I haz been run"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenAWorkingDirectoryIsConfiguredTheApplicationIsRunFromThatDirectory(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-working-directory").goals("spring-boot:run").execute(
|
||||
(project) -> assertThat(buildLog(project)).containsPattern("I haz been run from.*src.main.java"));
|
||||
mavenBuild.project("run-working-directory")
|
||||
.goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project)).containsPattern("I haz been run from.*src.main.java"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
void whenAToolchainIsConfiguredItIsUsedToRunTheApplication(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-toolchains").goals("verify", "-t", "toolchains.xml")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("The Maven Toolchains is awesome!"));
|
||||
mavenBuild.project("run-toolchains")
|
||||
.goals("verify", "-t", "toolchains.xml")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("The Maven Toolchains is awesome!"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenPomSpecifiesRunArgumentsContainingCommasTheyArePassedToTheApplicationCorrectly(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-arguments").goals("spring-boot:run").execute((project) -> assertThat(buildLog(project))
|
||||
mavenBuild.project("run-arguments")
|
||||
.goals("spring-boot:run")
|
||||
.execute((project) -> assertThat(buildLog(project))
|
||||
.contains("I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info'"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenCommandLineSpecifiesRunArgumentsContainingCommasTheyArePassedToTheApplicationCorrectly(
|
||||
MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-arguments-commandline").goals("spring-boot:run").systemProperty(
|
||||
"spring-boot.run.arguments",
|
||||
"--management.endpoints.web.exposure.include=prometheus,info,health,metrics --spring.profiles.active=foo,bar")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains(
|
||||
"I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info,health,metrics'"));
|
||||
mavenBuild.project("run-arguments-commandline")
|
||||
.goals("spring-boot:run")
|
||||
.systemProperty("spring-boot.run.arguments",
|
||||
"--management.endpoints.web.exposure.include=prometheus,info,health,metrics --spring.profiles.active=foo,bar")
|
||||
.execute((project) -> assertThat(buildLog(project))
|
||||
.contains("I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info,health,metrics'"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenPomAndCommandLineSpecifyRunArgumentsThenPomOverrides(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("run-arguments").goals("spring-boot:run")
|
||||
.systemProperty("spring-boot.run.arguments",
|
||||
"--management.endpoints.web.exposure.include=one,two,three --spring.profiles.active=test")
|
||||
.execute((project) -> assertThat(buildLog(project))
|
||||
.contains("I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info'"));
|
||||
mavenBuild.project("run-arguments")
|
||||
.goals("spring-boot:run")
|
||||
.systemProperty("spring-boot.run.arguments",
|
||||
"--management.endpoints.web.exposure.include=one,two,three --spring.profiles.active=test")
|
||||
.execute((project) -> assertThat(buildLog(project))
|
||||
.contains("I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info'"));
|
||||
}
|
||||
|
||||
private String buildLog(File project) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -34,14 +34,18 @@ class StartStopIntegrationTests {
|
||||
|
||||
@TestTemplate
|
||||
void startStopWaitsForApplicationToBeReadyAndThenRequestsShutdown(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("start-stop").goals("verify").execute(
|
||||
(project) -> assertThat(buildLog(project)).contains("isReady: true").contains("Shutdown requested"));
|
||||
mavenBuild.project("start-stop")
|
||||
.goals("verify")
|
||||
.execute((project) -> assertThat(buildLog(project)).contains("isReady: true")
|
||||
.contains("Shutdown requested"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenSkipIsTrueStartAndStopAreSkipped(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("start-stop-skip").goals("verify").execute((project) -> assertThat(buildLog(project))
|
||||
.doesNotContain("Ooops, I haz been run").doesNotContain("Stopping application"));
|
||||
mavenBuild.project("start-stop-skip")
|
||||
.goals("verify")
|
||||
.execute((project) -> assertThat(buildLog(project)).doesNotContain("Ooops, I haz been run")
|
||||
.doesNotContain("Stopping application"));
|
||||
}
|
||||
|
||||
private String buildLog(File project) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -51,33 +51,34 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
@TestTemplate
|
||||
void warRepackaging(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("war")
|
||||
.execute((project) -> assertThat(jar(new File(project, "target/war-0.0.1.BUILD-SNAPSHOT.war")))
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-context")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-core")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-jcl")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib-provided/jakarta.servlet-api-6")
|
||||
.hasEntryWithName("org/springframework/boot/loader/WarLauncher.class")
|
||||
.hasEntryWithName("WEB-INF/classes/org/test/SampleApplication.class")
|
||||
.hasEntryWithName("index.html")
|
||||
.manifest((manifest) -> manifest.hasMainClass("org.springframework.boot.loader.WarLauncher")
|
||||
.hasStartClass("org.test.SampleApplication").hasAttribute("Not-Used", "Foo")));
|
||||
.execute((project) -> assertThat(jar(new File(project, "target/war-0.0.1.BUILD-SNAPSHOT.war")))
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-context")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-core")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-jcl")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib-provided/jakarta.servlet-api-6")
|
||||
.hasEntryWithName("org/springframework/boot/loader/WarLauncher.class")
|
||||
.hasEntryWithName("WEB-INF/classes/org/test/SampleApplication.class")
|
||||
.hasEntryWithName("index.html")
|
||||
.manifest((manifest) -> manifest.hasMainClass("org.springframework.boot.loader.WarLauncher")
|
||||
.hasStartClass("org.test.SampleApplication")
|
||||
.hasAttribute("Not-Used", "Foo")));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void jarDependencyWithCustomFinalNameBuiltInSameReactorIsPackagedUsingArtifactIdAndVersion(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("war-reactor")
|
||||
.execute(((project) -> assertThat(jar(new File(project, "war/target/war-0.0.1.BUILD-SNAPSHOT.war")))
|
||||
.hasEntryWithName("WEB-INF/lib/jar-0.0.1.BUILD-SNAPSHOT.jar")
|
||||
.doesNotHaveEntryWithName("WEB-INF/lib/jar.jar")));
|
||||
.execute(((project) -> assertThat(jar(new File(project, "war/target/war-0.0.1.BUILD-SNAPSHOT.war")))
|
||||
.hasEntryWithName("WEB-INF/lib/jar-0.0.1.BUILD-SNAPSHOT.jar")
|
||||
.doesNotHaveEntryWithName("WEB-INF/lib/jar.jar")));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void whenRequiresUnpackConfigurationIsProvidedItIsReflectedInTheRepackagedWar(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("war-with-unpack").execute(
|
||||
(project) -> assertThat(jar(new File(project, "target/war-with-unpack-0.0.1.BUILD-SNAPSHOT.war")))
|
||||
.hasUnpackEntryWithNameStartingWith("WEB-INF/lib/spring-core-")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-context-")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-jcl-"));
|
||||
mavenBuild.project("war-with-unpack")
|
||||
.execute((project) -> assertThat(jar(new File(project, "target/war-with-unpack-0.0.1.BUILD-SNAPSHOT.war")))
|
||||
.hasUnpackEntryWithNameStartingWith("WEB-INF/lib/spring-core-")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-context-")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/spring-jcl-"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@@ -97,8 +98,9 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
assertThat(repackaged.lastModified()).isEqualTo(1584352800000L);
|
||||
try (JarFile jar = new JarFile(repackaged)) {
|
||||
List<String> unreproducibleEntries = jar.stream()
|
||||
.filter((entry) -> entry.getLastModifiedTime().toMillis() != 1584352800000L)
|
||||
.map((entry) -> entry.getName() + ": " + entry.getLastModifiedTime()).toList();
|
||||
.filter((entry) -> entry.getLastModifiedTime().toMillis() != 1584352800000L)
|
||||
.map((entry) -> entry.getName() + ": " + entry.getLastModifiedTime())
|
||||
.toList();
|
||||
assertThat(unreproducibleEntries).isEmpty();
|
||||
warHash.set(FileUtils.sha1Hash(repackaged));
|
||||
FileSystemUtils.deleteRecursively(project);
|
||||
@@ -122,8 +124,9 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
// these libraries are contributed by Spring Boot repackaging, and
|
||||
// sorted separately
|
||||
"WEB-INF/lib/spring-boot-jarmode-layertools");
|
||||
assertThat(jar(repackaged)).entryNamesInPath("WEB-INF/lib/").zipSatisfy(sortedLibs,
|
||||
(String jarLib, String expectedLib) -> assertThat(jarLib).startsWith(expectedLib));
|
||||
assertThat(jar(repackaged)).entryNamesInPath("WEB-INF/lib/")
|
||||
.zipSatisfy(sortedLibs,
|
||||
(String jarLib, String expectedLib) -> assertThat(jarLib).startsWith(expectedLib));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,9 +144,10 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("war-layered").execute((project) -> {
|
||||
File repackaged = new File(project, "war/target/war-layered-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("WEB-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-snapshot").hasEntryWithNameStartingWith(
|
||||
"WEB-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getCoordinates().getArtifactId());
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-snapshot")
|
||||
.hasEntryWithNameStartingWith(
|
||||
"WEB-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getCoordinates().getArtifactId());
|
||||
try (JarFile jarFile = new JarFile(repackaged)) {
|
||||
Map<String, List<String>> layerIndex = readLayerIndex(jarFile);
|
||||
assertThat(layerIndex.keySet()).containsExactly("dependencies", "spring-boot-loader",
|
||||
@@ -154,9 +158,9 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
assertThat(layerIndex.get("application")).contains("WEB-INF/lib/jar-release-0.0.1.RELEASE.jar",
|
||||
"WEB-INF/lib/jar-snapshot-0.0.1.BUILD-SNAPSHOT.jar");
|
||||
assertThat(dependenciesAndSnapshotDependencies)
|
||||
.anyMatch((dependency) -> dependency.startsWith("WEB-INF/lib/spring-context"));
|
||||
.anyMatch((dependency) -> dependency.startsWith("WEB-INF/lib/spring-context"));
|
||||
assertThat(layerIndex.get("dependencies"))
|
||||
.anyMatch((dependency) -> dependency.startsWith("WEB-INF/lib-provided/"));
|
||||
.anyMatch((dependency) -> dependency.startsWith("WEB-INF/lib-provided/"));
|
||||
}
|
||||
catch (IOException ex) {
|
||||
}
|
||||
@@ -168,10 +172,10 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("war-layered-disabled").execute((project) -> {
|
||||
File repackaged = new File(project, "war/target/war-layered-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("WEB-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-snapshot")
|
||||
.doesNotHaveEntryWithName("WEB-INF/layers.idx")
|
||||
.doesNotHaveEntryWithNameStartingWith("WEB-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName());
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-snapshot")
|
||||
.doesNotHaveEntryWithName("WEB-INF/layers.idx")
|
||||
.doesNotHaveEntryWithNameStartingWith("WEB-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -180,10 +184,10 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("war-layered-no-layer-tools").execute((project) -> {
|
||||
File repackaged = new File(project, "war/target/war-layered-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("WEB-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-snapshot")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/layers.idx")
|
||||
.doesNotHaveEntryWithNameStartingWith("WEB-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName());
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-snapshot")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/layers.idx")
|
||||
.doesNotHaveEntryWithNameStartingWith("WEB-INF/lib/" + JarModeLibrary.LAYER_TOOLS.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,17 +196,17 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("war-layered-custom").execute((project) -> {
|
||||
File repackaged = new File(project, "war/target/war-layered-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(jar(repackaged)).hasEntryWithNameStartingWith("WEB-INF/classes/")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-snapshot");
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-release")
|
||||
.hasEntryWithNameStartingWith("WEB-INF/lib/jar-snapshot");
|
||||
try (JarFile jarFile = new JarFile(repackaged)) {
|
||||
Map<String, List<String>> layerIndex = readLayerIndex(jarFile);
|
||||
assertThat(layerIndex.keySet()).containsExactly("my-dependencies-name", "snapshot-dependencies",
|
||||
"configuration", "application");
|
||||
assertThat(layerIndex.get("application"))
|
||||
.contains("WEB-INF/lib/jar-release-0.0.1.RELEASE.jar",
|
||||
"WEB-INF/lib/jar-snapshot-0.0.1.BUILD-SNAPSHOT.jar",
|
||||
"WEB-INF/lib/jar-classifier-0.0.1-bravo.jar")
|
||||
.doesNotContain("WEB-INF/lib/jar-classifier-0.0.1-alpha.jar");
|
||||
.contains("WEB-INF/lib/jar-release-0.0.1.RELEASE.jar",
|
||||
"WEB-INF/lib/jar-snapshot-0.0.1.BUILD-SNAPSHOT.jar",
|
||||
"WEB-INF/lib/jar-classifier-0.0.1-bravo.jar")
|
||||
.doesNotContain("WEB-INF/lib/jar-classifier-0.0.1-alpha.jar");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -211,13 +215,13 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
void repackagedWarContainsClasspathIndex(MavenBuild mavenBuild) {
|
||||
mavenBuild.project("war").execute((project) -> {
|
||||
File repackaged = new File(project, "target/war-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(jar(repackaged)).manifest(
|
||||
(manifest) -> manifest.hasAttribute("Spring-Boot-Classpath-Index", "WEB-INF/classpath.idx"));
|
||||
assertThat(jar(repackaged))
|
||||
.manifest((manifest) -> manifest.hasAttribute("Spring-Boot-Classpath-Index", "WEB-INF/classpath.idx"));
|
||||
assertThat(jar(repackaged)).hasEntryWithName("WEB-INF/classpath.idx");
|
||||
try (JarFile jarFile = new JarFile(repackaged)) {
|
||||
List<String> index = readClasspathIndex(jarFile, "WEB-INF/classpath.idx");
|
||||
assertThat(index).allMatch(
|
||||
(entry) -> entry.startsWith("WEB-INF/lib/") || entry.startsWith("WEB-INF/lib-provided/"));
|
||||
assertThat(index)
|
||||
.allMatch((entry) -> entry.startsWith("WEB-INF/lib/") || entry.startsWith("WEB-INF/lib-provided/"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -227,7 +231,7 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
|
||||
mavenBuild.project("war-exclude-entry").execute((project) -> {
|
||||
File war = new File(project, "target/war-exclude-entry-0.0.1.BUILD-SNAPSHOT.war");
|
||||
assertThat(jar(war)).hasEntryWithNameStartingWith("WEB-INF/lib/spring-context")
|
||||
.doesNotHaveEntryWithNameStartingWith("WEB-INF/lib/spring-core");
|
||||
.doesNotHaveEntryWithNameStartingWith("WEB-INF/lib/spring-core");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -113,9 +113,11 @@ public abstract class AbstractAotMojo extends AbstractDependencyFilterMojo {
|
||||
|
||||
protected void generateAotAssets(URL[] classPath, String processorClassName, String... arguments) throws Exception {
|
||||
List<String> command = CommandLineBuilder.forMainClass(processorClassName)
|
||||
.withSystemProperties(this.systemPropertyVariables)
|
||||
.withJvmArguments(new RunArguments(this.jvmArguments).asArray()).withClasspath(classPath)
|
||||
.withArguments(arguments).build();
|
||||
.withSystemProperties(this.systemPropertyVariables)
|
||||
.withJvmArguments(new RunArguments(this.jvmArguments).asArray())
|
||||
.withClasspath(classPath)
|
||||
.withArguments(arguments)
|
||||
.build();
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("Generating AOT assets using command: " + command);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -269,9 +269,10 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
protected RunArguments resolveJvmArguments() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (this.systemPropertyVariables != null) {
|
||||
stringBuilder.append(this.systemPropertyVariables.entrySet().stream()
|
||||
.map((e) -> SystemPropertyFormatter.format(e.getKey(), e.getValue()))
|
||||
.collect(Collectors.joining(" ")));
|
||||
stringBuilder.append(this.systemPropertyVariables.entrySet()
|
||||
.stream()
|
||||
.map((e) -> SystemPropertyFormatter.format(e.getKey(), e.getValue()))
|
||||
.collect(Collectors.joining(" ")));
|
||||
}
|
||||
if (this.jvmArguments != null) {
|
||||
stringBuilder.append(" ").append(this.jvmArguments);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -57,8 +57,10 @@ final class CommandLineBuilder {
|
||||
|
||||
CommandLineBuilder withSystemProperties(Map<String, String> systemProperties) {
|
||||
if (systemProperties != null) {
|
||||
systemProperties.entrySet().stream().map((e) -> SystemPropertyFormatter.format(e.getKey(), e.getValue()))
|
||||
.forEach(this.options::add);
|
||||
systemProperties.entrySet()
|
||||
.stream()
|
||||
.map((e) -> SystemPropertyFormatter.format(e.getKey(), e.getValue()))
|
||||
.forEach(this.options::add);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -130,13 +130,15 @@ class CustomLayersProvider {
|
||||
List<String> excludes = getChildNodeTextContent(element, "exclude");
|
||||
Element includeModuleDependencies = getChildElement(element, "includeModuleDependencies");
|
||||
Element excludeModuleDependencies = getChildElement(element, "excludeModuleDependencies");
|
||||
List<ContentFilter<Library>> includeFilters = includes.stream().map(filterFactory)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
List<ContentFilter<Library>> includeFilters = includes.stream()
|
||||
.map(filterFactory)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
if (includeModuleDependencies != null) {
|
||||
includeFilters.add(Library::isLocal);
|
||||
}
|
||||
List<ContentFilter<Library>> excludeFilters = excludes.stream().map(filterFactory)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
List<ContentFilter<Library>> excludeFilters = excludes.stream()
|
||||
.map(filterFactory)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
if (excludeModuleDependencies != null) {
|
||||
excludeFilters.add(Library::isLocal);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* 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.
|
||||
@@ -35,7 +35,7 @@ import org.apache.maven.artifact.Artifact;
|
||||
class JarTypeFilter extends DependencyFilter {
|
||||
|
||||
private static final Set<String> EXCLUDED_JAR_TYPES = Collections
|
||||
.unmodifiableSet(new HashSet<>(Arrays.asList("annotation-processor", "dependencies-starter")));
|
||||
.unmodifiableSet(new HashSet<>(Arrays.asList("annotation-processor", "dependencies-starter")));
|
||||
|
||||
JarTypeFilter() {
|
||||
super(Collections.emptyList());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* 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.
|
||||
@@ -37,8 +37,9 @@ class LoggingMainClassTimeoutWarningListener implements MainClassTimeoutWarningL
|
||||
|
||||
@Override
|
||||
public void handleTimeoutWarning(long duration, String mainMethod) {
|
||||
this.log.get().warn("Searching for the main-class is taking some time, "
|
||||
+ "consider using the mainClass configuration parameter");
|
||||
this.log.get()
|
||||
.warn("Searching for the main-class is taking some time, "
|
||||
+ "consider using the mainClass configuration parameter");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -150,7 +150,7 @@ public class ProcessTestAotMojo extends AbstractAotMojo {
|
||||
this.generatedClasses };
|
||||
URL[] classPath = getClassPath(directories);
|
||||
if (!includeJUnitPlatformLauncher || this.project.getArtifactMap()
|
||||
.containsKey(JUNIT_PLATFORM_GROUP_ID + ":" + JUNIT_PLATFORM_LAUNCHER_ARTIFACT_ID)) {
|
||||
.containsKey(JUNIT_PLATFORM_GROUP_ID + ":" + JUNIT_PLATFORM_LAUNCHER_ARTIFACT_ID)) {
|
||||
return classPath;
|
||||
}
|
||||
return addJUnitPlatformLauncher(classPath);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -63,9 +63,10 @@ public class RunMojo extends AbstractRunMojo {
|
||||
@Override
|
||||
protected void run(JavaProcessExecutor processExecutor, File workingDirectory, List<String> args,
|
||||
Map<String, String> environmentVariables) throws MojoExecutionException, MojoFailureException {
|
||||
processExecutor.withRunProcessCustomizer(
|
||||
(runProcess) -> Runtime.getRuntime().addShutdownHook(new Thread(new RunProcessKiller(runProcess))))
|
||||
.run(workingDirectory, args, environmentVariables);
|
||||
processExecutor
|
||||
.withRunProcessCustomizer(
|
||||
(runProcess) -> Runtime.getRuntime().addShutdownHook(new Thread(new RunProcessKiller(runProcess))))
|
||||
.run(workingDirectory, args, environmentVariables);
|
||||
}
|
||||
|
||||
private static final class RunProcessKiller implements Runnable {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -143,11 +143,11 @@ class ArtifactsLibrariesTests {
|
||||
given(snapshotArtifact.getArtifactHandler()).willReturn(this.artifactHandler);
|
||||
this.artifacts = Collections.singleton(snapshotArtifact);
|
||||
new ArtifactsLibraries(this.artifacts, Collections.emptyList(), null, mock(Log.class))
|
||||
.doWithLibraries((library) -> {
|
||||
assertThat(library.isIncluded()).isTrue();
|
||||
assertThat(library.isLocal()).isFalse();
|
||||
assertThat(library.getCoordinates().getVersion()).isEqualTo("1.0-SNAPSHOT");
|
||||
});
|
||||
.doWithLibraries((library) -> {
|
||||
assertThat(library.isIncluded()).isTrue();
|
||||
assertThat(library.isLocal()).isFalse();
|
||||
assertThat(library.getCoordinates().getVersion()).isEqualTo("1.0-SNAPSHOT");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,7 +162,7 @@ class ArtifactsLibrariesTests {
|
||||
given(mavenProject.getArtifact()).willReturn(artifact);
|
||||
this.artifacts = Collections.singleton(artifact);
|
||||
new ArtifactsLibraries(this.artifacts, Collections.singleton(mavenProject), null, mock(Log.class))
|
||||
.doWithLibraries((library) -> assertThat(library.isLocal()).isTrue());
|
||||
.doWithLibraries((library) -> assertThat(library.isLocal()).isTrue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,7 +179,7 @@ class ArtifactsLibrariesTests {
|
||||
given(mavenProject.getAttachedArtifacts()).willReturn(Collections.singletonList(attachedArtifact));
|
||||
this.artifacts = Collections.singleton(attachedArtifact);
|
||||
new ArtifactsLibraries(this.artifacts, Collections.singleton(mavenProject), null, mock(Log.class))
|
||||
.doWithLibraries((library) -> assertThat(library.isLocal()).isTrue());
|
||||
.doWithLibraries((library) -> assertThat(library.isLocal()).isTrue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -194,7 +194,8 @@ class ArtifactsLibrariesTests {
|
||||
given(mavenProject.getArtifact()).willReturn(artifact);
|
||||
this.artifacts = Collections.singleton(artifact);
|
||||
new ArtifactsLibraries(this.artifacts, Collections.emptySet(), Collections.singleton(mavenProject), null,
|
||||
mock(Log.class)).doWithLibraries((library) -> assertThat(library.isIncluded()).isFalse());
|
||||
mock(Log.class))
|
||||
.doWithLibraries((library) -> assertThat(library.isIncluded()).isFalse());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -36,43 +36,44 @@ class CommandLineBuilderTests {
|
||||
@Test
|
||||
void buildWithNullJvmArgumentsIsIgnored() {
|
||||
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withJvmArguments((String[]) null).build())
|
||||
.containsExactly(CLASS_NAME);
|
||||
.containsExactly(CLASS_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWithNullIntermediateJvmArgumentIsIgnored() {
|
||||
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withJvmArguments("-verbose:class", null, "-verbose:gc")
|
||||
.build()).containsExactly("-verbose:class", "-verbose:gc", CLASS_NAME);
|
||||
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME)
|
||||
.withJvmArguments("-verbose:class", null, "-verbose:gc")
|
||||
.build()).containsExactly("-verbose:class", "-verbose:gc", CLASS_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWithJvmArgument() {
|
||||
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withJvmArguments("-verbose:class").build())
|
||||
.containsExactly("-verbose:class", CLASS_NAME);
|
||||
.containsExactly("-verbose:class", CLASS_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWithNullSystemPropertyIsIgnored() {
|
||||
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withSystemProperties(null).build())
|
||||
.containsExactly(CLASS_NAME);
|
||||
.containsExactly(CLASS_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWithSystemProperty() {
|
||||
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withSystemProperties(Map.of("flag", "enabled")).build())
|
||||
.containsExactly("-Dflag=\"enabled\"", CLASS_NAME);
|
||||
.containsExactly("-Dflag=\"enabled\"", CLASS_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWithNullArgumentsIsIgnored() {
|
||||
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withArguments((String[]) null).build())
|
||||
.containsExactly(CLASS_NAME);
|
||||
.containsExactly(CLASS_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWithNullIntermediateArgumentIsIgnored() {
|
||||
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withArguments("--test", null, "--another").build())
|
||||
.containsExactly(CLASS_NAME, "--test", "--another");
|
||||
.containsExactly(CLASS_NAME, "--test", "--another");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,9 @@ class CustomLayersProviderTests {
|
||||
@Test
|
||||
void getLayerResolverWhenDocumentValid() throws Exception {
|
||||
CustomLayers layers = this.customLayersProvider.getLayers(getDocument("layers.xml"));
|
||||
assertThat(layers).extracting("name").containsExactly("my-deps", "my-dependencies-name",
|
||||
"snapshot-dependencies", "my-resources", "configuration", "application");
|
||||
assertThat(layers).extracting("name")
|
||||
.containsExactly("my-deps", "my-dependencies-name", "snapshot-dependencies", "my-resources",
|
||||
"configuration", "application");
|
||||
Library snapshot = mockLibrary("test-SNAPSHOT.jar", "org.foo", "1.0.0-SNAPSHOT");
|
||||
Library groupId = mockLibrary("my-library", "com.acme", null);
|
||||
Library otherDependency = mockLibrary("other-library", "org.foo", null);
|
||||
@@ -81,7 +82,7 @@ class CustomLayersProviderTests {
|
||||
Library library = mockLibrary("my-library", "com.acme", null);
|
||||
assertThat(layers.getLayer(library)).hasToString("my-deps");
|
||||
assertThatIllegalStateException().isThrownBy(() -> layers.getLayer("application.yml"))
|
||||
.withMessageContaining("match any layer");
|
||||
.withMessageContaining("match any layer");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,7 +91,7 @@ class CustomLayersProviderTests {
|
||||
Library library = mockLibrary("my-library", "com.acme", null);
|
||||
assertThat(layers.getLayer("application.yml")).hasToString("my-layer");
|
||||
assertThatIllegalStateException().isThrownBy(() -> layers.getLayer(library))
|
||||
.withMessageContaining("match any layer");
|
||||
.withMessageContaining("match any layer");
|
||||
}
|
||||
|
||||
private Document getDocument(String resourceName) throws Exception {
|
||||
|
||||
@@ -41,8 +41,10 @@ class DockerTests {
|
||||
assertThat(dockerConfiguration.getHost()).isNull();
|
||||
assertThat(dockerConfiguration.getBuilderRegistryAuthentication()).isNull();
|
||||
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"\"").contains("\"password\" : \"\"").contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
.contains("\"username\" : \"\"")
|
||||
.contains("\"password\" : \"\"")
|
||||
.contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,8 +61,10 @@ class DockerTests {
|
||||
assertThat(dockerConfiguration.isBindHostToBuilder()).isFalse();
|
||||
assertThat(docker.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
|
||||
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"\"").contains("\"password\" : \"\"").contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
.contains("\"username\" : \"\"")
|
||||
.contains("\"password\" : \"\"")
|
||||
.contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,8 +82,10 @@ class DockerTests {
|
||||
assertThat(dockerConfiguration.isBindHostToBuilder()).isTrue();
|
||||
assertThat(docker.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
|
||||
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"\"").contains("\"password\" : \"\"").contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
.contains("\"username\" : \"\"")
|
||||
.contains("\"password\" : \"\"")
|
||||
.contains("\"email\" : \"\"")
|
||||
.contains("\"serveraddress\" : \"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,13 +97,15 @@ class DockerTests {
|
||||
new Docker.DockerRegistry("user2", "secret2", "https://docker2.example.com", "docker2@example.com"));
|
||||
DockerConfiguration dockerConfiguration = docker.asDockerConfiguration();
|
||||
assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"user1\"").contains("\"password\" : \"secret1\"")
|
||||
.contains("\"email\" : \"docker1@example.com\"")
|
||||
.contains("\"serveraddress\" : \"https://docker1.example.com\"");
|
||||
.contains("\"username\" : \"user1\"")
|
||||
.contains("\"password\" : \"secret1\"")
|
||||
.contains("\"email\" : \"docker1@example.com\"")
|
||||
.contains("\"serveraddress\" : \"https://docker1.example.com\"");
|
||||
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"username\" : \"user2\"").contains("\"password\" : \"secret2\"")
|
||||
.contains("\"email\" : \"docker2@example.com\"")
|
||||
.contains("\"serveraddress\" : \"https://docker2.example.com\"");
|
||||
.contains("\"username\" : \"user2\"")
|
||||
.contains("\"password\" : \"secret2\"")
|
||||
.contains("\"email\" : \"docker2@example.com\"")
|
||||
.contains("\"serveraddress\" : \"https://docker2.example.com\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,7 +114,7 @@ class DockerTests {
|
||||
docker.setBuilderRegistry(
|
||||
new Docker.DockerRegistry("user", null, "https://docker.example.com", "docker@example.com"));
|
||||
assertThatIllegalArgumentException().isThrownBy(docker::asDockerConfiguration)
|
||||
.withMessageContaining("Invalid Docker builder registry configuration");
|
||||
.withMessageContaining("Invalid Docker builder registry configuration");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,7 +123,7 @@ class DockerTests {
|
||||
docker.setPublishRegistry(
|
||||
new Docker.DockerRegistry("user", null, "https://docker.example.com", "docker@example.com"));
|
||||
assertThatIllegalArgumentException().isThrownBy(docker::asDockerConfiguration)
|
||||
.withMessageContaining("Invalid Docker publish registry configuration");
|
||||
.withMessageContaining("Invalid Docker publish registry configuration");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,9 +133,9 @@ class DockerTests {
|
||||
docker.setPublishRegistry(new Docker.DockerRegistry("token2"));
|
||||
DockerConfiguration dockerConfiguration = docker.asDockerConfiguration();
|
||||
assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"identitytoken\" : \"token1\"");
|
||||
.contains("\"identitytoken\" : \"token1\"");
|
||||
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
|
||||
.contains("\"identitytoken\" : \"token2\"");
|
||||
.contains("\"identitytoken\" : \"token2\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,7 +147,7 @@ class DockerTests {
|
||||
Docker docker = new Docker();
|
||||
docker.setBuilderRegistry(dockerRegistry);
|
||||
assertThatIllegalArgumentException().isThrownBy(docker::asDockerConfiguration)
|
||||
.withMessageContaining("Invalid Docker builder registry configuration");
|
||||
.withMessageContaining("Invalid Docker builder registry configuration");
|
||||
}
|
||||
|
||||
String decoded(String value) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* 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.
|
||||
@@ -93,7 +93,7 @@ class JavaCompilerPluginConfigurationTests {
|
||||
|
||||
private Xpp3Dom buildConfigurationDom(String... properties) throws IOException, XmlPullParserException {
|
||||
return Xpp3DomBuilder
|
||||
.build(new StringReader("<configuration>" + Arrays.toString(properties) + "</configuration>"));
|
||||
.build(new StringReader("<configuration>" + Arrays.toString(properties) + "</configuration>"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user