Skip to content

Commit

Permalink
Fix #74: JasperReports 7.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 3, 2024
1 parent 713bf0c commit 5923a12
Show file tree
Hide file tree
Showing 11 changed files with 14,178 additions and 14,105 deletions.
20 changes: 1 addition & 19 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,7 @@ updates:
- dependency-name: "io.quarkus:quarkus-maven-plugin"
- dependency-name: "io.quarkus:quarkus-extension-processor"
- dependency-name: "io.quarkus:quarkus-extension-maven-plugin"
- dependency-name: "net.sf.jasperreports:jasperreports"
- dependency-name: "net.sf.jasperreports:jasperreports-fonts"
- dependency-name: "jaxen:jaxen"
groups:
quarkus:
patterns:
- "io.quarkus*"
- "quarkus*"
quarkiverse:
patterns:
- "io.quarkiverse*"
dependencies:
patterns:
- "*"
exclude-patterns:
- "io.quarkus*"
- "quarkus*"
- "io.quarkiverse*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "daily"
9 changes: 9 additions & 0 deletions deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-awt-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxb-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.poi</groupId>
<artifactId>quarkus-poi-deployment</artifactId>
<version>${version.quarkus-poi}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-dev-ui-spi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package io.quarkiverse.jasperreports.deployment;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedPackageBuildItem;
import io.quarkus.deployment.pkg.builditem.UberJarMergedResourceBuildItem;

Expand All @@ -25,24 +33,68 @@ UberJarMergedResourceBuildItem mergeResource() {
return new UberJarMergedResourceBuildItem(EXTENSIONS_FILE);
}

@BuildStep
void indexTransitiveDependencies(BuildProducer<IndexDependencyBuildItem> index) {
index.produce(new IndexDependencyBuildItem("net.sf.jasperreports", "jasperreports"));
index.produce(new IndexDependencyBuildItem("net.sf.jasperreports", "jasperreports-jaxen"));
index.produce(new IndexDependencyBuildItem("org.apache.xmlgraphics", "batik-bridge"));
index.produce(new IndexDependencyBuildItem("org.apache.xmlgraphics", "batik-gvt"));
}

@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndex) {

final List<String> classNames = new ArrayList<>();
classNames.addAll(collectClassesInPackage(combinedIndex, org.apache.batik.gvt.font.AWTGVTFont.class.getPackageName()));
classNames.addAll(collectClassesInPackage(combinedIndex,
net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.class.getPackageName()));
classNames.addAll(collectClassesInPackage(combinedIndex,
net.sf.jasperreports.engine.util.ImageUtil.class.getPackageName()));

reflectiveClass.produce(
ReflectiveClassBuildItem.builder(classNames.toArray(new String[0])).methods(true).serialization(true).build());
}

@BuildStep
void runtimeInitializedClasses(BuildProducer<RuntimeInitializedPackageBuildItem> runtimeInitializedPackages) {
//@formatter:off
Stream.of(
javax.swing.plaf.metal.MetalIconFactory.class.getPackageName(),
net.sf.jasperreports.data.http.HttpDataService.class.getPackageName(),
net.sf.jasperreports.engine.SimpleReportContext.class.getPackageName(),
net.sf.jasperreports.engine.design.JRAbstractCompiler.class.getPackageName(),
net.sf.jasperreports.engine.export.JRXlsExporter.class.getPackageName(),
net.sf.jasperreports.engine.export.oasis.JROdtExporter.class.getPackageName(),
net.sf.jasperreports.engine.export.ooxml.DocxRunHelper.class.getPackageName(),
net.sf.jasperreports.engine.fonts.AwtFontManager.class.getPackageName(),
net.sf.jasperreports.engine.print.JRPrinterAWT.class.getPackageName(),
net.sf.jasperreports.engine.type.ColorEnum.class.getPackageName(),
net.sf.jasperreports.engine.util.ExifUtil.class.getPackageName(),
net.sf.jasperreports.engine.util.json.DefaultJsonQLExecuter.class.getPackageName(),
net.sf.jasperreports.renderers.AbstractSvgDataToGraphics2DRenderer.class.getPackageName(),
net.sf.jasperreports.renderers.util.SvgFontProcessor.class.getPackageName()
"org.apache.xmlbeans.impl.config",
"javax.swing.plaf.metal",
"javax.swing.text.rtf",
"javax.swing.text.html",
"javax.swing",
"sun.swing",
"sun.datatransfer",
"org.apache.hc.client5.http.impl.auth.NTLMEngineImpl",
org.apache.batik.bridge.CSSUtilities.class.getPackageName(),
org.apache.batik.css.engine.SystemColorSupport.class.getPackageName(),
org.apache.batik.dom.svg.AbstractSVGTransform.class.getPackageName(),
org.apache.batik.anim.values.AnimatableTransformListValue.class.getPackageName(),
org.apache.batik.ext.awt.MultipleGradientPaint.class.getPackageName(),
org.apache.batik.ext.awt.image.GraphicsUtil.class.getPackageName(),
org.apache.batik.ext.awt.image.rendered.TurbulencePatternRed.class.getPackageName(),
org.apache.batik.ext.awt.image.spi.DefaultBrokenLinkProvider.class.getName(),
org.apache.batik.gvt.CompositeGraphicsNode.class.getPackageName(),
org.apache.batik.gvt.renderer.MacRenderer.class.getPackageName(),
org.apache.batik.script.InterpreterPool.class.getName(),
org.apache.xmlbeans.impl.schema.TypeSystemHolder.class.getName(),
org.apache.xmlbeans.impl.xpath.saxon.SaxonXPath.class.getPackageName(),
org.apache.xmlbeans.impl.config.PrePostExtensionImpl.class.getPackageName(),
net.sf.jasperreports.components.list.UnusedSpaceImageRenderer.class.getName(),
net.sf.jasperreports.components.util.AbstractFieldComparator.class.getPackageName(),
net.sf.jasperreports.engine.SimpleReportContext.class.getPackageName(),
net.sf.jasperreports.engine.base.ElementsBlock.class.getPackageName(),
net.sf.jasperreports.engine.convert.ReportConverter.class.getName(),
net.sf.jasperreports.engine.export.AbstractTextRenderer.class.getPackageName(),
net.sf.jasperreports.engine.fill.JRFillSubreport.class.getPackageName(),
net.sf.jasperreports.engine.fonts.AwtFontManager.class.getPackageName(),
net.sf.jasperreports.engine.type.ColorEnum.class.getPackageName(),
net.sf.jasperreports.crosstabs.fill.calculation.MeasureDefinition.class.getPackageName(),
net.sf.jasperreports.components.headertoolbar.HeaderToolbarElement.class.getPackageName(),
net.sf.jasperreports.engine.util.JRQueryExecuterUtils.class.getPackageName()

)
.map(RuntimeInitializedPackageBuildItem::new)
.forEach(runtimeInitializedPackages::produce);
Expand All @@ -58,10 +110,26 @@ void substrateResourceBuildItems(BuildProducer<NativeImageResourceBuildItem> nat
"jasperreports_messages.properties",
"metadata_messages.properties",
"metadata_messages-defaults.properties",
"properties-metadata.json"));
"properties-metadata.json",
"net/sf/jasperreports/fonts/dejavu/jasperreports-fonts.xml"));

resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("jasperreports_messages"));
resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("metadata_messages"));
resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("metadata_messages-defaults"));
}

public List<String> collectClassesInPackage(CombinedIndexBuildItem combinedIndex, String packageName) {
final List<String> classes = new ArrayList<>();
final List<DotName> packages = new ArrayList<>(combinedIndex.getIndex().getSubpackages(packageName));
packages.add(DotName.createSimple(packageName));
for (DotName aPackage : packages) {
final List<String> packageClasses = combinedIndex.getIndex()
.getClassesInPackage(aPackage)
.stream()
.map(ClassInfo::toString)
.toList();
classes.addAll(packageClasses);
}
return classes;
}
}
5 changes: 4 additions & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.jasperreports</groupId>
Expand Down Expand Up @@ -103,6 +103,9 @@
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
<quarkus.native.additional-build-args>
--trace-object-instantiation=org.apache.batik.bridge.RhinoInterpreterFactory
</quarkus.native.additional-build-args>
</properties>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;

import org.w3c.dom.Document;

Expand All @@ -38,19 +37,15 @@
import net.sf.jasperreports.engine.ReportContext;
import net.sf.jasperreports.engine.SimpleReportContext;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.export.HtmlExporter;
import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.engine.export.JRXmlExporter;
import net.sf.jasperreports.engine.fill.JRFiller;
import net.sf.jasperreports.engine.fill.SimpleJasperReportSource;
import net.sf.jasperreports.engine.query.JRXPathQueryExecuterFactory;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.util.JRXmlUtils;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleHtmlExporterOutput;
import net.sf.jasperreports.export.SimpleWriterExporterOutput;
import net.sf.jasperreports.export.SimpleXmlExporterOutput;
import net.sf.jasperreports.repo.JasperDesignCache;
import net.sf.jasperreports.repo.SimpleRepositoryResourceContext;

Expand Down Expand Up @@ -120,40 +115,40 @@ public byte[] csv() throws JRException {
return outputStream.toByteArray();
}

@POST
@Path("xml")
public byte[] xml(@QueryParam("embedded") boolean embedded) throws JRException {
long start = System.currentTimeMillis();
JasperPrint jasperPrint = fill();

JRXmlExporter exporter = new JRXmlExporter(DefaultJasperReportsContext.getInstance());

exporter.setExporterInput(new SimpleExporterInput(jasperPrint));

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
SimpleXmlExporterOutput xmlOutput = new SimpleXmlExporterOutput(outputStream);
xmlOutput.setEmbeddingImages(embedded);
exporter.setExporterOutput(xmlOutput);
exporter.exportReport();
Log.info("XML creation time : " + (System.currentTimeMillis() - start));
return outputStream.toByteArray();
}

@POST
@Path("html")
public byte[] html() throws JRException {
long start = System.currentTimeMillis();
JasperPrint jasperPrint = fill();

HtmlExporter exporter = new HtmlExporter(DefaultJasperReportsContext.getInstance());
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
exporter.setExporterOutput(new SimpleHtmlExporterOutput(outputStream));

exporter.exportReport();
Log.info("HTML creation time : " + (System.currentTimeMillis() - start));
return outputStream.toByteArray();
}
// @POST
// @Path("xml")
// public byte[] xml(@QueryParam("embedded") boolean embedded) throws JRException {
// long start = System.currentTimeMillis();
// JasperPrint jasperPrint = fill();
//
// JRXmlExporter exporter = new JRXmlExporter(DefaultJasperReportsContext.getInstance());
//
// exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
//
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// SimpleXmlExporterOutput xmlOutput = new SimpleXmlExporterOutput(outputStream);
// xmlOutput.setEmbeddingImages(embedded);
// exporter.setExporterOutput(xmlOutput);
// exporter.exportReport();
// Log.info("XML creation time : " + (System.currentTimeMillis() - start));
// return outputStream.toByteArray();
// }
//
// @POST
// @Path("html")
// public byte[] html() throws JRException {
// long start = System.currentTimeMillis();
// JasperPrint jasperPrint = fill();
//
// HtmlExporter exporter = new HtmlExporter(DefaultJasperReportsContext.getInstance());
// exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// exporter.setExporterOutput(new SimpleHtmlExporterOutput(outputStream));
//
// exporter.exportReport();
// Log.info("HTML creation time : " + (System.currentTimeMillis() - start));
// return outputStream.toByteArray();
// }

// @POST
// @Path("print")
Expand Down
Loading

0 comments on commit 5923a12

Please sign in to comment.