Ivy via Nexus proxy

霸气de小男生 提交于 2019-12-02 17:44:21

I don't think such an option exists directly. You could try implementing a chain, and put your Nexus repository ahead of central in that chain. If I understand how chains work correctly (that's a big if), Ivy will check your repository before central, so as long as your repository has the relevant contents central won't be needed.

See the tutorial for details.

You need to create a public resolver that does what you want (more details @ Ivy docs)

Basically save the following snippet under $USERHOME/.ivy2/ivysettings-public.xml. This should do the trick.

<ivysettings> 
  <resolvers> 
    <ibiblio name="public" m2compatible="true" root="http://localhost:8081/content/groups/public"/> 
  </resolvers> 
</ivysettings>
  • The unmodified standard installation has 'nexus' in the URL!
  • If you need to deploy artifacts, I think the solution is to do something similar to the shared resolver (see link to docs above), but I haven't tried.
  • I changed your local URL to resolve to the standard 'content/groups/public' which is better since in the maven settings fragment above you're passing all calls through the mirror, not just the ones to central. Just add any additional repositories to that group in the Nexus UI as they come up and you should be fine.
  • If your project loads it's own ivysettings which doesn't honor the defaults, then these settings will not get loaded and you're again back at zero :(

This is how I made it work (The answer from @Heron did not work for me):

Create a file with this content:

<ivysettings>
  <settings defaultResolver="default"/>
  <property name="m2-pattern" value="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]" override="false" />
  <resolvers>
    <chain name="default">
        <ibiblio name="public" m2compatible="true" root="http://nexus-server:8081/nexus/content/groups/public"/>
    </chain>
  </resolvers>
</ivysettings>

Refere to it from the ant build:

<ivy:settings file="/Users/wdb/.ivy2/ivysettings-public.xml" />

Ivy is now able to resolve dependencies from my nexus repository.

I have done the same but with Archiva, what is very similar. You only have to declare in a new chain the following:

<chain name="private">
<url name="archiva" m2compatible="true">
  <ivy pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/ivy.xml" /> 
  <artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> 
  <artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact].[ext]" /> 
  </url>
</chain>

Archiva manages Maven 2 repositories (artifacts with Maven meta data) there isn't usually Ivy meta data (ivy.xml). And the Maven 2 layout is [organisation]/[module]/[revision]/[artifact]-[revision].[ext].

We have only to provide the following information

<url name="archiva" m2compatible="true">
  <artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> 
  </url>
</chain>

or

  <settings defaultResolver="archiva"/>
  <resolvers>
<ibiblio name="archiva" m2compatible="true" root="http://.../archiva/repository/internal/[organization]/[module]/[revision]/[artifact]-[revision].[ext]"/>
  </resolvers>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!