1
votes

I am using eclipse, maven and artifactory. My artifactory installation mirrors maven central (https://repo1.maven.org/maven2/ is added as a remote repository in artifactory).

When I search for maven dependencies inside eclipse I rarely get any result and need to add them manually (which works fine). It seems that the index only contains dependencies that I have already installed instead of looking up in maven central:

enter image description here

I would expect more hits under org and there should also be more versions of spring-webmvc (see maven central).

I have tried to rebuild the indexes:

enter image description here

but it has no effect. Have I missed the purpose of maven dependency search in eclipse?

As I wrote I am using artifactory to mirror maven central and have configured that in my ~/.m2/settings.xml file (replaced real info with dummy info)

<?xml version="1.0"?>
<settings>
  <mirrors>
    <mirror>     
      <id>artifactory</id>
      <name>Maven Repository</name>
      <mirrorOf>*</mirrorOf>
      <url>http://myhost/artifactory/simple</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>artifactory</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
<servers>
    <server>
      <id>releases</id>
        <username>admin</username>
        <password>bla</password>
    </server>
    <server>
      <id>snapshots</id>
        <username>admin</username>
    <password>bla</password>
    </server>
    <server>
      <id>thirdparty</id>
        <username>admin</username>
        <password>bla</password>
    </server>
    <server>
      <id>artifactory</id>
      <username>admin</username>
      <password>bla</password>
    </server>
  </servers>
</settings>

As suggested below I have removed the proxy configuration in AF. I still have the remote repository that points to maven-central:

enter image description here

No proxy is configured for this remote repository. Further I have created a virtual repository that contains the above remote repository:

enter image description here

Its this virtual repository that I have in my ~/.m2/settings.xml file on my local machine:

<mirror>     
  <id>artifactory</id>
  <name>Maven Repository</name>
  <mirrorOf>*</mirrorOf>
  <url>http://myhost/artifactory/simple</url>
</mirror>

I also enabled the maven indexer:

enter image description here

and triggered a run but it has no effect, I still don't get any search hits in maven-central from within eclipse except the ones that I already have locally in ~/.m2/repository.

So it still seems that search for dependencies inside eclipse will only include artifacts locally stored on your machine.

2

2 Answers

1
votes

It seems that you accidentally mixed the Artifactory concepts of proxy and remote repository.
A proxy configuration in Artifactory is intended for organizations which are using a corporate proxy for accessing the internet. It looks like you configured it with intention to proxy the Maven central repository.
What you should do instead is configure the maven-central remote repository you created to proxy maven central:

enter image description here

In addition you should remove the proxy configuration, unless you need to pass a corporate proxy. In this case you should configure the correct host and credentials.
Once the remote repository is properly configured, Eclipse should be able to download the Maven index from Maven central and perform searches.
If you also need to search for artifacts in local repositories using Eclipse, you will need to enable Maven indexing in Artifactory.

0
votes

According to Maven, Guide to Mirror Settings, Using A Single Repository:

The repository must contain all of the desired artifacts, or be able to proxy the requests to other repositories. This setting is most useful when using an internal company repository with the Maven Repository Manager to proxy external requests.

[Emphasizing by me.]

The aforementioned proxy is called Remote Repository in Artifactory:

To configure a remote repository, in the Admin module, go to Repositories | Remote and click it to display the Edit Repository screen.

If this is established M2Eclipse is able to:

  • Quick search for dependencies in Maven remote repositories