mautrok
mautrok

Reputation: 961

ivy resolve dependencies from different settings

i have configured my settings.xml in this way:

settings.xml

<ivysettings>
    <settings defaultResover="archiva">
        <credentials host="host" realm="Repository Archiva Managed internal Repository" username="user" passwd="passwd" />

    </settings>
    <property name="ivy.shared.default.root" value="http://host.it/repository/internal/" override="false"/>
    <property name="ivy.shared.default.ivy.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>
    <property name="ivy.shared.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>

    <resolvers>
        <chain name="archiva">
            <ibiblio name="ibiblio" m2compatible="true"/>
            <ibiblio name="archibib" root="http://host.it/repository/internal/" m2compatible="true"/>
        </chain>
    </resolvers>    
    <modules>
        <module organisation="annogen" name="annogen" resolver="archiva" />
        <module organisation="commons-lang" name="commons-lang" resolver="archiva" />
        <module organisation="commons-codec" name="commons-codec" resolver="archiva" />
        <module organisation="commons-logging" name="commons-logging" resolver="archiva" />
        <module organisation="geniogroup.bbi" name="resutil" resolver="archiva" />                      
    </modules>

</ivysettings>

Build.xml

<target name="resolve" description="--> take dependencies"> 
     <ivy:settings id="dependency" file="archivaIvySetting.xml" />
     <ivy:retrieve pattern="./lib" />
</target>

log

settings loaded (60ms)
[ivy:retrieve]    default CACHE
[ivy:retrieve]    default resolver: null
[ivy:retrieve]    default latest strategy: latest-revision
[ivy:retrieve]    default conflict manager: latest-revision
[ivy:retrieve]    circular dependency strategy: warn
[ivy:retrieve]    validate: true
[ivy:retrieve]    check up2date: true
[ivy:retrieve]    -- 1 resolvers:
[ivy:retrieve]    archiva [ibiblio]
[ivy:retrieve]        cache: null
[ivy:retrieve]        m2compatible: true
[ivy:retrieve]        ivy patterns:
[ivy:retrieve]            http://host.it/repository/internal/[organisation]

/[module]/[revision]/[artifact]-revision.[ext]

[ivy:retrieve]        artifact patterns:
[ivy:retrieve]            http://host.it/repository/internal/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext] 

[ivy:retrieve]        repository: archiva
[ivy:retrieve]        root: http://host.it/repository/internal/
[ivy:retrieve]        pattern: [organisation]/[module]/[revision]/[artifact]- [revision](-[classifier]).[ext] 
[ivy:retrieve]        usepoms: true
[ivy:retrieve]        useMavenMetadata: true
[ivy:retrieve]    module settings:
[ivy:retrieve]        NONE......

.......[ivy:retrieve] post 1.3 ivy file: using exact as default matcher
[ivy:retrieve] :: resolving dependencies :: geniogroup.bbi#bpsxml;1.0
[ivy:retrieve]    confs: [default]
[ivy:retrieve]    validate = true
[ivy:retrieve]    refresh = false
[ivy:retrieve] resolving dependencies for configuration 'default'
[ivy:retrieve] == resolving dependencies for.....

.......[ivy:retrieve] :::: ERRORS
[ivy:retrieve]    unknown resolver null
[ivy:retrieve]    no resolver found for annogen#annogen: check your configuration

i don't understand what's wrong, i have write a resolver , i have set my settinggs for the retrieve task, but it seems that it didn't read the resolver, is there something wrong?

Update

adding the modules task inside the settings now it retrieve the jar files, but i don't understand why i'm not able to save the jar in my workspace.

Upvotes: 0

Views: 1828

Answers (1)

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 77951

Could it be a typo? Your settings file is called ivysettings.xml and not archivaIvySetting.xml

<target name="resolve" description="--> take dependencies"> 
     <ivy:settings id="dependency" file="archivaIvySetting.xml" />
     <ivy:retrieve settingsRef="dependency" />
</target>

I would also like to point out that you only need the ivy settings task when you use a non-standard location for the settings file. By default it looks locally for the ivysettings.xml.

Suggested changes

ivysettings.xml

<ivysettings>
    <settings defaultResover="archiva">
        <credentials host="host" realm="Repository Archiva Managed internal Repository" username="user" passwd="passwd" />
    </settings>    
    <resolvers>
        <chain name="archiva">
            <ibiblio name="ibiblio" m2compatible="true"/>
            <ibiblio name="archibib" root="http://host.it/repository/internal/" m2compatible="true"/>
        </chain>
    </resolvers>    
</ivysettings>

Notes:

  • Don't override the ivy default properities unless you really have to.
  • Isn't it possible to get Archiva to proxy remote repositories like Maven Central? This would make the settings file even simpler:

.

<ivysettings>
    <settings defaultResover="archiva">
        <credentials host="host" realm="Repository Archiva Managed internal Repository" username="user" passwd="passwd" />
    </settings>    
    <resolvers>
       <ibiblio name="archiva" root="http://host.it/repository/proxy/" m2compatible="true"/>
    </resolvers>    
</ivysettings>

build.xml

I over-used the ivy retrieve task until I discovered the power of combining configurations with the ivy cachepath task.

    <target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
        <ivy:resolve/>

        <ivy:report todir='${build.dir}/ivy-reports' graph='false' xml='false'/>

        <ivy:cachepath pathid="compile.path" conf="compile"/>
        <ivy:cachepath pathid="test.path"    conf="test"/>
    </target>

The retrieve task is only necessary when one needs to save files into the build workspace.

    <target name="build" depends="test" description="Create executable jar archive">
        <ivy:retrieve pattern="${dist.dir}/lib/[artifact]-[revision](-[classifier]).[ext]" conf="runtime"/>

        <manifestclasspath property="jar.classpath" jarfile="${jar.file}">
            <classpath>
                <fileset dir="${dist.dir}/lib" includes="*.jar"/>
            </classpath>
        </manifestclasspath>

        <jar destfile="${jar.file}" basedir="${build.dir}/classes">
            <manifest>
                <attribute name="Main-Class" value="${jar.main.class}" />
                <attribute name="Class-Path" value="${jar.classpath}" />
            </manifest>
        </jar>
    </target>

Upvotes: 1

Related Questions