Skip to content

Commit

Permalink
Remove org.graalvm.polyglot:polyglot when using Mandrel 23.0
Browse files Browse the repository at this point in the history
Mandrel 23.0 ships with org.graalvm.polyglot:polyglot embedded and
adding it to the classpath results in an error.
  • Loading branch information
zakkak committed Mar 13, 2024
1 parent df72bbc commit 6a8a66f
Showing 1 changed file with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.deployment.pkg.steps;

import static io.quarkus.deployment.pkg.steps.GraalVM.Version.CURRENT;
import static io.quarkus.deployment.pkg.steps.GraalVM.Version.VERSION_23_1_0;
import static io.quarkus.fs.util.ZipUtils.wrapForJDK8232879;

import java.io.BufferedInputStream;
Expand Down Expand Up @@ -74,8 +76,11 @@
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.deployment.pkg.builditem.JarBuildItem;
import io.quarkus.deployment.pkg.builditem.LegacyJarRequiredBuildItem;
import io.quarkus.deployment.pkg.builditem.NativeImageRunnerBuildItem;
import io.quarkus.deployment.pkg.builditem.NativeImageSourceJarBuildItem;
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
import io.quarkus.deployment.pkg.builditem.ProcessInheritIODisabled;
import io.quarkus.deployment.pkg.builditem.ProcessInheritIODisabledBuildItem;
import io.quarkus.deployment.pkg.builditem.UberJarIgnoredResourceBuildItem;
import io.quarkus.deployment.pkg.builditem.UberJarMergedResourceBuildItem;
import io.quarkus.deployment.pkg.builditem.UberJarRequiredBuildItem;
Expand Down Expand Up @@ -970,7 +975,10 @@ public NativeImageSourceJarBuildItem buildNativeImageJar(CurateOutcomeBuildItem
List<GeneratedNativeImageClassBuildItem> nativeImageResources,
List<GeneratedResourceBuildItem> generatedResources,
MainClassBuildItem mainClassBuildItem,
ClassLoadingConfig classLoadingConfig) throws Exception {
ClassLoadingConfig classLoadingConfig,
NativeImageRunnerBuildItem nativeImageRunnerBuildItem,
Optional<ProcessInheritIODisabled> processInheritIODisabled,
Optional<ProcessInheritIODisabledBuildItem> processInheritIODisabledBuildItem) throws Exception {
Path targetDirectory = outputTargetBuildItem.getOutputDirectory()
.resolve(outputTargetBuildItem.getBaseName() + "-native-image-source-jar");
IoUtils.createOrEmptyDir(targetDirectory);
Expand All @@ -983,7 +991,7 @@ public NativeImageSourceJarBuildItem buildNativeImageJar(CurateOutcomeBuildItem
return buildNativeImageThinJar(curateOutcomeBuildItem, outputTargetBuildItem, transformedClasses,
applicationArchivesBuildItem,
applicationInfo, packageConfig, allClasses, generatedResources, mainClassBuildItem, targetDirectory,
classLoadingConfig);
classLoadingConfig, nativeImageRunnerBuildItem, processInheritIODisabled, processInheritIODisabledBuildItem);
}

private NativeImageSourceJarBuildItem buildNativeImageThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,
Expand All @@ -996,7 +1004,10 @@ private NativeImageSourceJarBuildItem buildNativeImageThinJar(CurateOutcomeBuild
List<GeneratedResourceBuildItem> generatedResources,
MainClassBuildItem mainClassBuildItem,
Path targetDirectory,
ClassLoadingConfig classLoadingConfig) throws Exception {
ClassLoadingConfig classLoadingConfig,
NativeImageRunnerBuildItem nativeImageRunnerBuildItem,
Optional<ProcessInheritIODisabled> processInheritIODisabled,
Optional<ProcessInheritIODisabledBuildItem> processInheritIODisabledBuildItem) throws Exception {
copyJsonConfigFiles(applicationArchivesBuildItem, targetDirectory);

Path runnerJar = targetDirectory
Expand All @@ -1019,6 +1030,21 @@ private NativeImageSourceJarBuildItem buildNativeImageThinJar(CurateOutcomeBuild
removedArtifacts.add("org.graalvm.sdk:word");
removedArtifacts.add("org.graalvm.sdk:collections");

nativeImageRunnerBuildItem.getBuildRunner()
.setup(processInheritIODisabled.isPresent() || processInheritIODisabledBuildItem.isPresent());
final GraalVM.Version v;
if (nativeImageRunnerBuildItem.getBuildRunner() instanceof NoopNativeImageBuildRunner) {
v = CURRENT;
log.warnf("native-image is not installed. " +
"Using the default %s version as a reference to build native image thin jar.", v.getVersionAsString());
} else {
v = nativeImageRunnerBuildItem.getBuildRunner().getGraalVMVersion();
}

if (v.compareTo(VERSION_23_1_0) < 0) {
removedArtifacts.add("org.graalvm.polyglot:polyglot");
}

doLegacyThinJarGeneration(curateOutcomeBuildItem, outputTargetBuildItem, transformedClasses,
applicationArchivesBuildItem, applicationInfo, packageConfig, generatedResources, libDir, allClasses,
runnerZipFs, mainClassBuildItem, classLoadingConfig);
Expand Down

0 comments on commit 6a8a66f

Please sign in to comment.