Hi
I feel so close, yet not quite there and I'm starting to loose the
will to live.
This is my "from" file structure:
c:\temp
repo
net.purpletube.goodmusic-0.2.jar
net.purpletube.goodmusic-0.2.xml
<!-- net.purpletube.goodmusic-0.2.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="1.0">
<info organisation="net.purpletube"
module="goodmusic"
revision="0.2"
status="release"
default="true"
/>
<configurations>
<conf name="default" visibility="public"/>
</configurations>
<publications>
<artifact name="goodmusic" type="jar" ext="jar" conf="default"/>
</publications>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.0"
conf="default"/>
</dependencies>
</ivy-module>
My ivy install ant files look like this:
<!-- ivysettings-repo.xml -->
<ivysettings>
<resolvers>
<chain name="chain-example">
<filesystem name="local-repository">
<artifact
pattern="${src.repo.dir}/[organisation].[artifact]-[revision].[ext]"/>
<ivy
pattern="${src.repo.dir}/[organisation].[module]-[revision].xml"/>
</filesystem>
<ibiblio name="ibiblio" m2compatible="true"
usepoms="false" />
</chain>
<filesystem name="shared-repository">
<artifact
pattern="${dest.repo.dir}/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
</filesystem>
</resolvers>
</ivysettings>
<!-- build.xml -->
<project name="ivy-repository" default="create-repo"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="from.resolver" value="chain-example"/>
<property name="to.resolver" value="shared-repository"/>
<property name="src.repo.dir" value="C:\Temp\repo" />
<property name="dest.repo.dir" value="C:/Program Files (x86)/Apache
Software Foundation/Apache2.2/htdocs/ivy" />
<target name="init-ivy" >
<ivy:settings id="repo.settings" file="ivysettings-repo.xml"/>
</target>
<target name = "create-repo" depends = "init-ivy">
<ivy:cleancache />
<ivy:install settingsRef="repo.settings"
organisation="net.purpletube"
module="goodmusic"
revision="0.2"
from="${from.resolver}"
to="${to.resolver}"
overwrite = "true"
haltonfailure = "yes"/>
<ivy:cleancache />
</target>
</project>
As you can see I clear the cache before and after I install the
dependancies into the shared repository just to be certain that the
install is doing what I think it's doing. When I run build.xml my
shared repository is populated as expected:
iyv
net.purpletube
goodmusic
ivys
ivy-0.2.xml
ivy-0.2.xml.md5
ivy-0.2.xml.sha1
jars
goodmusic-0.2.jar
goodmusic-0.2.jar.md5
goodmusic-0.2.jar.sha1
ivysettings-purple-shared.xml
and the ivy-0.2.xml for net.purpletube.goodmusic-0.2.jar contains the
commons-lang dependancy as expected:
<!-- ivy-0.2.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="1.0">
<info organisation="net.purpletube" module="goodmusic" revision="0.2"
status="release" publication="20090805080842" default="true"/>
<configurations>
<conf name="default" visibility="public"/>
</configurations>
<publications>
<artifact name="goodmusic" type="jar" ext="jar" conf="default"/>
</publications>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.0"
conf="default"/>
</dependencies>
</ivy-module>
So, as far as I can tell my shared repository is being setup as I want it.
The Ivy setup for my client project is like this:
<!-- ivysettings.xml>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ivysettings>
<ivysettings>
<settings defaultResolver="default"/>
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
<include url="http://localhost/ivy/ivysettings-purple-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
</ivysettings>
<!-- ivysettings-purple-shared.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ivysettings>
<ivysettings>
<resolvers>
<url name="shared">
<artifact
pattern="http://localhost/ivy/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"
/>
<ivy
pattern="http://localhost/ivy/[organisation]/[artifact]/ivys/ivy-[revision].xml"/>
</url>
</resolvers>
</ivysettings>
<!-- ivy.xml -->
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="purpletube.net" module="IvyAnt" status="integration"/>
<dependencies>
<dependency org="net.purpletube" name="goodmusic" rev="0.2"
conf="default"/>
</dependencies>
</ivy-module>
<!-- build.xml -->
<project name = "IvyAnt" basedir="." default = "run"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property name = "src.dir" value="${basedir}/src" />
<property name = "bin.dir" value="${basedir}/bin" />
<property name = "ivy.lib.dir" value="${basedir}\lib" />
<path id="lib.path.id">
<fileset dir="${ivy.lib.dir}" />
</path>
<path id="run.path.id">
<path refid="lib.path.id" />
<path location="${bin.dir}" />
</path>
<target name = "init">
<mkdir dir = "${bin.dir}"/>
<ivy:retrieve />
</target>
<target name = "compile" depends= "init">
<javac srcdir="${src.dir}" destdir="${bin.dir}" fork="true">
<classpath refid = "lib.path.id"/>
</javac>
</target>
<target name = "run" depends= "compile">
<java classpathref="run.path.id" classname="GoodMusicClient"/>
</target>
</project>
When I run the project's build.xml, I get the output:
Buildfile: build.xml
init:
[ivy:retrieve] :: Ivy 2.1.0-rc2 - 20090704004254 :: http://ant.apache.org/ivy/ :
:
[ivy:retrieve] :: loading settings :: file =
C:\Users\Paul\Documents\Sandbox\EclipseWorkspace\IvyAntRepo\ivysettings.xml
[ivy:retrieve] :: resolving dependencies ::
purpletube.net#IvyAnt;work...@paul-desktop
[ivy:retrieve] confs: [default]
[ivy:retrieve] found net.purpletube#goodmusic;0.2 in shared
[ivy:retrieve] :: resolution report :: resolve 686ms :: artifacts dl 3ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 1 | 0 | 0 | 0 || 1 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: purpletube.net#IvyAnt
[ivy:retrieve] confs: [default]
[ivy:retrieve] 1 artifacts copied, 0 already retrieved (1kB/11ms)
compile:
[javac] Compiling 1 source file to
C:\Users\Paul\Documents\Sandbox\EclipseWorkspace\IvyAntRepo\bin
run:
* lots of errors due to commons-lang not being found *
So it appears that Ivy is finding net.purpletube.goodmusic-0.2.jar in
my shared repository but completely missing the fact that it's
dependant on commons-lang.
--
Thanks
Paul
Paul Grenyer
e: [email protected]
w: http://www.marauder-consulting.co.uk
b: paulgrenyer.blogspot.com