Add buildpack option for image building
This commit adds configuration to the Maven and Gradle plugins to allow a list of buildpacks to be provided to the image building goal and task. Fixes gh-21722
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -26,6 +27,7 @@ import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.buildpack.platform.build.BuildRequest;
|
||||
import org.springframework.boot.buildpack.platform.build.BuildpackReference;
|
||||
import org.springframework.boot.buildpack.platform.build.PullPolicy;
|
||||
import org.springframework.boot.buildpack.platform.io.Owner;
|
||||
import org.springframework.boot.buildpack.platform.io.TarArchive;
|
||||
@@ -65,6 +67,7 @@ class ImageTests {
|
||||
assertThat(request.isCleanCache()).isFalse();
|
||||
assertThat(request.isVerboseLogging()).isFalse();
|
||||
assertThat(request.getPullPolicy()).isEqualTo(PullPolicy.ALWAYS);
|
||||
assertThat(request.getBuildpacks()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,6 +126,15 @@ class ImageTests {
|
||||
assertThat(request.isPublish()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBuildRequestWhenHasBuildpacksUsesBuildpacks() {
|
||||
Image image = new Image();
|
||||
image.buildpacks = Arrays.asList("example/buildpack1@0.0.1", "example/buildpack2@0.0.2");
|
||||
BuildRequest request = image.getBuildRequest(createArtifact(), mockApplicationContent());
|
||||
assertThat(request.getBuildpacks()).containsExactly(BuildpackReference.of("example/buildpack1@0.0.1"),
|
||||
BuildpackReference.of("example/buildpack2@0.0.2"));
|
||||
}
|
||||
|
||||
private Artifact createArtifact() {
|
||||
return new DefaultArtifact("com.example", "my-app", VersionRange.createFromVersion("0.0.1-SNAPSHOT"), "compile",
|
||||
"jar", null, new DefaultArtifactHandler());
|
||||
|
||||
Reference in New Issue
Block a user