2

I am trying to depend on Neo4j server jar and Neo4j server jar - static-web.jar in Ivy. I am trying something like

<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="org.jimwebber" module="neo4j-koans"/>
<dependencies>
    <dependency org="org.springframework.data" name="spring-data-neo4j" rev="1.0.0.RELEASE">
        <exclude module="jms"/>
        <exclude module="jmxtools"/>
        <exclude module="jmxri"/>
        <exclude org="org.slf4j" name="slf4j-log4j12"/>
    </dependency>
    <dependency org="org.aspectj" name="aspectjrt" rev="1.6.11.RELEASE"/>
    <dependency org="org.aspectj" name="aspectjtools" rev="1.6.11.RELEASE"/>
    <dependency org="org.neo4j.app" name="neo4j-server" rev="1.5-SNAPSHOT" m:classifier="static-web"/>
    <dependency org="org.neo4j.app" name="neo4j-server" rev="1.5-SNAPSHOT"/>
    <dependency org="org.neo4j" name="neo4j-community" rev="1.5-SNAPSHOT"/>
    <dependency org="org.neo4j" name="neo4j-shell" rev="1.5-SNAPSHOT"/>
    <dependency org="org.codehaus.jackson" name="jackson-core-asl" rev="1.7.5"/>
    <dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.7.5"/>
    <dependency org="com.sun.jersey" name="jersey-client" rev="1.3"/>
    <dependency org="org.mockito" name="mockito-all" rev="1.8.5"/>
    <dependency org="junit" name="junit" rev="4.7"/>        
</dependencies>
</ivy-module>

But I never get the "staic-web".jar down, and now error either. Anyone knows how to do this?

Thanks for any hints!

/peter

Peter Neubauer
  • 1,700
  • 1
  • 13
  • 11
  • This might be interesting: http://stackoverflow.com/questions/6690544/resolving-javadoc-files-with-ant-and-ivy – nawroth Oct 18 '11 at 12:41

1 Answers1

9

This is how you retrieve more than one artifact associated with a Maven module:

<dependency org="org.neo4j.app" name="neo4j-server" rev="1.5-SNAPSHOT">
    <artifact name="neo4j-server" type="jar" />
    <artifact name="neo4j-server" type="jar" m:classifier="static-web"/>
</dependency>

The syntax is odd because of the way Maven references additional artifacts using classifiers.

The neo4j snapshot repository needs to be added into your ivysettings.xml file (snapshot releases are not published to Maven Central)

<ivysettings>
    <settings defaultResolver="chain"/>
    <resolvers>
        <chain name="chain">
            <ibiblio name="central" m2compatible="true"/>
            <ibiblio name="neo4j-snapshot" m2compatible="true" root="http://repo.neo4j.org/content/repositories/snapshots"/>
        </chain>
    </resolvers>
</ivysettings>

Other issues

Version corrections

<dependency org="org.aspectj" name="aspectjrt" rev="1.6.11"/>
<dependency org="org.aspectj" name="aspectjtools" rev="1.6.11"/>

Broken repository POM

The problem with using snapshot repos is sometimes the POMs are broken. Ivy is unable to process the following file:

http://repo.neo4j.org/content/repositories/snapshots/org/neo4j/app/neo4j-server/1.5-SNAPSHOT/neo4j-server-1.5-SNAPSHOT.pom

This prevents ivy from downloading the neo4j-server arifacts....

[ivy:retrieve] :::: WARNINGS
[ivy:retrieve]  io problem while parsing ivy file: http://repo.neo4j.org/content/repositories/snapshots/org/neo4j/app/neo4j-server/1.5-SNAPSHOT/neo4j-server-1.5-SNAPSHOT.pom: Impossible to load parent for file:/home/mark/.ivy2/cache/org.neo4j.app/neo4j-server/ivy-1.5-SNAPSHOT.xml.original. Parent=org.neo4j.build#parent-pom;25
[ivy:retrieve]      module not found: org.neo4j.app#neo4j-server;1.5-SNAPSHOT
..
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]      ::          UNRESOLVED DEPENDENCIES         ::
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]      :: org.neo4j.app#neo4j-server;1.5-SNAPSHOT: not found
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::

Work-around

In the settings file configure ivy to retrieve the artifacts directly using the url resolver. The ibiblio resolver is used for all other modules whose POMs are valid.

<ivysettings>
    <settings defaultResolver="chain"/>
    <resolvers>
        <chain name="chain">
            <ibiblio name="central" m2compatible="true"/>
            <ibiblio name="neo4j-snapshot" m2compatible="true" root="http://repo.neo4j.org/content/repositories/snapshots"/>
        </chain>
        <url name="neo4j-snapshot-hack">
              <artifact pattern="http://repo.neo4j.org/content/repositories/snapshots/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
        </url>
    </resolvers>
    <modules>
        <module organisation="org.neo4j.app" name="neo4j-server" resolver="neo4j-snapshot-hack"/>
    </modules>
</ivysettings>

This will mean transitive dependencies in the by-passed POM file might be skipped. Can't be helped if the POM is not working properly

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Thanks Mark so much for the fast answer - that was exactly what I was looking for! Also, the snapshot pom is not giving me any hickups, so the hack does not seem to be needed. Will put a note on the ivy setup into the docs. Thanks again! – Peter Neubauer Oct 19 '11 at 08:56
  • Btw, it seems the `` is not pulling down transitive dependencies - any way to specify this? – Peter Neubauer Oct 19 '11 at 13:24
  • I'm still getting the error reading that module's POM file.... That explains why there's no transitive dependencies for me.... Are you purging your ivy cache? (See ivy's cleancache task) Perhaps your build is retrieving an older copy of the snapshot build. – Mark O'Connor Oct 19 '11 at 20:49
  • I updated my answer above with the ivy warning information. The module's POM is referencing a parent POM that does not seem to exist within the repo. – Mark O'Connor Oct 19 '11 at 20:51
  • Thanks a bunch Mark! Included this into the docs now, see http://docs.neo4j.org/chunked/snapshot/tutorials-java-embedded-setup.html#_add_neo4j_as_a_dependency – Peter Neubauer Dec 04 '11 at 22:20
  • Keep up the good work supporting all the build tools! One small point. The URL parameter is optional for Maven central. i.e: – Mark O'Connor Dec 04 '11 at 22:43