Skip to content

Proposal to fix support for mirrors - #399

Merged
cstamas merged 5 commits into
masterfrom
reuse-not-redo
Feb 4, 2026
Merged

Proposal to fix support for mirrors#399
cstamas merged 5 commits into
masterfrom
reuse-not-redo

Conversation

@cstamas

@cstamas cstamas commented Jan 31, 2026

Copy link
Copy Markdown
Member

This change relies on reusing existing API that can return proper URL (as set by user by ANY means in Maven config) to resolve from. PR contains also some cleanup.

Fixes #396
Supersedes #397

This change relies on reusing existing API that
can return proper URL (as set by user by ANY means
in Maven config) to resolve from.

Moreover, if repo ID is made configurable as well,
it could be used to pull (needs more code) reposes
like ID "my-corpo-repo" from settings and use that
instead.
@cstamas cstamas mentioned this pull request Jan 31, 2026
8 tasks
@yeikel

yeikel commented Jan 31, 2026

Copy link
Copy Markdown

Thank you for this, If this is better solution I am all for it.

Moreover, if repo ID is made configurable as well, it could be used to pull (needs more code; for that you would need to pull exec req repo by ID, and use that instead, and not craft central RemoteRepository instance) reposes like ID "my-corpo-repo" from settings and use that instead.

Sorry, I’m not familiar with this and I’m unsure what the next steps are or what you mean with this.

For what is worth, I built and tested this locally and it seems to fix my original bug report, so I'd be happy to have this as an starting solution

[INFO] --- wrapper:3.3.5-SNAPSHOT:wrapper (default-cli) @ simudyne-maven-java ---
[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:3.3.5-SNAPSHOT
[INFO] Determined repo URL to use as https://maven-central.storage.googleapis.com/maven2
[INFO] Configuring .mvn/wrapper/maven-wrapper.properties to use Maven 3.9.9 and download from https://maven-central.storage.googleapis.com/maven2

@cstamas

cstamas commented Feb 4, 2026

Copy link
Copy Markdown
Member Author

From ASF CI:

Caused by: java.security.cert.CertificateNotYetValidException: NotBefore: Tue Feb 03 22:19:18 UTC 2026
    at sun.security.x509.CertificateValidity.valid (CertificateValidity.java:178)
    at sun.security.x509.X509CertImpl.checkValidity (X509CertImpl.java:534)
    at sun.security.provider.certpath.BasicChecker.verifyValidity (BasicChecker.java:190)

Weird.

@cstamas
cstamas marked this pull request as ready for review February 4, 2026 12:43

@ExtendWith(MockitoExtension.class)
class WrapperMojoTest {
private final RepositorySystem repositorySystem;

@manandbytes manandbytes Feb 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To fully utilize Mockito Extension, IIRC:

  • @org.mockito.Mock on non-final RepositorySystem and mockRepositorySystemSession, no need to initialize them
  • no need to initialize wrapperMojo
  • WrapperMojoTest() should became @BeforeEach void setUp(), method name could be any
  • any(RepositorySystemSession.class) sould become same(mockRepositorySystemSession)

But this would fail userSuppliedRepoUrlGetsTrailingSlashTrimmed with:

org.mockito.exceptions.misusing.UnnecessaryStubbingException: 
Unnecessary stubbings detected.
Clean & maintainable test code requires zero unnecessary code.
Following stubbings are unnecessary (click to navigate to relevant line of code):
  1. -> at org.apache.maven.plugins.wrapper.WrapperMojoTest.setUp(WrapperMojoTest.java:45)
Please remove unnecessary stubbings or use 'lenient' strictness. More info: javadoc for UnnecessaryStubbingException class.

To fix this, @Mock(strictness = Mock.Strictness.LENIENT) RepositorySystem mockRepositorySystem

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks!

@cstamas
cstamas requested a review from manandbytes February 4, 2026 19:41
@cstamas
cstamas merged commit 8132e06 into master Feb 4, 2026
38 checks passed
@cstamas
cstamas deleted the reuse-not-redo branch February 4, 2026 20:40
@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

@cstamas Please assign appropriate label to PR according to the type of change.

@github-actions github-actions Bot added this to the 3.3.4 milestone Feb 4, 2026
@cstamas cstamas added the enhancement New feature or request label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for the central mirror

4 participants