Skip to content

Check that every published address and anchor keeps working - #1772

Open
dashorst wants to merge 2 commits into
apache:masterfrom
dashorst:address-check
Open

dashorst wants to merge 2 commits into
apache:masterfrom
dashorst:address-check

Conversation

@dashorst

@dashorst dashorst commented Nov 1, 2026 •

Copy link
Copy Markdown

Closes #1771.

Adds a check to mvn site that 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 the site phase, so verify-site.yml runs it on every pull request. Redirects into the component sites that the components.links files link in, and to download.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: the addresses property and the exec execution.

To try it yourself:

git fetch https://github.com/dashorst/maven-site.git address-check
git checkout -b address-check FETCH_HEAD
mvn clean verify site

The build passes, with:

Addresses: 795 published, 2 redirected, 2 to sites outside this build, 0 retired, 0 broken

Use clean: without it, target/site keeps 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:

git revert --no-commit e399db52
mvn clean site
git revert --abort

The build fails with:

Addresses: 795 published, 2 redirected, 2 to sites outside this build, 0 retired, 3 broken
  /guides/mini/guide-creating-archetypes.html lacks #a4._Install_the_archetype_and_run_the_archetype_plugin
  /guides/mini/guide-http-settings.html lacks #Configuring_GET.2C_HEAD.2C_PUT.2C_or_All_of_the_Above #Connection_Timeouts #Example.3A_Lifting_auth_scope_restriction_for_external_authentication_systems #Example.3A_Using_Preemptive_Authentication #Fine-Tuning_HttpClient_Parameters #HTTP_Headers #Ignoring_Cookies #Introduction #Non-String_Parameter_Values #Read_time_out #Support_for_General-Wagon_Configuration_Standards #Taking_Control_of_Your_HTTP_Headers #The_Basics
  /guides/mini/guide-wagon-providers.html lacks #Available_Wagon_Providers #Command-Line_Configuration #settings.xml_Configuration
To fix a broken address, do one of these:
  - redirect it to its new place: Redirect Permanent <old> <new> in content/filtered-resources/.htaccess
  - put a dropped anchor back above the section that holds its content: <a id="a4._Install_the_archetype_and_run_the_archetype_plugin"></a>
  - retire it on purpose: Redirect gone <old>, or delete the anchor from src/published-addresses.txt
See https://maven.apache.org/developers/website/move-a-page.html

Rename a page without a redirect:

git mv content/markdown/guides/mini/guide-java-target.md content/markdown/guides/mini/guide-java-version.md
mvn clean site
git mv content/markdown/guides/mini/guide-java-version.md content/markdown/guides/mini/guide-java-target.md

The build fails with:

Addresses: 795 published, 2 redirected, 2 to sites outside this build, 0 retired, 1 broken
  /guides/mini/guide-java-target.html does not exist, and no redirect leads away from it
      it moved to /guides/mini/guide-java-version.html, which has 5 of its 5 anchors:
      Redirect Permanent /guides/mini/guide-java-target.html /guides/mini/guide-java-version.html
To fix a broken address, do one of these:
  - redirect it to its new place: Redirect Permanent <old> <new> in content/filtered-resources/.htaccess
  - put a dropped anchor back above the section that holds its content: <a id="..."></a>
  - retire it on purpose: Redirect gone <old>, or delete the anchor from src/published-addresses.txt
See https://maven.apache.org/developers/website/move-a-page.html

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 RedirectMatch pattern), ten runs with different seeds. The two agree on every address.

What the check cannot see is inside the component sites. /reference/maven-classloading.html redirects 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

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 elharo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting. What is the implication for the CI? Will the CI fail if a page external to this repo moves or vanishes?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Comment on lines +279 to +299
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";
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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")) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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")) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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>
@dashorst

Copy link
Copy Markdown
Author

@elharo Nothing outside this repository can make CI fail.

  • The check reads only the rendered target/site and the .htaccess files in it. It makes no network requests.
  • It only knows the addresses this repository has published, listed in src/published-addresses.txt. Pages of the component sites (the plugins, /ref/, /resolver/, and so on) are not on that list.
  • A redirect into a part of the server that another build writes is not followed further: the paths in the components.links files, /components/, and the download.cgi scripts. The summary counts it as "to sites outside this build", never as broken. If a plugin site moves or drops a page, this build doesn't notice.

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 Redirect gone. The check runs in the site phase, so it fails both the PR workflow (verify site) and the Jenkins site/site-deploy job, and it prints the Redirect line or anchor to add. A new page never fails it; it is only reported as not on the list yet. If the check is ever in the way, -Dexec.skip skips it; it is the only exec execution in a normal site build.

- 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

other sites,


# 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a and o are what?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check in the build that every published address and anchor keeps working

3 participants