Conversation
PR Summary by QodoRelease 0.1.6: Schematron cache/params + serializer outputMethod support
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
1. Stale marker skips recompile
|
| File compiledFile = getStyle().get().getAsFile(); | ||
| synchronized (transpilerCompileLock) { | ||
| if (needsRecompile(compiledFile, transpilerParameters)) { | ||
| compileSchematron(compiledFile, transpilerParameters); | ||
| writeFingerprint(fingerprintMarkerFor(compiledFile), computeTranspilerFingerprint(transpilerParameters)); | ||
| } |
There was a problem hiding this comment.
1. Stale marker skips recompile 🐞 Bug ☼ Reliability
SchematronTask only updates the fingerprint marker after compileSchematron succeeds; if compilation fails after truncating/partially writing the compiled stylesheet, the old marker can remain valid and needsRecompile() may incorrectly skip recompilation on the next run, reusing a corrupted stylesheet.
Agent Prompt
### Issue description
`SchematronTask` persists a compiled stylesheet and a `.transpiler.sha256` fingerprint marker. The marker is only written after compilation succeeds. If compilation fails after it has already modified the compiled stylesheet file (e.g., truncated/partially written), the old marker can remain and still match the current parameter fingerprint. On the next run, `needsRecompile()` can treat the compiled stylesheet as current and skip recompiling, causing repeated failures (or incorrect behavior) until the compiled file is manually deleted.
### Issue Context
- `resolveCompiledStylesheet()` calls `compileSchematron(compiledFile, ...)` and then writes the fingerprint marker.
- `needsRecompile()` relies on the marker match to skip recompilation.
### Fix Focus Areas
- src/main/java/name/jurgenei/gradle/xml/SchematronTask.java[355-393]
### Suggested implementation approach
- Compile to a temp file in the same directory and then atomically move/replace `compiledFile` (best effort: `Files.move(..., REPLACE_EXISTING, ATOMIC_MOVE)` with fallback).
- Only write the fingerprint marker after the move/replace succeeds.
- If compilation throws, delete/clear the fingerprint marker (and optionally delete the partially-written compiled file) so the next run will recompile.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| private File fingerprintMarkerFor(File compiledFile) { | ||
| return new File(compiledFile.getParentFile(), compiledFile.getName() + ".transpiler.sha256"); | ||
| } | ||
|
|
||
| private boolean isFingerprintCurrent(File markerFile, String currentFingerprint) { | ||
| if (!markerFile.isFile()) { | ||
| return false; | ||
| } | ||
| try { | ||
| String recorded = Files.readString(markerFile.toPath(), StandardCharsets.UTF_8).trim(); | ||
| return currentFingerprint.equals(recorded); | ||
| } catch (Exception ignored) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| private void writeFingerprint(File markerFile, String fingerprint) throws Exception { | ||
| Files.writeString(markerFile.toPath(), fingerprint, StandardCharsets.UTF_8); | ||
| } |
There was a problem hiding this comment.
2. Undeclared marker output 🐞 Bug ⚙ Maintainability
SchematronTask writes a sidecar fingerprint file '<compiled>.transpiler.sha256' but does not declare it as an output, so Gradle output tracking/cleanup does not model this generated file and it may be unexpectedly created alongside user-chosen style paths.
Agent Prompt
### Issue description
`SchematronTask` generates a fingerprint sidecar file (`.transpiler.sha256`) next to the persisted compiled stylesheet. This file is written during task execution but is not declared as an output (`@OutputFile` / `@OutputDirectory`), which makes Gradle's output model incomplete and can leave untracked generated files.
### Issue Context
- The compiled stylesheet is declared via `getStyle()` as `@OutputFile`.
- The marker file is created via `fingerprintMarkerFor(...)` and `writeFingerprint(...)`.
### Fix Focus Areas
- src/main/java/name/jurgenei/gradle/xml/SchematronTask.java[88-100]
- src/main/java/name/jurgenei/gradle/xml/SchematronTask.java[455-473]
### Suggested implementation approach
- Add a derived task property for the marker file (e.g., `getStyleFingerprintFile()`) annotated as `@OutputFile` and computed from `getStyle()`.
- Alternatively, store the fingerprint under an existing declared output directory and declare that directory as an `@OutputDirectory` for the marker(s).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Misc fixes maturing the plugin