Skip to content

Bugfix for 429 (Maven sourceDocuments configuration is optional)#431

Open
ascheman wants to merge 13 commits into
developfrom
bugfix/429-maven-sourcedocs-optional
Open

Bugfix for 429 (Maven sourceDocuments configuration is optional)#431
ascheman wants to merge 13 commits into
developfrom
bugfix/429-maven-sourcedocs-optional

Conversation

@ascheman

Copy link
Copy Markdown
Member

The Maven source document configuration should be optional (it was mandatory as it seems).

This closes #429

@ascheman ascheman requested review from Copilot and truhroth October 29, 2025 15:07
@ascheman ascheman self-assigned this Oct 29, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request enhances the HTML Sanity Check Maven and Gradle plugins to automatically discover HTML files (including .htm extension) from the sourceDir when sourceDocuments is not explicitly configured. Key changes include:

  • Auto-population of sourceDocuments from sourceDir when not specified
  • Support for both .html and .htm file extensions
  • Addition of a recursive file discovery mechanism for the Maven plugin
  • Comprehensive test coverage for the new functionality
  • Fixed a typo in method name (defaultIndeFilenamesdefaultIndexFilenames)
  • Updated documentation to reflect .htm support

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
HtmlSanityCheckMojo.java Added findHtmlFiles() method to recursively discover HTML/HTM files and modified setupConfiguration() to auto-populate sourceDocuments
HtmlSanityCheckMojoTest.java Added comprehensive test suite covering HTTP status code configuration, file discovery scenarios, and edge cases
HtmlSanityCheckTask.groovy Added .htm file pattern to Gradle plugin's auto-population logic
HtmlSanityCheckTaskSpec.groovy Added test to verify .htm files are included in auto-population
Configuration.java Fixed typo in method name from defaultIndeFilenames to defaultIndexFilenames
htmlSanityCheck-maven-plugin/README.adoc Updated documentation to reflect .htm support and corrected XML tag name
htmlSanityCheck-gradle-plugin/README.adoc Updated documentation to reflect .htm support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Oct 29, 2025

Copy link
Copy Markdown

Test Results

123 files  ± 0  123 suites  ±0   3m 39s ⏱️ +17s
498 tests +11  496 ✅ +11  0 💤 ±0   2 ❌ ±0 
638 runs  +11  573 ✅ +11  0 💤 ±0  65 ❌ ±0 

For more details on these failures, see this check.

Results for commit 88a6ffd. ± Comparison against base commit 0c70c6f.

This pull request removes 60 and adds 34 tests. Note that renamed tests count towards both.
                                <a href="http://aim.org">improve</a>' 
                                <a href="http://arc42.de">arc42.de</a> and some more text
                                <a href="https://arc42.org">arc42 over https</a> even more
                                <a href="local-file.jpg">local file</a> again, text
                                <img src="" alt="2">
                                <img src="t.doc" alt="r"> '
    <area shape="circle" coords="0,1,1" href="#test2">
    <area shape="rect" coords="0,0,1,1" href="#id1" >
    <area shape="rect" coords="0,0,1,1" href="#test1" >
    <area shape="rect" coords="0,0,1,1" href="#test1">
…
org.aim42.htmlsanitycheck.check.ImageMapsCheckerSpec ‑ find image map issues [nrOfFindings: 1, imageMapStr: <img src="image1.jpg" usemap="#map1"><map name="map1">
    <area shape="rect" coords="0,0,1,1" href="#id1" >
</map>
<h2 id="foo" >bad header</h2>, msg: ImageMap "map1" refers to missing link "id1"., #4]
org.aim42.htmlsanitycheck.check.ImageMapsCheckerSpec ‑ find image map issues [nrOfFindings: 1, imageMapStr: <img src="image1.jpg" usemap="#map1"><map name="map1">
    <area shape="rect" coords="0,0,1,1" href="#id1" >
</map>
<map name="map1">
    <area shape="rect" coords="0,0,1,1" href="#id1" >
</map>
<h2 id="id1">aim42 header</h2>, msg: 2 imagemaps with identical name "map1" exist., #1]
org.aim42.htmlsanitycheck.check.ImageMapsCheckerSpec ‑ find image map issues [nrOfFindings: 1, imageMapStr: <img src="image1.jpg" usemap="#map1"><map name="map1">
</map>
, msg: ImageMap "map1" has no area tags., #3]
org.aim42.htmlsanitycheck.check.ImageMapsCheckerSpec ‑ find image map issues [nrOfFindings: 1, imageMapStr: <map name="map1">
    <area shape="rect" coords="0,0,1,1" href="#id1" >
</map>
<h2 id="id1">aim42 header</h2>, msg: ImageMap "map1" not referenced by any image., #2]
org.aim42.htmlsanitycheck.gradle.HtmlSanityCheckTaskSpec ‑ should include .htm files when auto-populating sourceDocuments
org.aim42.htmlsanitycheck.html.HtmlPageSpec ‑ can extract alt attributes from imageTag ' <img alt="1" >
                                <img src="" alt="2">
                                <img src="t.doc" alt="r"> '
org.aim42.htmlsanitycheck.html.HtmlPageSpec ‑ detect correct number of external http links in anchors '<a href="http://arc42.org">arc42</a> and some text
                                <a href="http://arc42.de">arc42.de</a> and some more text
                                <a href="https://arc42.org">arc42 over https</a> even more
                                <a href="local-file.jpg">local file</a> again, text
                                <a href="http://aim.org">improve</a>' 
org.aim42.htmlsanitycheck.html.HtmlPageSpec ‑ detect missing alt attributes in imageTag ' <img alt="1" >
                                <img src="" alt="2">
                                <img src="t.doc" alt="r"> '
org.aim42.htmlsanitycheck.html.ImageMapParserSpec ‑ find all areas within map [nrOfAreas: 1, mapName: mymap, htmlBody: <img src="image.gif" usemap="#mymap">
<map name="mymap">
    <area shape="rect" coords="0,0,1,1" href="#test1" >
</map> , #1]
org.aim42.htmlsanitycheck.html.ImageMapParserSpec ‑ find all areas within map [nrOfAreas: 2, mapName: mymap, htmlBody: <img src="image.gif" usemap="#mymap">
<map name="mymap">
    <area shape="rect" coords="0,0,1,1" href="#test1" >
    <area shape="circle" coords="0,1,1" href="#test2">
</map> , #0]
…

♻️ This comment has been updated with latest results.

@ascheman ascheman force-pushed the bugfix/429-maven-sourcedocs-optional branch 2 times, most recently from b474f66 to 2d1b66c Compare October 31, 2025 08:10
@sonarqubecloud

Copy link
Copy Markdown

ascheman and others added 13 commits June 17, 2026 12:45
testcontainers 1.20.6 -> 1.21.4 — Docker Desktop detection.
gradle-git-properties 2.5.3 -> 2.5.4 — Git worktree support.
Maven groupId and all artifactIds are now lowercase, aligning with
Maven conventions and unblocking publication to repositories that
enforce this (notably GitHub Packages).

Old -> New:
  Group           org.aim42.htmlSanityCheck -> org.aim42.htmlsanitycheck
  Gradle plugin   id 'org.aim42.htmlSanityCheck' -> id 'org.aim42.htmlsanitycheck'
  All artifacts   htmlSanityCheck-* -> htmlsanitycheck-*

Internal Gradle project directories (htmlSanityCheck-core/, etc.) and
DSL closure names (htmlSanityCheck { ... }) are unchanged for
readability; only the published coordinates differ.

Each subproject sets base.archivesName explicitly to its lowercase
artifactId; the root maven-publish config picks that up via
artifactId = project.base.archivesName.get().

CHANGELOG carries the migration table with links to the historical
CamelCase artifacts on Maven Central and the Gradle Plugin Portal.
Plugin READMEs gain a prominent [IMPORTANT] admonition pointing at
issue #432 and showing the historical URLs.
The lowercase coordinates introduced by #432 are not yet on the Gradle
Plugin Portal or Maven Central — HSC's BrokenHttpLinksChecker would
fail self-check and the integration tests on the new badge/canonical
URLs in our READMEs and CHANGELOG.

Exclude them with grep-able TODO(#432) markers so the cleanup after
the first release under the lowercase coords is a pure revert:

    grep -rn 'TODO(#432)' integration-test self-check
Add a maven repository named 'GitHubPackages' under publishing
{ repositories { } } so all four artifacts (core, gradle-plugin,
gradle-plugin marker, maven-plugin) can be pushed to
https://maven.pkg.github.com/aim42/htmlSanityCheck.

The repo is only registered when GITHUB_USER and GITHUB_TOKEN are
both set in the env — that way running 'publish' tasks that target
other repositories (mavenLocal, the local integration repo) keeps
working without env vars, and a missing-PAT mistake yields a clear
"task not found" instead of Gradle's cryptic "property
'credentials.username' doesn't have a configured value".

Plugin READMEs gain a "Development versions" section that recommends
GitHub Packages and deprecates JitPack. publishing.adoc gains a
GitHub Packages credentials section and a 'Publish development
snapshot to GitHub Packages' how-to step.
Feature and bugfix branches now publish under their own
branch-slug-SNAPSHOT (e.g. feature-432-add-gh-packages-SNAPSHOT)
so GitHub Packages can hold multiple in-flight branches in parallel
without colliding on a single 2.0.0-rcN coordinate.

Mechanism:

  - Add me.qoomon.git-versioning 6.4.4. For refs matching
    ^(feature|bugfix)/.+ derive version = ${ref}-SNAPSHOT; for tags
    v<version> derive a release version; otherwise fall back to
    gradle.properties.
  - Add a tiny root :printVersion task so shell callers (generate-
    pages, CI) can capture the derived version without parsing build
    output.
  - Propagate -PhtmlSanityCheckVersion to the integration-test child
    Gradle so the gradle-plugin integration test asks for the just-
    published SNAPSHOT, not the static 2.0.0-rcN.
  - generate-pages now captures printVersion and forwards it via -P
    to self-check, so the CI doc-build picks up the SNAPSHOT plugin
    instead of trying to resolve the static version that has not
    been published yet.

SNAPSHOT-resolution plumbing for embedded/integration Maven:

Gradle's publishToRepository writes Maven layout but no
_remote.repositories markers, so Maven's
EnhancedLocalRepositoryManager refuses to resolve SNAPSHOTs that
simply appear in localRepository. Fix both Maven invocations
(htmlSanityCheck-maven-plugin build-time descriptor generation, and
integration-test/maven-plugin) by:

  - declaring build/maven-repo as a 'remote' <repositories> /
    <pluginRepositories> entry with a file:// URL, so Maven goes
    through its download path and writes the origin markers
  - pointing localRepository at a separate .gradle/maven-local-cache
    so the cache lives outside build/ (and survives gradle clean,
    avoiding re-downloading the Maven plugin toolchain on every
    clean build)

The build-time pom.xml gets the absolute repo URL via a
mavenBuildRepoUrl expand binding in generatePom; the integration-
test pom.xml uses Maven's ${project.basedir} since it's loaded
directly.
Daily scheduled workflow that deletes htmlsanitycheck-* SNAPSHOT
versions on GitHub Packages whose branch no longer exists on origin
AND that are older than ORPHAN_RETENTION_DAYS (28).

Policy:
  - Release versions (anything not ending in -SNAPSHOT) are NEVER
    deleted.
  - SNAPSHOTs whose branch still exists on origin are kept regardless
    of age. So an active long-lived feature branch retains all its
    snapshot history.
  - SNAPSHOTs from removed branches stay in a 4-week grace window
    before deletion — covers "I deleted the branch but a colleague
    still consumes the artifact."

Implementation:
  - Slugify active remote branches the same way git-versioning does
    (slashes -> dashes) so 'feature/432-…' matches version
    'feature-432-…-SNAPSHOT'.
  - Iterate the 5 published artifacts (core, cli, gradle-plugin,
    maven-plugin, gradle-plugin marker).
  - Use the auto-injected secrets.GITHUB_TOKEN — no PAT required.
  - workflow_dispatch with a 'dry-run' input for safe tuning before
    enabling production deletes.

Replaces the simpler 'actions/delete-package-versions' approach with
branch-awareness: active branches never lose snapshot history, dead
branches age out cleanly.
Add a publish-gh-packages job to gradle-build.yml that runs after
build-artifacts succeeds and pushes all four artifacts plus the
plugin marker to GitHub Packages.

Triggers only on push events to feature/* or bugfix/* branches —
those are the refs git-versioning rewrites to <slug>-SNAPSHOT
coordinates. develop and main fall through to gradle.properties'
static 2.0.0-rcN and would conflict with already-published
release versions, so we skip them here.

The job uses the auto-injected secrets.GITHUB_TOKEN (no PAT needed
for in-repo publishing) and github.actor as the username. The
conditional credential block in build.gradle picks them up; without
the env vars set (e.g. on PRs from forks) the GitHubPackages repo
isn't registered and the job's gradle invocation would be a no-op,
but the 'if:' gate prevents that path from running at all.
SonarCloud's GitHub Actions rule S7637 flags `uses: …@<tag>` as a
supply-chain risk: a compromised tag could rewrite the action's
implementation on the next workflow run. Pin to the commit SHA the
v4 tag points at today (gradle/actions v4.4.3, commit
48b5f213c81028ace310571dc5ec0fbbca0b2947) and keep a trailing
`# v4.4.3` comment so the version stays human-readable.

Without this, the bugfix/405 PR analysis hits sonar.qualitygate.wait
on the unreviewed-new-hotspot metric and fails the build.
Auto-populate sourceDocuments from sourceDir when not explicitly
configured, matching the behavior of Gradle plugin and CLI.

- Add findHtmlFiles() method to recursively scan for .html files
- Modify setupConfiguration() to auto-populate when sourceDocuments is null
- Add integration test executeWithOnlySourceDir_ShouldSucceed()
- All existing tests pass without regression

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Rename defaultIndeFilenames to defaultIndexFilenames

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update Gradle and Maven plugins to automatically search for both
.html and .htm files when sourceDocuments is not specified.

- Gradle plugin: Add .htm pattern to fileTree includes
- Maven plugin: Update findHtmlFiles() to check for .htm extension
- Update README.adoc in both plugins to document default behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add tests to verify both .html and .htm files are discovered when
sourceDocuments is auto-populated from sourceDir.

- Maven plugin: Test verifies 3 files (.htm, .html, nested .htm)
- Gradle plugin: Test verifies same file discovery pattern
- Both tests confirm recursive directory scanning works for .htm
- Fix Maven README: Use correct <sourceDocument> element name
- All tests pass with no regressions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Increases test count from 10 to 18 tests to improve SonarCloud
coverage for HtmlSanityCheckMojo.

- Add tests for HTTP status code overrides (success/error/warning)
- Add tests for findHtmlFiles() edge cases (null, non-existent, empty)
- Verify non-HTML files are properly ignored
- Refactor setField() helper to shared static method
@ascheman ascheman force-pushed the bugfix/429-maven-sourcedocs-optional branch from 2d1b66c to 88a6ffd Compare June 17, 2026 16:22
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maven Plugin: sourceDocuments are not optional but required

2 participants