Summary: To download sources you must map the dependency's conf also to 'sources' (ex.:
sources" (or "
javadoc" to fetch JavaDocs).
To find out what target configurations are defined, you may check the generated Ivy metadata for a downloaded Maven artifact, for example ~/.ivy2/cache/org.springframework/spring-context/ivy-2.5.6.xml - check <configurations> for (obviously) the configurations and <publications> to find out what artifacts are available in which configurations (ex.: ...name="spring-context" type="source" ext="jar" conf="sources"...).
Example: Ivy.xml with non-standard configurations
<!-- ivy.xml --> ... <configurations> <conf name="oracle-war" description="Runtime dependencies for deploying to an Oracle container." /> <conf name="compile" extends="oracle-war" visibility="private" description="Additional compile time dependencies required to build the application." /> ... </configurations>
<dependencies> <dependency org="org.springframework" name="spring-webmvc" rev="2.5.6" conf="oracle-war->default,sources" /> ...
- We first define some custom configurations (scopes), including oracle-war
- Next we define a dependency belonging into the configuration oracle-war and map it to the target configurations default and sources, i.e. we depend on anything which is published either in the default configuration (-> spring-webmvc-2.5.6.jar) or in the sources configuration (-> spring-webmvc-2.5.6-sources.jar)
- Notice that we could use configurations' attributes defaultconf (e.g. ="oracle-war") and defaultconfmapping (e.g. ="*->default,sources") to avoid unnecessary duplication in the file
Retrieving sources or binaries with AntTo retrieve only the binary dependencies and put them inside the lib/ folder (notice type="jar") with ivy:retrieve:
<!-- build.xml --> <target name="ivy-get-binaries"> <ivy:settings file="ivysettings.xml" /> <ivy:retrieve pattern="lib/[artifact].[ext]" type="jar" /> </target>
To retrieve source codes of the dependencies and put them inside the libsources/ folder:
<!-- build.xml --> <target name="ivy-get-sources" description="Fetch JARs with source codes for libraries that have them"> <ivy:settings file="ivysettings.xml" /> <ivy:retrieve pattern="libsources/[artifact]-[type].[ext]" type="source" /> </target>
To verify that some artifacts have been found, the resolution report in the log is useless for it sums all types of artifacts (i.e. binary and source ones) together. You have to check the last line, which shows count only for the artifacts of the requested type:
[ivy:retrieve] 0 artifacts copied, 4 already retrieved (0kB/170ms)