Repository navigation
Conversation
src/published-addresses.txt lists every page the site has published, with the ids on each page that a link can point at, recorded from a build of master. After site:site, Addresses.java follows each address through the .htaccess files of the rendered site the way httpd does, and fails the build when one leads to no page, or to a page without the anchor. Redirects into the component sites that the components.links files link in, and to download.cgi, are not followed further. A failure says how to fix it, and writes the Redirect line for a page that moved as a whole. New pages are reported; -Daddresses=record adds them to the list and then checks. A how-to, developers/website/move-a-page, covers each kind of change; the failure message, the Deploy Maven Website menu, that section's index page and the README link to it. Closes apache#1771 Generated-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
elharo
left a comment
There was a problem hiding this comment.
Interesting. What is the implication for the CI? Will the CI fail if a page external to this repo moves or vanishes?
There was a problem hiding this comment.
🟡 Changes recommended
Check mode can incorrectly succeed with a missing or empty published-address baseline, while redirect validation gaps also allow broken destinations and anchors to pass.
4 open issues
What changed in this PR
Adds a build-time safeguard for Maven website URLs and section anchors, addressing #1771 and helping prevent regressions like the anchors restored in #1767.
Changes:
- Adds a redirect-aware checker and record mode, backed by a baseline of 795 published addresses.
- Runs the checker during
mvn site. - Documents how to preserve, redirect, or deliberately retire published addresses and anchors.
| File | Description |
|---|---|
src/published-addresses.txt |
Records published addresses and their anchors. |
src/main/java/org/apache/maven/site/check/Addresses.java |
Implements address recording, redirect resolution, and validation. |
README.md |
Introduces the check and links to maintenance guidance. |
pom.xml |
Integrates the checker and excludes its baseline from RAT. |
content/site.xml |
Adds the how-to page to site navigation. |
content/markdown/developers/website/move-a-page.md |
Explains address preservation and checker diagnostics. |
content/markdown/developers/website/index.md |
Links website maintainers to the new guidance. |
Review effort: Balanced
| } | ||
| break; | ||
| case "check": | ||
| if (addresses.check(known) > 0) { |
There was a problem hiding this comment.
Fixed in 2bf8ebf: check mode now fails when the list is missing or lists no address, and says to create it with -Daddresses=record. Record mode still starts from an empty list.
| String dir = path.endsWith("/") ? path : Files.isDirectory(file(path)) ? path + "/" : null; | ||
| if (dir != null) { | ||
| path = dir + "index.html"; | ||
| if (!Files.exists(file(path)) && Files.isDirectory(file(dir))) { | ||
| // the server lists a directory without an index page | ||
| o.path = dir; | ||
| return o; | ||
| } | ||
| } | ||
| o.path = path; | ||
| if (!Files.exists(file(path))) { | ||
| if (isOutside(path)) { | ||
| o.outside = true; | ||
| } else { | ||
| o.problem = o.hops.isEmpty() | ||
| ? "does not exist, and no redirect leads away from it" | ||
| : "leads to " + path + ", which does not exist"; | ||
| } | ||
| } else if (o.anchor != null && path.endsWith(".html") && !idsOf(path).contains(o.anchor)) { | ||
| o.problem = "leads to " + path + "#" + o.anchor + ", which lacks that anchor"; | ||
| } |
There was a problem hiding this comment.
Fixed in 2bf8ebf: a directory listing now goes through the same anchor check, and a file that is not a page has no anchors, so /images/maven.png#Missing is reported as lacking that anchor.
|
|
||
| /** True when path is in a part of the server that another build writes, or the download script. */ | ||
| private boolean isOutside(String path) { | ||
| if (path.endsWith(".cgi")) { |
There was a problem hiding this comment.
Fixed in 2bf8ebf: only a download.cgi counts as written by another build (the root one, and the per-component ones that RedirectMatch ^/(.*)/download.html$ sends to). A redirect to /missing.cgi is now reported as leading to a file that does not exist.
| continue; | ||
| } | ||
| // a redirect with an anchor of its own sends every link to that anchor; follow() checked it | ||
| if (!a.getValue().isEmpty() && o.anchor == null && o.path.endsWith(".html")) { |
There was a problem hiding this comment.
Fixed in 2bf8ebf: the anchors of a page are checked whatever the destination is; a non-HTML file or a directory listing has none, so a page with anchors redirected to /images/maven.png is reported with every anchor it loses. The current site still passes: 795 addresses, 0 broken.
From the review of apache#1772: - check mode fails when src/published-addresses.txt is missing or lists no address, instead of passing with nothing checked; - a file that is not a page, or a directory listing, has no anchors: a redirect's own anchor to it, and the anchors of a page redirected to it, are reported as missing instead of skipped; - only a download.cgi script counts as written by another build, not every missing .cgi. Generated-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@elharo Nothing outside this repository can make CI fail.
What does fail CI is a change in this repository that leaves a published address or anchor leading nowhere: deleting or renaming a page, or dropping the id of a heading, without a redirect or a |
| - on every main content source commit ([maven-site.git](https://github.com/apache/maven-site), main content rebuild and publish is triggered through Jenkins jobs ([maven-site job](https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-site/), which basically run `mvn site-deploy` (it can be run locally if CI is off...), | ||
| - on every Maven component release, release manager follows "[deploying Maven components reference documentation](./deploy-component-reference-documentation.html)", eventually using [Component Reference Documentation Helper](./component-reference-documentation-helper.html) to easily prepare `svnmucc` command line. | ||
|
|
||
| # Moving or removing a page |
There was a problem hiding this comment.
This section doesn't seem to fit here outside the context of this PR, or at least it's incomplete.
|
|
||
| # Moving or Removing a Page | ||
|
|
||
| Links to maven.apache.org live in bookmarks, answers on forums, other sites and Maven's own messages. Every page and every section anchor the site has published is listed in `src/published-addresses.txt`, and `mvn site` fails when one of them no longer leads to its page or anchor. The Verify Site workflow runs it on every pull request; `mvn site:run` does not. |
|
|
||
| # Moving or Removing a Page | ||
|
|
||
| Links to maven.apache.org live in bookmarks, answers on forums, other sites and Maven's own messages. Every page and every section anchor the site has published is listed in `src/published-addresses.txt`, and `mvn site` fails when one of them no longer leads to its page or anchor. The Verify Site workflow runs it on every pull request; `mvn site:run` does not. |
There was a problem hiding this comment.
I don't know you need to mention mvn site:run here
| String best = null; | ||
| int most = 0; | ||
| boolean tie = false; | ||
| for (Map.Entry<String, Set<String>> p : published.entrySet()) { |
There was a problem hiding this comment.
p is what exactly? no single letter variable names
| } | ||
| // a redirect with an anchor of its own sends every link to that anchor; follow() checked it. | ||
| // A file that is not a page, or a directory listing, has no anchors. | ||
| if (!a.getValue().isEmpty() && o.anchor == null) { |


Closes #1771.
Adds a check to
mvn sitethat every address the site has published still leads to its page and anchors, through the redirects in.htaccess. The background, and the run that finds the 17 anchors #1767 restored, are in #1771.src/main/java/org/apache/maven/site/check/Addresses.java: the check (check) and the list update (record, which then checks too). A single-file Java tool on jsoup, run by exec-maven-plugin in thesitephase, soverify-site.ymlruns it on every pull request. Redirects into the component sites that thecomponents.linksfiles link in, and todownload.cgi, are not followed further.src/published-addresses.txt: every address of master at c39e862 with its anchors, plus the new how-to page: 795 in all. Excluded from RAT.content/markdown/developers/website/move-a-page.md: a how-to for each kind of change (move or rename a page, rename or merge a section, move a section to another page, remove a page or section, add a page) and how to read the check's output. The failure message links to it. It is in the Deploy Maven Website menu and linked from that section's index page and the README.pom.xml: theaddressesproperty and the exec execution.To try it yourself:
The build passes, with:
Use
clean: without it,target/sitekeeps the pages of the previous build, and a page you moved still seems to be at its old address.Take back the 17 anchors that #1767 restored:
The build fails with:
Rename a page without a redirect:
The build fails with:
I compared the check with httpd 2.4 serving the built site with these .htaccess files: about 3,700 addresses per run (the listed ones, variants of them and of every redirect source, and strings generated from every
RedirectMatchpattern), ten runs with different seeds. The two agree on every address.What the check cannot see is inside the component sites.
/reference/maven-classloading.htmlredirects into/archives/maven-1.x/, which another build publishes, and the page is not there (#1525); the check counts that redirect as leaving this build.To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
check one of the following:
🤖 Generated with Claude Code