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

Apache Maven API doesn't use third party repositories #927

Closed
kobmik opened this issue Oct 6, 2023 · 8 comments
Closed

Apache Maven API doesn't use third party repositories #927

kobmik opened this issue Oct 6, 2023 · 8 comments
Milestone

Comments

@kobmik
Copy link

kobmik commented Oct 6, 2023

Camel Catalog downloader in version 1.1.0 doesn't work properly for me. I've added a third party repository to my pom.xml.
It seems that CamelService finds the repository in pom.xml, but still wants to download the catalog from repo1.maven.org.
(Maven repo is blocked in our company)

Should the API also work, if I set repo only in settings.xml?
According to the Camel Plugin logs:

  • .m2/settings.xml => Camel Plugin doesn't recognize these repositories (repo is listed in the effective POM)
  • pom.xml => Camel Plugin recognizes the repo, but still use repo1.maven.org

Logs:

INFO - #com.github.cameltooling.idea.service.CamelService - Found third party Maven repository id: central url:https://artifactory/...
FINE - #com.github.cameltooling.idea.service.CamelMavenVersionManager - Trying to load the catalog version: 3.21.1
WARN - #com.github.cameltooling.idea.service.CamelMavenVersionManager - Could not load the catalog version 3.21.1: org.apache.camel.tooling.maven.MavenResolutionException: The following artifacts could not be resolved: org.apache.camel:camel-catalog:jar:3.21.1 (absent): Could not transfer artifact org.apache.camel:camel-catalog:jar:3.21.1 from/to central (https://repo1.maven.org/maven2)...

@essobedo
Copy link
Contributor

essobedo commented Oct 6, 2023

Do you have your custom repo defined in your .m2/settings.xml ?

@essobedo
Copy link
Contributor

essobedo commented Oct 6, 2023

The repository https://repo1.maven.org/maven is automatically added to the list of repositories to query. So far, there is no way to prevent that, but it is supposed to also to query the repositories defined in your .m2/settings.xml and your pom.xml files. If it cannot find the artifact in any of them, then you will get the error corresponding to the first repository that it tried which is repo1.maven.org here, it doesn't necessarily mean that it is the only one it tried.

Could you please clarify a bit more about the behavior that you get? Are you sure that the artifact is in your custom repository?

@kobmik
Copy link
Author

kobmik commented Oct 9, 2023

Yes, our internal repository is listed in .m2/settings.xml.
But according to the logs, it looks like the plugin doesn't recognize the third party repository.
If I add it to the pom.xml, I get the following log entry:
INFO - #com.github.cameltooling.idea.service.CamelService - Found third party Maven repository id: central url:https://artifactory/...
But the plugin still doesn't try to download it from there. The artifact (camel-catalog) is available in our custom repository.

@essobedo
Copy link
Contributor

essobedo commented Oct 9, 2023

I tried to reproduce your very specific use case but without success.
What results do you get when you launch the command mvn dependency:get -Dartifact=org.apache.camel:camel-catalog:3.21.1:jar -DremoteRepositories=<URL of your custom repository here> ?

@kobmik
Copy link
Author

kobmik commented Oct 9, 2023

I get the following result within the IDE with your command:

[ERROR] Plugin .apache.camel:camel-catalog:3.21.1 or one of its dependencies could not be resolved: The following artifacts could not be resolved: .apache.camel:camel-catalog:jar:3.21.1 (absent): Could not find artifact .apache.camel:camel-catalog:jar:3.21.1 in central (https://artifactory...

When I put quotation marks around the artifact, the download does work as expected.
So connectivity and permission to the third party repository should be fine inside IntelliJ.

@essobedo
Copy link
Contributor

I did my best to reproduce your use case by blocking repo1.maven.org on my local machine but I still cannot reproduce your issue, I could only improve a bit more the way to manage the third-party maven repositories with #933 but it should not change much for you.
Indeed if I block repo1.maven.org, I can see that the plugin cannot download the catalog but if I add my custom maven repository in .m2/settings.xml and/or in the pom.xml of my project, it then can download the catalog as expected.

If with the latest changes, the plugin cannot download the catalog on your side, I encourage you to submit a PR if you can because I don't see what I can do.

essobedo added a commit that referenced this issue Oct 11, 2023
## Motivation

Some operations such as the automatic download of the Camel Debugger don't consider third-party maven repositories. Moreover, third-party maven repositories are only detected in maven projects, it should be improved to support Gradle projects too.

## Modifications:

* Delegates the extraction of third-party maven repositories to `MavenArtifactRetrieverContext` to make sure that all operations take them into account
* Provides a way to retrieve the list of maven repositories from Gradle project
* Retrieves the list of maven repositories from Maven project using the Maven model instead of using the DOM API
* Removes all DOM-related classes as they are no longer used 
* Moves all Gradle-related classes into a `gradle` package
* Moves all Maven-related classes into a `maven` package
@davsclaus davsclaus added this to the 1.1.2 milestone Oct 11, 2023
@kobmik
Copy link
Author

kobmik commented Oct 12, 2023

Alright, will try it as soon as it has been released. Thanks for your time so far.

@davsclaus
Copy link
Collaborator

Can you try the new 1.1.2 release

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

No branches or pull requests

3 participants