1
votes

Ok; my first stackoverflow question.

I have been trying to use our local Nexus to download artifacts from and to retrieve those artifacts automatically from an outer repositories in case they don't exist. and CACHE them in the way.

I am using Ant and Ivy to handle the dependency.

More or less the question is similar to this question: Ivy via Nexus proxy The ultimate answer to my understanding did enable the use of nexus as a repository but it didn't cache (at least not for me).

I have seen lots of material hovering around the subject but nothing of the exact nature (and sadly I couldn't figure it out).

So let me wrap it up. I am using the local nexus repository using a url resolver, because we should use a URL if we need to publish (read that somewhere):

<chain name="deploy-chain">
    <url
        name="nexus"
        m2compatible="true"
    >
        <artifact pattern="${nexus.host}/${nexus.pattern}" />
        <ivy pattern="${nexus.host}/${nexus.ivy.pattern}" />
    </url>

    <ibiblio
        name="maven.public"
        m2compatible="true"
    />
</chain>

The ivy.xml and build.xml are very standard.

So, is it possible to do this using Ivy or is this a nexus issue?

Is it a good practice to publish the artifacts (designated ant target) to Nexus after I retrieve the artifacts in my cache or local repository? (it seems like a really bad practice, but the only option is always a great option)

Is this a misuse of the tools?

1

1 Answers

2
votes

The ibiblio resolver is the best way to configure a Maven repository.

The following ivysettings.xml file configures ivy to pull it's dependencies Nexus.

<ivysettings>
    <settings defaultResolver="central-proxy"/>
    <resolvers>
        <ibiblio name="central-proxy" m2compatible="true" root="http://mynexushost/nexus/content/repositories/central/"/>
        <ibiblio name="release-repo"  m2compatible="true" root="http://mynexushost/nexus/content/repositories/releases/"/>
    </resolvers>
</ivysettings>

The "central-proxy" resolver is configured to pull content from the default Maven Central proxy repository that comes by default in Nexus.

The "release-repo" resolver can be used when publishing content to the Nexus release repository.