Skip navigation.

Basic repository replication

!!!! UNDER CONSTRUCTION !!!!

We will study here two cases, corresponding to the two basics targets found in the previous build.xml project file.

Basic : ivyconf.xml file used

The ivy conf file that we will use is very simple here. It defines two resolvers, libraries and local-repository. The first one is used to retrieve the files that we want, the second is used to copy them. The second one will become our own repository.

  • ivyrep : nothing special on it, ivy files will be looked for on ivyrep and artifacts will be downloaded from
    ibilio
  • local-repository : will store the found files
<ivyconf>
    <conf  defaultCache="${ivy.cache.dir}"
            defaultResolver="local-repository"
            defaultConflictManager="all" />    <!-- in order to get all revisions without any eviction -->
    <resolvers>
        <ivyrep name="libraries" />
        <filesystem name="local-repository">
            <ivy pattern="${dest.repo.dir}/[organisation]/[module]/ivys/ivy-[revision].xml"/>
            <artifact pattern="${dest.repo.dir}/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"/>
        </filesystem>
    </resolvers>
</ivyconf>

basic, retrieve commons-lang 1.0

Let's have a look at the basic target.

    <target name="basic" depends="init-basic" description="--> retrieve files from well formatted ivy repositories">
        <ivy:install organisation="apache" module="commons-lang" revision="1.0" from="${from-resolver}" to="${to-resolver}" />
    </target>

After a call to init-basic, that make the ivy initialization with the right ivyconf file, we only call the task install to retrieve apache commons-lang in it's 1.0 version.
Here is the ant call output :

Z:\ivy-repository>ant basic
Buildfile: build.xml

init-basic:
:: Ivy 20060123130642 - 20060123130642 :: http://ivy.jayasoft.org/ ::
:: configuring :: file = Z:\ivy-repository\ivy-conf-basic.xml

basic:
:: installing [ apache | commons-lang | 1.0 ] ::
:: resolving dependencies ::
        found [ apache | commons-lang | 1.0 ] in libraries
:: downloading artifacts to cache ::
downloading http://www.ibiblio.org/maven/commons-lang/jars/commons-lang-1.0.jar ...
............ (62kB)
        [SUCCESSFUL ] [ apache | commons-lang | 1.0 ]/commons-lang.jar[jar] (1203ms)
:: installing in local-repository ::
        published commons-lang to Z:\ivy-repository/ivy-local-repository/apache/commons-lang/jars/commons-lang-1.0.jar
        published ivy to Z:\ivy-repository/ivy-local-repository/apache/commons-lang/ivys/ivy-1.0.xml

BUILD SUCCESSFUL
Total time: 2 seconds

The trace tells us that the module definition was found using the "libraries" resolver and that the corresponding artifact was downloaded from ibiblio. Then both were published in the local repository.

If we take a look at our repository :

Z:\ivy-repository>dir /s /B /A:-D ivy-local-repository
Z:\ivy-repository\ivy-local-repository\apache\commons-lang\ivys\ivy-1.0.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-lang\jars\commons-lang-1.0.jar
Z:\ivy-repository>

We can see that we have started our own repository by retrieving the commons-lang 1.0 ivy file descriptor and jar.

basic with dependencies, retrieve hibernate 2.1.8

Now let's advance a little more by trying a module that has some dependencies. Here is the target that we will call :

    <target name="basic-deps" depends="init-basic" description="--> retrieve files from well formatted ivy repositories with dependencies">
        <ivy:install organisation="hibernate" module="hibernate" revision="2.1.8" from="${from-resolver}" to="${to-resolver}" transitive="true" />
    </target>

This target is very similar to the basic one, except it defines the transitivity mode to use. By writing, transitive="true", we tell the task to retrieve the corresponding module and it's dependencies.

Ok let's call the target :

Z:\ivy-repository>ant basic-deps
Buildfile: build.xml

init-basic:
:: Ivy 20060123130642 - 20060123130642 :: http://ivy.jayasoft.org/ ::
:: configuring :: file = Z:\ivy-repository\ivy-conf-basic.xml

basic-deps:
:: installing [ hibernate | hibernate | 2.1.8 ] ::
:: resolving dependencies ::
        found [ hibernate | hibernate | 2.1.8 ] in libraries
        found [ cglib | cglib | 2.0.2 ] in libraries
        found [ apache | commons-collections | 2.1.1 ] in libraries
        found [ apache | commons-logging | 1.0.4 ] in libraries
        found [ dom4j | dom4j | 1.4 ] in libraries
        found [ ehcache | ehcache | 0.9 ] in libraries
        found [ odmg | odmg | 3.0 ] in libraries
        found [ sun | jta | 1.0 ] in libraries
        found [ apache | xalan | 2.4.0 ] in libraries
        found [ apache | xerces | 2.4.0 ] in libraries
        found [ sun | jdbc | 2.0 ] in libraries
        found [ sun | jca | 1.0 ] in libraries
        found [ sun | jaas | 1.0 ] in libraries
        found [ c3p0 | c3p0 | 0.8.4.5 ] in libraries
        found [ apache | commons-dbcp | 1.2.1 ] in libraries
        found [ apache | commons-pool | 1.2 ] in libraries
        found [ apache | commons-collections | 2.1 ] in libraries
        found [ apache | xerces | 2.0.2 ] in libraries
        found [ proxool | proxool | 0.8.3 ] in libraries
        found [ jboss | jboss-cache | 1.1.1 ] in libraries
        found [ opensymphony | oscache | 2.0 ] in libraries
        found [ apache | commons-logging | 1.0.3 ] in libraries
        found [ swarmcache | swarmcache | 1.0RC2 ] in libraries
        found [ apache | commons-logging | 1.0.2 ] in libraries
        found [ jgroups | jgroups | 2.2 ] in libraries
:: downloading artifacts to cache ::
downloading http://www.ibiblio.org/maven/hibernate/jars/hibernate-2.1.8.jar ...
...........
............
.. (944kB)
        [SUCCESSFUL ] [ hibernate | hibernate | 2.1.8 ]/hibernate.jar[jar] (97063ms)


SOME MINUTES LATER .... ;-)


downloading http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.4.... ...
..
......
.. (37kB)
        [SUCCESSFUL ] [ apache | commons-logging | 1.0.4 ]/commons-logging.jar[jar] (24172ms)

BUILD SUCCESSFUL
Total time: 14 minutes 57 seconds
Z:\ivy-repository>

We can see here that ivy has resolved hibernate 2.1.8 and 24 depending modules. If we look at the ivy file for hibernate 2.1.8, we can see that it defines 17 dependencies. The 7 others that ivy retrieved, were transitive ones used in direct dependent modules of hibernate.

We can notice that we have retrieve 3 differents revisions of apache commons-logging (1.0.2, 1.0.3, 1.0.4) and 2 revisions of commons-collections (1.2, 1.2.1). This is due to the fact that we use the "no conflict" conflic manager in the ivyconf file.
We do not want to evict any modules because we are building our own repository !

8 modules artifacts have not been downloaded cause they have not been found on ibiblio with the ivyconf as it is.
We will see how to handle this problem in the advanced tutorial.

If we look at our repository now, it starts to look to something good :

Z:\ivy-repository>dir /s /B /A:-D ivy-local-repository
Z:\ivy-repository\ivy-local-repository\apache\commons-collections\ivys\ivy-2.1.1.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-collections\ivys\ivy-2.1.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-collections\jars\commons-collections-2.1.1.jar
Z:\ivy-repository\ivy-local-repository\apache\commons-collections\jars\commons-collections-2.1.jar
Z:\ivy-repository\ivy-local-repository\apache\commons-dbcp\ivys\ivy-1.2.1.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-dbcp\jars\commons-dbcp-1.2.1.jar
Z:\ivy-repository\ivy-local-repository\apache\commons-lang\ivys\ivy-1.0.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-lang\jars\commons-lang-1.0.jar
Z:\ivy-repository\ivy-local-repository\apache\commons-logging\ivys\ivy-1.0.2.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-logging\ivys\ivy-1.0.3.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-logging\ivys\ivy-1.0.4.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-logging\jars\commons-logging-1.0.2.jar
Z:\ivy-repository\ivy-local-repository\apache\commons-logging\jars\commons-logging-1.0.3.jar
Z:\ivy-repository\ivy-local-repository\apache\commons-logging\jars\commons-logging-1.0.4.jar
Z:\ivy-repository\ivy-local-repository\apache\commons-pool\ivys\ivy-1.2.xml
Z:\ivy-repository\ivy-local-repository\apache\commons-pool\jars\commons-pool-1.2.jar
Z:\ivy-repository\ivy-local-repository\apache\xalan\ivys\ivy-2.4.0.xml
Z:\ivy-repository\ivy-local-repository\apache\xalan\jars\xalan-2.4.0.jar
Z:\ivy-repository\ivy-local-repository\apache\xerces\ivys\ivy-2.0.2.xml
Z:\ivy-repository\ivy-local-repository\apache\xerces\ivys\ivy-2.4.0.xml
Z:\ivy-repository\ivy-local-repository\apache\xerces\jars\xerces-2.0.2.jar
Z:\ivy-repository\ivy-local-repository\apache\xerces\jars\xerces-2.4.0.jar
Z:\ivy-repository\ivy-local-repository\apache\xerces\jars\xmlParserAPIs-2.0.2.jar
Z:\ivy-repository\ivy-local-repository\c3p0\c3p0\ivys\ivy-0.8.4.5.xml
Z:\ivy-repository\ivy-local-repository\c3p0\c3p0\jars\c3p0-0.8.4.5.jar
Z:\ivy-repository\ivy-local-repository\cglib\cglib\ivys\ivy-2.0.2.xml
Z:\ivy-repository\ivy-local-repository\cglib\cglib\jars\cglib-full-2.0.2.jar
Z:\ivy-repository\ivy-local-repository\dom4j\dom4j\ivys\ivy-1.4.xml
Z:\ivy-repository\ivy-local-repository\dom4j\dom4j\jars\dom4j-1.4.jar
Z:\ivy-repository\ivy-local-repository\ehcache\ehcache\ivys\ivy-0.9.xml
Z:\ivy-repository\ivy-local-repository\ehcache\ehcache\jars\ehcache-0.9.jar
Z:\ivy-repository\ivy-local-repository\hibernate\hibernate\ivys\ivy-2.1.8.xml
Z:\ivy-repository\ivy-local-repository\hibernate\hibernate\jars\hibernate-2.1.8.jar
Z:\ivy-repository\ivy-local-repository\jboss\jboss-cache\ivys\ivy-1.1.1.xml
Z:\ivy-repository\ivy-local-repository\jgroups\jgroups\ivys\ivy-2.2.xml
Z:\ivy-repository\ivy-local-repository\odmg\odmg\ivys\ivy-3.0.xml
Z:\ivy-repository\ivy-local-repository\odmg\odmg\jars\odmg-3.0.jar
Z:\ivy-repository\ivy-local-repository\opensymphony\oscache\ivys\ivy-2.0.xml
Z:\ivy-repository\ivy-local-repository\proxool\proxool\ivys\ivy-0.8.3.xml
Z:\ivy-repository\ivy-local-repository\proxool\proxool\jars\proxool-0.8.3.jar
Z:\ivy-repository\ivy-local-repository\sun\jaas\ivys\ivy-1.0.xml
Z:\ivy-repository\ivy-local-repository\sun\jca\ivys\ivy-1.0.xml
Z:\ivy-repository\ivy-local-repository\sun\jdbc\ivys\ivy-2.0.xml
Z:\ivy-repository\ivy-local-repository\sun\jta\ivys\ivy-1.0.xml
Z:\ivy-repository\ivy-local-repository\swarmcache\swarmcache\ivys\ivy-1.0RC2.xml
Z:\ivy-repository\ivy-local-repository\swarmcache\swarmcache\jars\swarmcache-1.0RC2.jar

Z:\ivy-repository>