Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make user-defined repository parameter of ArtifactResolver constructor work #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ufolr
Copy link

@ufolr ufolr commented Oct 3, 2020

Sometimes the local maven repo may not be ~/.m2/repository .
And In my area, by some network reason we can't connect to the official maven repo, or the official repo is too slow to use. I have to use a mirror repo to speed up the downloading.

When I construct an ArtifactResolver Object with user-defined local repository and remote repository mirror, it can't resolve the pom.

    String localRepo = "D:/Maven/.m2/repo";
    String mavenCenterMirror = "http://mirrors.cloud.tencent.com/nexus/repository/maven-public/";
    ArtifactResolver artifactResolver = new ArtifactResolver(localRepo, mavenCenterMirror);
    File pomFile = new File("src/test/poms/maven-core-3.0.4.pom");

Here is a full test code to replay the issue #20

I find this is because, in function MavenProject getMavenProject(File pomFile), it always use the default repository

request.setLocalRepository(lrs.createDefaultLocalRepository());
request.setRemoteRepositories(Arrays.asList(new ArtifactRepository[] {lrs.createDefaultRemoteRepository()}.clone()));

So I make this PR to set the user-defined repositories to the request, and I exchange the order of repositories handle to make sure the user-defined remote repository to use first.

Set the custom local and remote repository to the  ProjectBuildingRequest when get pom's MavenProject.
@ufolr ufolr changed the title Fix custom repository Make user-defined repository parameter of ArtifactResolver constructor work Oct 9, 2020
@ufolr
Copy link
Author

ufolr commented Oct 9, 2020

By doing this, we can make below Plugin Config property of presto work.

maven.repo.local
maven.repo.remote

Please take a look @electrum

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.

1 participant