45

Can anyone point me at a good tutorial for making & using a local repository with Ivy? (Please don't point me at the Ivy docs, the tutorials are rather confusing)

I need to make a local repository to include .jar files that aren't necessarily available through the public maven repositories.

Jason S
  • 184,598
  • 164
  • 608
  • 970
  • I don't think there are many proper tutorials around. For .jars that aren't in the public maven repositories you can use the task. In practice I've found it easier to simply copy the .jars in the proper spots and to hand-edit the ivy.xml files. – leonm Sep 20 '09 at 02:41
  • 2
    Interesting question. Our local Ivy repo was organically built up over years, and it's a mess. – skaffman Feb 17 '10 at 09:51
  • 10
    +1 for "Please don't point me at the Ivy docs, the tutorials are rather confusing". I'm finding it extremely difficult to learn how to do basic things in Ivy. – jwaddell Sep 01 '11 at 00:19

3 Answers3

45

Creating a local ivy repository is straight forward, maven is not required. Here's an example of publishing some text files using ivy as a standalone program.

I have 3 files I want to publish:

src/English.txt
src/Spanish.txt
src/Irish.txt

The ivy file src/ivy.xml details the name of the module and a list of the artifacts being published. (Release index)

<ivy-module version="2.0">
  <info organisation="myorg" module="hello"/>
  <publications>
    <artifact name="English" ext="txt" type="doc"/>
    <artifact name="Irish" ext="txt" type="doc"/>
    <artifact name="Spanish" ext="txt" type="doc"/>
  </publications>
</ivy-module>

You'll also need an ivy settings file to tell ivy where the repository is located

<ivysettings>
    <property name="repo.dir" value=".../repo"/>
    <settings defaultResolver="internal"/>
    <resolvers>
        <filesystem name="internal">
            <ivy pattern="${repo.dir}/[module]/ivy-[revision].xml" />
            <artifact pattern="${repo.dir}/[module]/[artifact]-[revision].[ext]" />
        </filesystem>
    </resolvers>
</ivysettings>

Finally run ivy to publish the released version 1.0:

java -jar $IVY -settings config/ivysettings.xml \
        -ivy src/ivy.xml \
        -publish internal \
        -publishpattern "src/[artifact].[ext]" \
        -revision 1.0 \
        -status release \
        -overwrite 

Note the publish pattern. It tells ivy where the files to be published are located.

Added: Publishing from within ANT

<target name="publish" depends="clean,package" description="Publish this build into repository">
    <ivy:publish pubrevision="${pub.version}" status="${pub.status}" resolver="${pub.resolver}" >
        <artifacts pattern="${build.dir}/dist/[artifact].[ext]"/>
    </ivy:publish>
</target>
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Nice answer! Do you know where we can get the same 'publish' information in an Ant task? The "official" documentation of the tasks is confusing. – Ralph Oct 01 '10 at 11:24
  • 1
    Yes, I use the ivy publish task all the time, publishing to my Nexus Maven repository. What's missing really on the ivy site is more example documentation. I find it's fine for reference once you've figured out how ivy works :-( – Mark O'Connor Oct 01 '10 at 19:23
  • 9
    Don't say it is easy, because it is not. If it would be easy, I would have found out myself how to do it. – Arne Nov 25 '10 at 13:18
  • 1
    Point taken. Maven is no walk in the part either :-) – Mark O'Connor Nov 30 '10 at 19:53
2

don't know if you're using SVN, if this is the case this may help:

http://code.google.com/p/ivysvn/

Marc
  • 356
  • 1
  • 8
0

What you may want to look at doing is creating a private maven repository, either on your local machine, or in your intranet. Then deploy these non-public resources to that repository using maven. Ivy integrates with maven repositories, so you will be able to then pull these resources in during compile time.

codethulhu
  • 3,976
  • 2
  • 21
  • 15