-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration for report file location #98
Configuration for report file location #98
Conversation
in config:
- "quarkus.jasperreports." Full example name: JasperReports
description: JasperReports is an open source reporting library that can be embedded into any Java application.
artifact: ${project.groupId}:${project.artifactId}:${project.version}
metadata:
short-name: "jasperreports"
type: "test"
keywords:
- "reports"
- "reporting"
- "pdf"
- "excel"
categories:
- "miscellaneous"
config:
- "quarkus.jasperreports."
status: "preview"
guide: "https://docs.quarkiverse.io/quarkus-jasperreports/dev/index.html"
icon-url: "https://raw.githubusercontent.com/quarkiverse/quarkus-jasperreports/main/docs/modules/ROOT/assets/images/jasperreports.svg" |
Done. Now, to figure out why it's not adding the config to the generated docs. The "Writing You Own Extension" guide makes it sound like you don't have to do anything but add the config class(es). |
5a53bf0
to
b81ac1f
Compare
You should not have to do anything |
b81ac1f
to
1857d89
Compare
@gastaldi I do the same, use a Maven plugin, but the purpose of this is to roll that into the deployment, though I'm not sure I'm producing the correct build item as I'm not getting a .jasper file to show up in the target directory or the .jar file. |
Perhaps we need a processor producing a |
1fd0fb6
to
ce1e711
Compare
@gastaldi Ok, I'm stuck. I tried writing the |
@nderwin i think I can help with this. I will look tomorrow. |
This is just pseudocode i didn't test it but to save to the output target directory the .jasper file. @BuildStep
void compileReports(ReportConfig config, List<ReportFileBuildItem> reportFiles,
BuildProducer<GeneratedClassBuildItem> compiledReportProducer,
OutputTargetBuildItem outputTarget) {
Log.warnf("Found %s report(s) to compile? %s", reportFiles.size(), config.build().enable());
if (config.build().enable()) {
// TODO - only compile if the report file has changed
for (ReportFileBuildItem item : reportFiles) {
String outputFile = item.getFileName().replace("." + ReportFileBuildItem.EXT_REPORT,
"." + ReportFileBuildItem.EXT_COMPILED);
String outputFilePath = outputTarget.getOutputDirectory().get(Path.of(config.build().destination().toString(), outputFile)).toString();
Log.warnf("Compiling %s into %s", item.getFileName(), outputFilePath);
try (InputStream inputStream = JRLoader.getLocationInputStream(item.getFileName())) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JasperCompileManager.compileReportToStream(inputStream, outputStream);
// might have to reset or reload the input stream if its a bytearrayStream you can call reset
JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
JasperCompileManager.compileReportToFile(jasperDesign, outputFilePath);
Log.warnf("Compiled size is %s", outputStream.size());
compiledReportProducer
.produce(new GeneratedClassBuildItem(true,
outputFilePath, // TODO: this is supposed to be the class name ??
outputStream.toByteArray()));
} catch (JRException ex) {
} catch (IOException ex) {
}
}
} else {
Log.debug("Automatic report compilation disabled");
}
} It uses the |
7b1a84e
to
170e0f9
Compare
@melloware Yes, now I have generated .jasper files. Needs some more cleanup, but this should be ready late today, and then it can be iterated and improved upon. |
Awesome! |
deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java
Outdated
Show resolved
Hide resolved
170e0f9
to
eaaef9e
Compare
config.build().destination().get().toString()); | ||
|
||
if (!Files.exists(outputFilePath)) { | ||
Files.createDirectories(outputFilePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to call outputFilePath.getParent()
if I am not mistaken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try that at first, but it didn't work right. This one puts the output directory where I wanted it to be.
542d578
to
1d983cd
Compare
deployment/src/main/java/io/quarkiverse/jasperreports/deployment/ReportConfig.java
Outdated
Show resolved
Hide resolved
1d983cd
to
153810f
Compare
@melloware This is so close... just barfing on the native tests if you could take a look? |
Have you merged all my latest changes from main? |
Oh I bet I know is it trying to compile on build? You can't compile in native mode so you have to add a LauncHMode check to your build step so it doesn't happen in Native mode. |
Yup, has the latest; I'm not as familiar with native mode (haven't needed to use it), but I thought we'd be able to use the output of the compile step to feed into whatever native mode needs? |
I will take a closer look tomorrow. |
// if (isRunningInContainer()) { | ||
// result = (JasperReport) JRLoader.loadObject(JRLoader.getLocationInputStream(jasperFile + ".jasper")); | ||
// } else { | ||
result = compile(jasperFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the issue. You can't compile in Native mode that is why this check uses the .jasper file and not the compiled file. It checks if it's running on Native mode. You need to put this back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compile
doesn't actually compile any more, it basically does what line 25 is doing - loading the previously compiled .jasper
file.
Found the issue. You need to put the code back the way I had it because it runs the integration tests against the native build and that absolutely cannot compile. |
Wow, your days are really short :) |
I am seeing errors in the log saying "src/main/resources" is invalid. Like it's not actually compiling them? |
* added runtime configuration to enable / disable building the reports * added source (.jrxml) and destination (.jasper) paths for the reports * ignore another NetBeans specific file for git * reworked the file watching to only watch the report files in dev mode, but we need to collect the report files always so they can be compiled * compile the found source files Signed-off-by:Nathan Erwin <[email protected]>
153810f
to
40879ad
Compare
@nderwin i am going to merge this and work on a fix. Its easier for me to figure it out working locally. |
@melloware Ok, let me know if there's anything I can do to help. |
Signed-off-by:Nathan Erwin [email protected]