4

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

 2 years ago
source link: https://blog.jakubholy.net/2011/07/25/ivy-retrieve-both-jar-and-sources-jar-into-a-folder-note-to-self/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

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).
Tags: tool

Are you benefitting from my writing? Consider buying me a coffee or supporting my work via GitHub Sponsors. Thank you! You can also book me for a mentoring / pair-programming session via Codementor or (cheaper) email.

Allow me to write to you!

Let's get in touch! I will occasionally send you a short email with a few links to interesting stuff I found and with summaries of my new blog posts. Max 1-2 emails per month. I read and answer to all replies.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK