Fail more elegantly when GraalVM version is too old
Closes gh-32924
This commit is contained in:
parent
19b2bd6d1c
commit
fe8644cc59
|
|
@ -261,6 +261,7 @@ publishing.publications.withType(MavenPublication) {
|
|||
metadataRepository {
|
||||
delegate.enabled('true')
|
||||
}
|
||||
delegate.requiredVersion('22.3')
|
||||
}
|
||||
executions {
|
||||
execution {
|
||||
|
|
@ -305,6 +306,7 @@ publishing.publications.withType(MavenPublication) {
|
|||
metadataRepository {
|
||||
delegate.enabled('true')
|
||||
}
|
||||
delegate.requiredVersion('22.3')
|
||||
}
|
||||
executions {
|
||||
execution {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ When the {nbt-gradle-plugin}[GraalVM Native Image plugin] is applied to a projec
|
|||
. Adds the output of the `aot` source set to the classpath of the `main` GraalVM native binary.
|
||||
. Adds the output of the `aotTest` source set to the classpath of the `test` GraalVM native binary.
|
||||
. Configures the GraalVM extension to disable Toolchain detection.
|
||||
. Configures each GraalVM native binary to require GraalVM 22.3 or later.
|
||||
. Configures the `bootJar` task to include the reachability metadata produced by the `collectReachabilityMetadata` task in its jar.
|
||||
. Configures the `bootBuildImage` task to use `paketobuildpacks/builder:tiny` as its builder and to set `BP_NATIVE_IMAGE` to `true` in its environment.
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.graalvm.buildtools.gradle.NativeImagePlugin;
|
|||
import org.graalvm.buildtools.gradle.dsl.GraalVMExtension;
|
||||
import org.graalvm.buildtools.gradle.dsl.GraalVMReachabilityMetadataRepositoryExtension;
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
|
|
@ -94,6 +95,15 @@ class NativeImagePluginAction implements PluginApplicationAction {
|
|||
private GraalVMExtension configureGraalVmExtension(Project project) {
|
||||
GraalVMExtension extension = project.getExtensions().getByType(GraalVMExtension.class);
|
||||
extension.getToolchainDetection().set(false);
|
||||
extension.getBinaries().configureEach((options) -> {
|
||||
try {
|
||||
options.getRequiredVersion().convention("22.3");
|
||||
}
|
||||
catch (NoSuchMethodError ex) {
|
||||
throw new GradleException("Incompatible version of org.graalvm.buildtools.native plugin. "
|
||||
+ "Please upgrade to 0.9.17 or later.");
|
||||
}
|
||||
});
|
||||
return extension;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,12 @@ class NativeImagePluginActionIntegrationTests {
|
|||
projectPath("build/resources/aotTest"), projectPath("build/generated/aotTestClasses"));
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void nativeImageBinariesRequireGraal22Dot3() {
|
||||
BuildResult result = this.gradleBuild.build("requiredGraalVersion");
|
||||
assertThat(result.getOutput()).contains("custom: 22.3", "main: 22.3", "test: 22.3");
|
||||
}
|
||||
|
||||
private String projectPath(String path) {
|
||||
return new File(this.gradleBuild.getProjectDir(), path).getAbsolutePath();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
apply plugin: 'org.graalvm.buildtools.native'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
graalvmNative {
|
||||
binaries {
|
||||
custom {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task('requiredGraalVersion') {
|
||||
doFirst {
|
||||
println "Binaries ${graalvmNative.binaries.asMap}"
|
||||
graalvmNative.binaries.asMap.each { name, binary ->
|
||||
println "${name}: ${binary.requiredVersion.get()}"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue