We have both a snapshot and release repositories in Artifactory. All we have to 
do is add "-SNAPSHOT" to the end of the revision and we get the snapshot and 
not the release. Maven does not guarantee you can select which snapshot you 
want. In Maven 3, you can only get the last one.

Here's our ivysettings-pulbic.xml:

<ivysettings>
    <resolvers>
        <ibiblio name="public"
            m2compatible="true"
            checkmodified="true"
            root="http://buildl01.tcprod.local/artifactory/libs-release"; />
    </resolvers>
</ivysettings>

We setup Artifactory so that libs-release is actually a virtual repository 
which includes our local release and snapshot repos (plus a bunch of public 
repos).

--
David Weintraub
[email protected]

perl -e 'print "Just another second rate Perl Hacker\n";'

On Feb 12, 2014, at 1:35 PM, KARR, DAVID <[email protected]> wrote:

> I've been struggling for a while trying to figure out how to get Ivy to 
> download a snapshot artifact.  I originally posted a question about this on 
> StackOverflow last week.  I got some good responses, but I'm not getting any 
> more traction on this.  I wanted to start over with a new post here 
> summarizing what I know so far.
> 
> The crux of the problem appears to be that when my Maven build uploads a 
> snapshot artifact, it gets stored in the Nexus repository with a timestamp in 
> the name.  When Ivy resolves and retrieves this artifact, the resolve 
> succeeds, but it doesn't retrieve because the file names don't match what is 
> configured in the Ivy repository definition.  I don't understand how to 
> configure the repository definition so this will work.
> 
> I'll describe my configuration verbally, then show the files that specify 
> this.
> 
> My app has 9 dependencies, 7 of which I get from Central, 1 of which I get 
> from our thirdparty repo on our local "MavenCentral" (it's an intranet Nexus 
> Pro instance with a confusing name), and the one dependency I'm trying to get 
> from the snapshot repo on the same Nexus Pro instance.  The other 8 
> dependencies, including the one from the thirdparty repo on the intranet 
> Nexus Pro instance, resolve and retrieve without error.
> 
> I define four resolvers in my resolver chain:
> * Local Maven repo
> * Snapshots repo on Nexus Pro instance
> * Thirdparty repo on Nexus Pro instance
> * Central
> 
> I have one build target that resolves and retrieves all the dependencies.
> 
> If I look inside my Nexus Pro instance at the two artifacts I get from there 
> (one thirdparty, and one snapshot), I see the following off of the root 
> directory specified in the repository definition in my ivysettings.xml file:
> 
> com/oracle/coherence/12.1.2-0-0/coherence-12.1.2-0-0.jar
> 
> This downloads fine.
> 
> However, in the snapshot repo, I see files like this:
> 
> /com/att/ecom/poc/poc-domain-model/0.0.1-SNAPSHOT/poc-domain-model-0.0.1-20131206.234206-76.jar
> /com/att/ecom/poc/poc-domain-model/0.0.1-SNAPSHOT/poc-domain-model-0.0.1-20140210.184009-86.jar
> 
> Ivy fails to download this artifact.
> 
> (I also wonder if Ivy can possibly know to try to get the snapshot with the 
> newest timestamp.)
> 
> Here are some excerpts from my configuration:
> 
> build.xml:
> ---------------
> <target name="install-dependencies">
>      <ivy:resolve transitive="false" type="jar"/>
>      <ivy:retrieve conf="*" type="jar" 
> pattern="${basedir}/lib/[artifact]-[type]-[revision].[ext]"/>
>    </target>
> ---------------
> 
> ivy.xml:
> ---------------
> <ivy-module version="2.0">
>  <info organisation="com.att.ecom.poc" module="coherence_poc"/>
>  <dependencies>
>    <dependency org="com.att.ecom.poc" name="poc-domain-model" 
> rev="0.0.1-SNAPSHOT"/>
>    <dependency org="org.apache.commons" name="commons-lang3" rev="3.1"/>
>    <dependency org="org.springframework" name="spring-aop" 
> rev="4.0.0.RELEASE"/>
>    <dependency org="org.springframework" name="spring-beans" 
> rev="4.0.0.RELEASE"/>
>    <dependency org="org.springframework" name="spring-context" 
> rev="4.0.0.RELEASE"/>
>    <dependency org="org.springframework" name="spring-core" 
> rev="4.0.0.RELEASE"/>
>    <dependency org="org.springframework" name="spring-expression" 
> rev="4.0.0.RELEASE"/>
>    <dependency org="org.springframework" name="spring-web" 
> rev="4.0.0.RELEASE"/>
>    <dependency org="com.oracle.coherence" name="coherence" rev="12.1.2-0-0"/>
>  </dependencies>
> </ivy-module>
> -------------------
> 
> ivysettings.xml:
> -------------------
> <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">
>            <filesystem name="local-maven2" m2compatible="true" >
>                <artifact pattern="${m2-pattern}"/>
>                <ivy pattern="${m2-pattern}"/>
>            </filesystem>
>            <ibiblio name="mavenCentralSnapshots" m2compatible="true"
>                    
> root="http://mavencentral/nexus/content/repositories/cditspoc-snapshots"/>
>            <ibiblio name="mavenCentralThirdparty" m2compatible="true"
>                    
> root="http://mavencentral/nexus/content/repositories/cditspoc-3rd-party"/>
>            <ibiblio name="central" m2compatible="true"/>
>        </chain>
>    </resolvers>
> </ivysettings>
> -------------------
> 
> This is an excerpt from my IvyDE console in Eclipse (shouldn't I be able to 
> get this output in some way from the command-line build?):
> -----------------------------
> Sort done for : com.att.ecom.poc#poc-domain-model;0.0.1-SNAPSHOT
> storing dependency com.att.ecom.poc#poc-domain-model;0.0.1-SNAPSHOT in props
>       resolved ivy file produced in cache
> :: downloading artifacts ::
>        trying 
> C:\Users\myhome\.ivy2\shared\com.att.ecom.poc\poc-domain-model\0.0.1-SNAPSHOT\bundles\poc-domain-model.jar
>               tried 
> C:\Users\myhome\.ivy2\shared\com.att.ecom.poc\poc-domain-model\0.0.1-SNAPSHOT\bundles\poc-domain-model.jar
>       shared: resource not reachable for 
> com.att.ecom.poc#poc-domain-model;0.0.1-SNAPSHOT: 
> res=C:\Users\myhome\.ivy2\shared\com.att.ecom.poc\poc-domain-model\0.0.1-SNAPSHOT\bundles\poc-domain-model.jar
>       maven-metadata not available: 
> http://repo1.maven.org/maven2/com/att/ecom/poc/poc-domain-model/0.0.1-SNAPSHOT/maven-metadata.xml
>        trying 
> http://repo1.maven.org/maven2/com/att/ecom/poc/poc-domain-model/0.0.1-SNAPSHOT/poc-domain-model-0.0.1-SNAPSHOT.jar
>               tried 
> http://repo1.maven.org/maven2/com/att/ecom/poc/poc-domain-model/0.0.1-SNAPSHOT/poc-domain-model-0.0.1-SNAPSHOT.jar
>       public: resource not reachable for 
> com/att/ecom/poc#poc-domain-model;0.0.1-SNAPSHOT: 
> res=http://repo1.maven.org/maven2/com/att/ecom/poc/poc-domain-model/0.0.1-SNAPSHOT/poc-domain-model-0.0.1-SNAPSHOT.jar
> WARN:         [FAILED     ] 
> com.att.ecom.poc#poc-domain-model;0.0.1-SNAPSHOT!poc-domain-model.jar(bundle):
>   (0ms)
> WARN: ==== shared: tried
> WARN:   
> C:\Users\myhome\.ivy2\shared\com.att.ecom.poc\poc-domain-model\0.0.1-SNAPSHOT\bundles\poc-domain-model.jar
> WARN: ==== public: tried
> WARN:   
> http://repo1.maven.org/maven2/com/att/ecom/poc/poc-domain-model/0.0.1-SNAPSHOT/poc-domain-model-0.0.1-SNAPSHOT.jar
> -----------------------
> 
> What's curious from this output is that it never even attempts to download 
> the artifact from the Nexus Pro snapshots repo.  It never even tried that 
> repository.

Reply via email to