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

Repositories from settings get replaced by the default repository and m2e wrongly report errors #221

Closed
glhez opened this issue Aug 27, 2021 · 1 comment · Fixed by #222
Milestone

Comments

@glhez
Copy link

glhez commented Aug 27, 2021

Hello,

I am using several remote repositories - four, and some being corporate - and m2e trigger warning about missing dependencies whenever I edit my POM file.

The dependency is inside a corporate repository, whose content is of course not accessible in central.
The dependency was already downloaded by mvn (using mvn clean install...) but somehow, m2e tries to download it again - perhaps to check if it is up to date.

  1. In a previous PR/issue (lemminx-maven completely ignore local settings  #196), I had the same kind of problem with the local repo path, which was overridden by some default value. It failed because I created a file ~/.m2/repository
  2. The repositories are overridden from settings by the "default":
    List<ArtifactRepository> defaultRemoteRepositories = Collections.singletonList(repositorySystem.createDefaultRemoteRepository());
    (this is on master branch)

The code should perhaps be something like:

List<ArtifactRepository> repositories = mavenRequest.getRemoteRepositories()
if (repositories.isEmpty()) repositories.add(defaultRemoteRepositories);
List<ArtifactRepository> pluginRepositories = mavenRequest.getPluginArtifactRepositories()
if (pluginRepositories .isEmpty()) pluginRepositories .add(defaultRemoteRepositories);

However, I fail to understand why this code differ from whatever is done when importing the maven project ? (since I only have this error when editing the pom file).

(I can do a PR to apply the code above)

@mickaelistria
Copy link
Contributor

Sure, please try submitting a PR for this change. Note that usually it's not a good thing to modify the lists that are returned by getters when there is a setter, so the pattern should be more

List<Blah> newValue = new ArrayList<>(mavenRequest.getBlah());
newValue.add(additionalValue);
mavenRequest.setBlah(newValue);

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 a pull request may close this issue.

2 participants