Update CNB buildpack Java version env variable
Prior to this commit, the build tool plugins set the environment variable BP_JAVA_VERSION when invoking the CNB builder to set the version of the JDK/JRE that the builder should use in the created image. With CNB API 0.3, the convention changed the name of this environment variable to BP_JVM_VERSION. This commit updates the build tool plugins to match the newer convention. See gh-21273
This commit is contained in:
@@ -146,7 +146,7 @@ The builder can be specified on the command line as well, as shown in this examp
|
||||
==== Builder Configuration
|
||||
If the builder exposes configuration options using environment variables, those can be set using the `env` attributes.
|
||||
|
||||
The following example assumes that the default builder defines a `BP_JAVA_VERSION` property (typically used to customize the JDK version the image should use):
|
||||
The following example assumes that the default builder defines a `BP_JVM_VERSION` property (typically used to customize the JDK version the image should use):
|
||||
|
||||
[source,xml,indent=0,subs="verbatim,attributes"]
|
||||
----
|
||||
@@ -160,7 +160,7 @@ The following example assumes that the default builder defines a `BP_JAVA_VERSIO
|
||||
<configuration>
|
||||
<image>
|
||||
<env>
|
||||
<BP_JAVA_VERSION>13.0.1</BP_JAVA_VERSION>
|
||||
<BP_JVM_VERSION>13.0.1</BP_JVM_VERSION>
|
||||
</env>
|
||||
</image>
|
||||
</configuration>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<configuration>
|
||||
<image>
|
||||
<env>
|
||||
<BP_JAVA_VERSION>13.9.9</BP_JAVA_VERSION>
|
||||
<BP_JVM_VERSION>13.9.9</BP_JVM_VERSION>
|
||||
</env>
|
||||
</image>
|
||||
</configuration>
|
||||
|
||||
@@ -63,7 +63,7 @@ import org.springframework.util.StringUtils;
|
||||
@Execute(phase = LifecyclePhase.PACKAGE)
|
||||
public class BuildImageMojo extends AbstractPackagerMojo {
|
||||
|
||||
private static final String OPENJDK_BUILDPACK_JAVA_VERSION_KEY = "BP_JAVA_VERSION";
|
||||
private static final String BUILDPACK_JVM_VERSION_KEY = "BP_JVM_VERSION";
|
||||
|
||||
/**
|
||||
* Directory containing the JAR.
|
||||
@@ -175,11 +175,11 @@ public class BuildImageMojo extends AbstractPackagerMojo {
|
||||
}
|
||||
|
||||
private BuildRequest customizeEnvironment(BuildRequest request) {
|
||||
if (!request.getEnv().containsKey(OPENJDK_BUILDPACK_JAVA_VERSION_KEY)) {
|
||||
if (!request.getEnv().containsKey(BUILDPACK_JVM_VERSION_KEY)) {
|
||||
JavaCompilerPluginConfiguration compilerConfiguration = new JavaCompilerPluginConfiguration(this.project);
|
||||
String targetJavaVersion = compilerConfiguration.getTargetMajorVersion();
|
||||
if (StringUtils.hasText(targetJavaVersion)) {
|
||||
return request.withEnv(OPENJDK_BUILDPACK_JAVA_VERSION_KEY, targetJavaVersion + ".*");
|
||||
return request.withEnv(BUILDPACK_JVM_VERSION_KEY, targetJavaVersion + ".*");
|
||||
}
|
||||
}
|
||||
return request;
|
||||
|
||||
Reference in New Issue
Block a user