Ivy: a selection of Javadocs and sources

I am new to Ivy, but got a job working with jar dependencies. The problem is trying to configure it, so I can get javadocs and sources regardless of cans.

I have a simple test project, but no matter what I do, I collect a jar with class files.

I have the following ivy.xml file:

 <ivy-module version="1.0"> <info organisation="com.vegicorp" module="test" revision="1.0" status="release"/> <configurations> <conf name="default" visibility="public" extends="runtime,master"/> <conf name="master" visibility="public"/> <conf name="compile" visibility="public"/> <conf name="provided" visibility="public"/> <conf name="runtime" visibility="public" extends="compile"/> <conf name="test" visibility="private" extends="runtime"/> <conf name="system" visibility="public"/> <conf name="sources" visibility="public"/> <conf name="javadoc" visibility="public"/> <conf name="optional" visibility="public"/> </configurations> <dependencies> <dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="compile->default"/> <dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="sources->default"> <artifact name="commons-logging" type="sources" ext="jar"/> </dependency> <dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="javadoc->default"> <artifact name="commons-logging" type="javadoc" ext="jar"/> </dependency> </dependencies> </ivy-module> 

And the following build.xml :

 <project name="ivy-test" default="default" basedir="." xmlns:ivy="http://ant.apache.org/ivy"> <property name="ivy.dir" value="${basedir}/ivy.dir"/> <import file="${ivy.dir}/ivy.tasks.xml"/> <property name="target.dir" value="${basedir}/lib"/> <target name="-resolve"> <ivy:resolve/> </target> <target name="clean"> <delete dir="${target.dir}"/> <ivy:cleancache/> </target> <target name="default" depends="-resolve"> <fail message="ivy.conf is not defined"> <condition> <not> <isset property="ivy.conf"/> </not> </condition> </fail> <delete dir="${target.dir}"/> <mkdir dir="${target.dir}"/> <ivy:retrieve conf="${ivy.conf}" pattern="${target.dir}/[artifact]-[revision].[ext]"/> </target> </project> 

At the command prompt, type:

 $ ant -Divy.conf=compile 

And, this should load the jarfile with the classes.

However, if I type it like this:

 $ ant -Divy.conf=sources 

I need a jar file that contains sources, not classes, and when I type this:

 $ ant -Divy.conf=javadoc 

I need a jar file containing javadoc, not sources.

I am sure my ivy.xml not quite right. I originally tried this:

 <dependencies> <dependency org="commons-logging" name="commons-logging" rev="1.1.1"> <artifact name="commons-logging" type="jar" ext="jar" conf="compile->default"/> <artifact name="commons-logging" type="sources" ext="jar" conf="sources->default"/> <artifact name="commons-logging" type="javadoc" ext="jar" conf="javadoc->default"/> </dependency> 

This loaded the jar, sources and javadoc, but right away, which configuration I tried.

+6
source share
1 answer

Ok, I think I figured it out. I already thought about this process. My <dependencies> section should look like this:

 <dependencies> <dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="javadoc->javadoc;sources->sources;compile->default"/> </dependencies> 

This maps my javadoc to Maven javadoc and my sources to Maven sources . When I matched conf="sources->default" , it matched my sources with Maven default , which are compilation dependencies.

I can specify all the configurations on one line, and I do not need separate <artifact> objects.

+4
source

Source: https://habr.com/ru/post/924773/


All Articles