Repository navigation
Support build-time SVG rendering in Maven/Gradle via the CLI - #282
Merged
Merged
Conversation
Harden the CLI for in-process use from exec-maven-plugin / Gradle JavaExec: create missing output parent directories, default to headless AWT, and reject unknown options, missing values, and invalid numbers. Add a Build-time Rendering guide and README section. Fixes: #279 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#279 asks for a way to render SVG logos to PNG/JPEG at build time, for example PWA icons. The prototype for this is viritin/svg-render-maven-plugin. This PR does it without a new Maven plugin artifact: the build runs the existing CLI (
io.brunoborges.jairosvg.cli.Main) in the same JVM, usingexec-maven-plugin'sjavagoal withjairosvgadded as a plugin dependency. Gradle can do the same with aJavaExectask.The CLI needed three small changes to work reliably inside a build:
-o target/classes/META-INF/resources/icons/icon.pngfailed if the folder did not exist.Mainsetsjava.awt.headless=trueunless the property is already set. This matters because the CLI now runs inside the Maven JVM.IllegalArgumentExceptionwith a clear message. This way a typo such as--outputwidthfails the build instead of producing an image at the wrong size.testUnknownFlagIgnoredis replaced by tests for the rejection cases.Docs:
build-time-rendering.md, linked from the site menu andcli.md. It covers:generated-resources+build-helperalternative-i, --invert-imagesfrom the README CLI table, because the CLI never implemented it.bump-version.shnow also updates the version shown in the new page.Compared with the dedicated plugin, this gives up
{size}placeholders, fingerprint-based incremental skipping, and automatic resource registration. In return there is no new artifact to release or maintain.Validation:
mvn packageput a 512x512 PNG and a 192x96 JPEG into the jar. Changing an argument to the typo--outputwidthfailed the build withUnknown option../mvnw clean verify site: 1272 tests, 0 failures, and the new page was generated. The site step also logged a javadoc report error, but the build still succeeded.Fixes: #279
Checklist
./mvnw clean verify(BUILD SUCCESS, 1272 tests, 0 failures)./mvnw spotless:apply