The Holy Java

Building the right thing, building it right, fast

Posts Tagged ‘ivy’

Ivy: Retrieve Both .jar And -sources.jar Into A Folder – Note to Self

Posted by Jakub Holý on July 25, 2011

After some experimenting I’ve found out how to tell Ivy (2.2.0) to retrieve also .jar with source codes into a folder:

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"
            xmlns:e="http://ant.apache.org/ivy/extra">
...
   <dependency org="net.jakubholy.testing" name="dbunit-embeddedderby-parenttest" rev="1.2.0" conf="test" >
	<artifact name="dbunit-embeddedderby-parenttest" type="jar" />
	<artifact name="dbunit-embeddedderby-parenttest" type="sources" e:classifier="sources"  ext="jar" />
	<exclude org="junit" />
   </dependency>

The important thing here is the second artifact line with type and classifier sources and extension jar.

Ant:

<target name="ivy" description="Retrieve dependencies managed by Ivy into lib/">
	<ivy:settings file="ivysettings.xml" />
	<!-- Notice that with sync=true Ivy will also remove the files which do not need to be there -->
	<ivy:retrieve pattern="lib/[conf]/[artifact].[ext]" sync="true" type="jar" />
	<ivy:retrieve pattern="lib/[conf]/[artifact]-sources.[ext]" sync="false" type="sources" />
</target>

Notice the second retrieve line – the type is set to sources and we’ve changed also the pattern not to overwrite the normal .jar and we’ve also disabled sync for otherwise the normal .jar would be removed (I’m sure there must be a better way, perhaps combining the two into one line with type=”jar,sources” and a pattern which takes the type into account).

Posted in Tools | Tagged: | Comments Off

Ivy: How to Retrieve Source Codes of Dependencies

Posted by Jakub Holý on May 20, 2011

Summary: To download sources you must map the dependency’s conf also to ‘sources’ (ex.: conf="myScope->default,sources").

If you are using Apache Ivy (2.2) for maintaining you dependencies, you may also want to retrieve source codes (or javadocs) of those dependencies, e.g. to get nice help pop-ups in Eclipse or to actually browse the sources. Provided that you’re retrieving the dependencies from Maven repositories, the configuration required to enable retrieval of source codes is to map to the Ivy “configuration” (“scope”, or perhaps more exactly classifier, in the Maven language) called “sources” (or “javadoc” to fetch JavaDocs).

Read the rest of this entry »

Posted in Tools | Tagged: | Comments Off

Using Ivy with pom.xml

Posted by Jakub Holý on January 26, 2011

It’s possible to use Apache Ivy with dependencies defined in pom.xml instead of its native ivy.xml but you will need to apply some workarounds and you’re loosing access to some functionality that you might (or might not) need.

The problem is that in a POM you can provide only a subset of settings available in ivy.xml and that Ivy understands only a subset of POM’s syntax. Read the rest of this entry »

Posted in Tools | Tagged: , | Comments Off

Ivy resolve downloads but ignores some artifacts (though not modules)

Posted by Jakub Holý on December 23, 2010

I’ve had a strange issue with Apache Ivy‘s resolve task – it resolved and downloaded all my dependencies but didn’t put some of them to the classpath (via ivy:cachepath) and certainly wouldn’t copy them either (via ivy:retrieve). An indicia was that in the resolve report the number of “artifacts” was zero while the number of “modules” matched the number of the dependencies. The issue was caused by my defaultconfmapping=”*->compile” – it turned out that most modules, as interpreted by Ivy, produce their artifacts only for the configuration “master” and not for compile.

Read the rest of this entry »

Posted in Tools | Tagged: , , | Comments Off