Skip to content

Commit

Permalink
Ignore missing AWT library if missing
Browse files Browse the repository at this point in the history
- This is a workaround until oracle/graal#4124 is fixed
  • Loading branch information
gastaldi committed Feb 4, 2023
1 parent 3d22a4c commit d495b86
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.NativeImageFeatureBuildItem;
import io.quarkus.deployment.builditem.SystemPropertyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;

class POIProcessor {
Expand All @@ -34,6 +35,11 @@ void indexTransitiveDependencies(BuildProducer<IndexDependencyBuildItem> index)
index.produce(new IndexDependencyBuildItem("org.apache.poi", "poi-ooxml-full"));
}

@BuildStep
SystemPropertyBuildItem ignoreMissingFontSystem() {
return new SystemPropertyBuildItem("org.apache.poi.ss.ignoreMissingFontSystem", "true");
}

@BuildStep
void registerXMLBeansClassesForReflection(CombinedIndexBuildItem combinedIndexBuildItem,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkiverse.poi.runtime.graal;

import java.text.AttributedString;

import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.SheetUtil;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(SheetUtil.class)
@Platforms(Platform.MACOS.class)
public final class SheetUtilSubstitution {

@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
public static int DEFAULT_CHAR_WIDTH = 5;

@Substitute
public static int getDefaultCharWidth(final Workbook wb) {
return DEFAULT_CHAR_WIDTH;
}

@Substitute
private static double getCellWidth(int defaultCharWidth, int colspan,
CellStyle style, double minWidth, AttributedString str) {
return defaultCharWidth;
}
}

0 comments on commit d495b86

Please sign in to comment.