i have schema's which needs to be parsed and that should create ejb stubs and jboss related deployment descriptor files .
Could anyone please suggest me which tool (for instance :xdoclet jaxb,its for weblogic) generates jboss deployment descriptor files along with ejb needed interfaces .I have been trying with the below code snippet but couldnt able to generate artifacts .
<taskdef name="ejbdoclet" classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="xdoclet.classpath" />
<taskdef name="ejbdoclet" classname="xdoclet.modules.jboss.ejb.JBossSubTask" classpathref="xdoclet.classpath" />
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath refid="compile.classpath" />
</taskdef>
your help on this matter is highly appreciable .Thanks in Advance .
Seems like you are using ANT, I've used something like this for the build.xml. The compile task must depend on this.
<target name="createDeployDescriptor" description="create DeployDescriptor using XDoclet">
<taskdef classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="xdoclet.classpath" name="ejbdoclet" />
<ejbdoclet destdir="${classes.dir}/META-INF" mergedir="etc/xdoclet/merge" excludedtags="#version,#author" ejbspec="2.1" force="true">
<fileset dir="${src.dir}">
<include name="**/*Bean.java" />
<exclude name="**/*test*" />
</fileset>
<remoteinterface destDir="${src.gen.dir}" />
<localinterface destDir="${src.gen.dir}" />
<homeinterface destDir="${src.gen.dir}" />
<localhomeinterface destDir="${src.gen.dir}" />
<!-- valueobject templateFile="etc/resources/xdoclet/valueobject.xdt" pattern="{0}" / -->
<!-- generate the primary key classes for the entities -->
<entitypk destDir="${src.gen.dir}" />
<utilobject destDir="${src.gen.dir}" kind="physical" cacheHomes="true" includeGUID="${xdoclet.ejb.include.guid}" pattern="{0}Locator" templateFile="etc/xdoclet/locator.xdt" />
<deploymentdescriptor validatexml="true">
<configParam name="Description" value="Deploymentdescriptor for WFink EJB2.1" />
</deploymentdescriptor>
<jboss version="4.0" mergeDir="etc/xdoclet/merge" />
</ejbdoclet>
</target>
Also Maven is possible with this:
<build>
<plugins>
<!-- use XDoclet to generate the EJB2 artifacts, the plugin version is defined in the root pom -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xdoclet-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xdoclet</goal>
</goals>
<configuration>
<tasks>
<ejbdoclet destdir="${project.build.outputDirectory}">
<fileset dir="${project.build.sourceDirectory}" includes="**/*Bean.java" />
<localinterface destDir="${project.build.directory}/generated-sources/xdoclet" />
<localhomeinterface destDir="${project.build.directory}/generated-sources/xdoclet" />
<remoteinterface destDir="${project.build.directory}/generated-sources/xdoclet" />
<homeinterface destDir="${project.build.directory}/generated-sources/xdoclet" />
<utilobject kind="physical" destDir="${project.build.directory}/generated-sources/xdoclet" />
<deploymentdescriptor destDir="${project.build.outputDirectory}/META-INF" />
<jboss version="4.0" destDir="${project.build.outputDirectory}/META-INF" datasource="java:jboss/datasources/ExampleDS" />
</ejbdoclet>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
....
</plugins>
</build>
You should consider that both are out of date, for JBossAS7, WildFly and EAP6+ the generated jboss.xml descriptor is ignored and you need to add by hand a jboss-ejb3.xml which configure the JBoss specific settings.
For simple use you should not need this
Related
I would like to generate schema sql script with maven.
Here is my persistance file :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="mypersistance"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"></property>
<property name="hibernate.archive.autodetection" value="class"></property>
</properties>
<description>Persistance descriptor</description>
<class>test.sofiane.beans.Code</class>
</persistence-unit>
</persistence>
hibernate configuration file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="mySessionFactory">
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/test</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.default_schema">public</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
</session-factory>
</hibernate-configuration>
plugin in the pom
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<!-- Hibernatetool will generate everything before running tests -->
<phase>compile</phase>
<configuration>
<target>
<echo message="Ant target, through maven-antrun-plugin, started" />
<property name="maven_compile_classpath" refid="maven.compile.classpath" />
<property name="maven_test_classpath" refid="maven.test.classpath" />
<path id="hibernatetool.path">
<pathelement path="${maven_compile_classpath}" />
<pathelement path="${maven_test_classpath}" />
</path>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernatetool.path" />
<property name="generatedByHibernate.outputDirectory"
value="${project.build.directory}/generated/hibernatetool" />
<mkdir dir="${generatedByHibernate.outputDirectory}" />
<hibernatetool destdir="${generatedByHibernate.outputDirectory}">
<classpath>
<path location="${project.build.directory}/classes/test/sofiane/beans" />
</classpath>
<configuration
configurationfile="${project.build.directory}/classes/hibernate.cfg.xml" />
<hbm2ddl export="true" drop="true" create="true"
outputfilename="helloworld.ddl" format="true" />
</hibernatetool>
<echo message="Ant target, through maven-antrun-plugin, terminated" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The pom works fine and generate helloworld.ddl but empty unfortunately !
Any idea please ?
My first advice is that you should better use the hibernate3-maven-plugin instead of the maven-antrun-plugin because it includes everything that you need and is a lot more simple to use than all the configuration that you had to write with the maven-antrun-plugin (see here for more information about the hibernate3-maven-plugin).
And then, to fix your problem, I think that you can find the answer to your problem in this post and in the answer because it seems that all the elements given will lead you to make your configuration work good.
And don't forget to bind the run of the hibernate3-maven-plugin after the compile phase, on the process-classes phase for example (see Lifecycle Reference) and then just run mvn process-classes.
I was building an Ant build file that worked properly in my eclipse project but not on our Jenkins autobuild set-up. I installed ant on my computer and ran the build from the console. It worked, but I realized it didn't use the junit-4.10.jar in my project lib like I wished but the junit.jar in the ant lib. After renaming the junit.jar files in my ant lib, the ant build didn't work.
So basically the problem in our Jenkins autobuild setup is that there are no junit.jar in its own ant lib directory. Can I specify the junit task to use the jar in my project lib instead of the one in the ant lib?
EDIT : I have modified my build.xml file and now it looks like this, still doesnt work. My junit-4.10.jar is in the /war/WEB-INF/lib/test directory :
<project name="vlp" default="junit" basedir=".">
<tstamp />
<!-- ################# PROPERTIES ################ -->
<!-- directory properties -->
<!-- source -->
<property name="vlp.src" location="src" />
<property name="vlp.test" location="test" />
<!-- build -->
<property name="src.build" location="bin/src" />
<property name="test.build" location="bin/test" />
<!-- libraries -->
<property name="vlp.lib.dir" location="war/WEB-INF/lib" />
<property name="vlp.testlib.dir" location="war/WEB-INF/lib/test" />
<!-- compile classpath -->
<path id="compile.path">
<fileset dir="${vlp.lib.dir}" includes="*.jar" />
</path>
<!-- test classpath -->
<path id="test.path">
<fileset dir="${vlp.testlib.dir}" includes="*.jar" />
<path refid="compile.path" />
</path>
<!-- ############### CLEANING ################## -->
<!-- Cleaning old compile files -->
<target name="clean" description="Clean all the old build files.">
<delete dir="${src.build}" />
<delete dir="${dist}" />
</target>
<!-- ############## COMPILATION ############### -->
<!-- Compile source -->
<target name="src.compile" depends="clean" description="Compile the source code when everything has been cleaned.">
<mkdir dir="${src.build}" />
<javac encoding="utf-8" destdir="${src.build}" nowarn="true">
<src path="${vlp.src}" />
<classpath refid="compile.path" />
</javac>
</target>
<!-- Compile test -->
<target name="test.compile" depends="clean" description="Compile the source code when everything has been cleaned.">
<mkdir dir="${test.build}" />
<javac encoding="utf-8" destdir="${test.build}" nowarn="true">
<src path="${vlp.test}" />
<classpath>
<pathelement location="${src.build}" />
<path refid="test.path" />
</classpath>
</javac>
</target>
<!-- ########### RUNS JUNIT TEST ############ -->
<target name="junit" depends="src.compile,test.compile" description="Runs all the unit test in the application. Does not halt build if test are failed.">
<junit printsummary="on" haltonfailure="false" showoutput="true">
<formatter type="brief" usefile="false" />
<classpath>
<pathelement location="${test.build}" />
<path refid="test.path" />
</classpath>
<batchtest>
<fileset dir="${vlp.test}">
<include name="**/Test*.java" />
<exclude name="**/AllTests.java" />
</fileset>
</batchtest>
</junit>
</target>
</project>
EDIT : Simlar question can be found here with a different answer that works well. Note that it is much easier to install ant-junit on the machine than to try to add it to your libs and everything.
See the answer to this question:
H2 database org.h2.Driver ClassNotFoundException
I normally specify the junit jar to be on a test classpath and then use it when calling the junit ANT task
Update
The following build file is an example of a starting template I used for my builds.
Sets up an infrastructure that uses ivy to manage classpaths. Dependencies are downloaded from the Maven Central repository (by default). Makes build much more portable and repeatable.
build.xml
<project name="ivy demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant">
<!--
==========
Properties
==========
-->
<property name="build.dir" location="build"/>
<property name="class.dir" location="${build.dir}/classes"/>
<property name="report.dir" location="${build.dir}/reports"/>
<!--
=======
Targets
=======
-->
<target name="install-ivy" description="Used to install the ivy task jar">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar"/>
</target>
<target name="init" description="Download dependencies, setup project classpaths and create build directories">
<ivy:resolve/>
<ivy:cachepath pathid="compile.path" conf="compile"/>
<ivy:cachepath pathid="runtime.path" conf="runtime"/>
<ivy:cachepath pathid="test.path" conf="test"/>
<ivy:report todir="${report.dir}" graph="false"/>
<mkdir dir="${class.dir}"/>
</target>
<target name="build" depends="init" description="Build the project">
<echo message="Build logic goes here"/>
</target>
<target name="clean" description="Remove build directories">
<delete dir="${build.dir}"/>
</target>
<target name="clean-all" depends="clean" description="Purge ivy cache">
<ivy:cleancache />
</target>
</project>
ivy.xml
This file is used to specify the project's dependencies. Ivy configurations are used to manage the classpath groupings.
<ivy-module version="2.0">
<info organisation="org.demo" module="demo"/>
<configurations>
<conf name="compile"/>
<conf name="runtime" extends="compile"/>
<conf name="test" extends="runtime"/>
</configurations>
<!--
Dependencies can be found using Maven Central's search site:
http://search.maven.org/
-->
<dependencies>
<!-- Compile dependencies -->
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.4" conf="compile->default"/>
<!-- Runtime dependencies -->
<dependency org="log4j" name="log4j" rev="1.2.16" conf="runtime->default"/>
<!-- Test dependencies -->
<dependency org="junit" name="junit" rev="4.10" conf="test->default"/>
</dependencies>
</ivy-module>
We have a special routine to explode files in a subfolder into extensions, which will be copied and jared into single extension files. For this special approach I wanted to use the maven-antrun-plugin, for the sequential iteration and jar packaging through the dirset, we need the library ant-contrib.
The upcoming plugin configuration fails with an error. What did I misconfigured? Thank you.
Plugin configuration
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<for param="extension">
<path>
<dirset dir="${basedir}/src/main/webapp/WEB-INF/resources/extensions/">
<include name="*" />
</dirset>
</path>
<sequential>
<basename property="extension.name" file="${extension}" />
<echo message="Creating JAR for extension '${extension.name}'." />
<jar destfile="${basedir}/target/extension-${extension.name}-1.0.0.jar">
<zipfileset dir="${extension}" prefix="WEB-INF/resources/extensions/${extension.name}/">
<include name="**/*" />
</zipfileset>
</jar>
</sequential>
</for>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
Error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project extension-platform: An Ant BuildException has occured: Problem: failed to create task or type for
[ERROR] Cause: The name is undefined.
[ERROR] Action: Check the spelling.
[ERROR] Action: Check that any custom tasks/types have been declared.
[ERROR] Action: Check that any <presetdef>/<macrodef> declarations have taken place.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Therefore I wasted at least one hour to find the error a little hint below ...
I use maven3 and the rest as described above, BUT I have to use maven.dependency.classpath
instead of maven.plugin.classpath! Otherwise maven won't find the contrib tasks. Hope this helps anybody.
It looks like you're missing the taskdef that's needed to declare the ant-contrib tasks, so that Ant knows about them, hence this part of the error message:
Problem: failed to create task or type for
(It would perhaps be a little clearer if the failed task - 'for' - were quoted.)
One way to add the taskdef is to insert it immediately prior to the for loop:
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpathref="maven.plugin.classpath" />
<for param="extension">
...
After wasting 2 hours and reading too many answers, this is what I need to check
http://www.thinkplexx.com/learn/howto/maven2/plugins/could-not-load-definitions-from-resource-antlib-xml-understanding-the-problem-and-fix-worklow
I printed all the maven classpaths using this
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
and checked which classpath contains antrib jar file. So I changed classpathhref to maven.runtime.classpath from maven.plugin.classpath
. So my taskdef is
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.runtime.classpath" />
and the dependencies
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
I too wasted several hours on this one, because antcontrib for task could not be found.
Finally, I found out that for task in not defined in antcontrib.properties, but in antlib.xml!
antcontrib.properties is a pre ant 1.6 way of doing things – the modern way is to use antlib.xml.
So, this is a maven 3.5, ant 1.8, working example:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<execution>
<id>deploy_to_distrib_folder</id>
<phase>package</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<macrodef name="deploy_extra_dir">
<attribute name="dir" />
<sequential>
<basename property="basename" file="#{dir}" />
<sync todir="${outputDir}/${basename}">
<fileset dir="#{dir}" />
</sync>
<var name="basename" unset="true" />
</sequential>
</macrodef>
<for param="dir">
<path>
<dirset dir="${project.build.directory}/maven-shared-archive-resources" includes="*" />
</path>
<sequential>
<deploy_extra_dir dir="#{dir}" />
</sequential>
</for>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</plugin>
Hope this helps!
This is more of knowledge sharing rather than asking a question. Thought this little Ant snippet might be useful to someone.
<target name="create-jaxb-index" depends="compile">
<!-- Create a suitable jaxb.index file on the fly to remove the need for an ObjectFactory
jaxb.index is a simple list of the domain objects without package or extension, e.g.
org.example.Domain.java -> Domain
-->
<fileset id="domain-sources" dir="${src}">
<include name="org/example/*.java"/>
</fileset>
<pathconvert property="domain-list" refid="domain-sources" pathsep="${line.separator}">
<chainedmapper>
<flattenmapper/>
<globmapper from="*.java" to="*" casesensitive="false"/>
</chainedmapper>
</pathconvert>
<echo file="${target}/classes/org/example/jaxb.index" message="${domain-list}"/>
</target>
OK, OK so it doesn't go the whole way and store up all the package names so that it can reconstruct the appropriate file structure, but it's good enough to get you started.
Hope it helps.
Also, you could just insert this little snippet (less the target element) into a Maven build like this:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<!-- Create a suitable jaxb.index file on the fly to remove the need for an ObjectFactory
jaxb.index is a simple list of the domain objects without package or extension, e.g.
org.example.Domain.java -> Domain
-->
<fileset id="domain-sources" dir="${build.sourceDirectory}">
<include name="org/example/domain/*.java"/>
</fileset>
<pathconvert property="domain-list" refid="domain-sources" pathsep="${line.separator}">
<chainedmapper>
<flattenmapper/>
<globmapper from="*.java" to="*" casesensitive="false"/>
</chainedmapper>
</pathconvert>
<echo file="${build.outputDirectory}/org/example/domain/jaxb.index" message="${domain-list}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Following on from Gary's example, I took it and extended it so it would work for more than one package directory. The following should work if you have the antcontrib dependency in your plugin's dependencies:
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="maven.dependency.classpath" />
<for param="dto-dir">
<path>
<dirset dir="${basedir}/src/main/java">
<include name="com/example/**/dto"/>
</dirset>
</path>
<sequential>
<property name="#{dto-dir}" basedir="${basedir}/src/main/java" relative="true" location="#{dto-dir}" />
<echo message="Creating jaxb.index file for directory: ${#{dto-dir}}" />
<echo message="#{dto-dir}" />
<fileset id="#{dto-dir}_dtos" dir="#{dto-dir}">
<include name="*Dto.java" />
</fileset>
<pathconvert property="#{dto-dir}_contents" refid="#{dto-dir}_dtos" pathsep="${line.separator}">
<chainedmapper>
<flattenmapper />
<globmapper from="*.java" to="*" casesensitive="false" />
</chainedmapper>
</pathconvert>
<echo file="${project.build.outputDirectory}/${#{dto-dir}}/jaxb.index" message="${#{dto-dir}_contents}" />
</sequential>
</for>
</target>
I am not an ant expert by any means as you can see, and I had to do some weird stuff to create unique property names, but it works for me.
You can also use the JAXBIndex plugin from JAXB2 Basics.
Is it possible to do something like the following?
<target name="path-test">
<property name="d.file" value="ant/d.fileset" />
<property name="c.file" value="ant/c.fileset" />
<property name="e.file" value="ant/e.fileset" />
<available property="c.file.exists" file="${c.file}" />
<available property="d.file.exists" file="${d.file}" />
<available property="e.file.exists" file="${e.file}" />
<path id="classPathRef">
<fileset dir="${depot.dir}">
<include name="${c.file}" if="c.file.exists" />
<include name="${d.file}" if="d.file.exists" />
<include name="${e.file}" if="e.file.exists" />
</fileset>
</path>
</target>
In this scenario, each fileset file would contain a list of jars that I want to end up in the classPathRef.
Doh!
<target name="path-test">
<property name="d.file" value="ant/d.fileset" />
<property name="c.file" value="ant/c.fileset" />
<property name="e.file" value="ant/e.fileset" />
<available property="c.file.exists" file="${c.file}" />
<available property="d.file.exists" file="${d.file}" />
<available property="e.file.exists" file="${e.file}" />
<path id="classPathRef">
<fileset dir="${depot.dir}">
<includesfile name="${c.file}" if="c.file.exists" />
<includesfile name="${d.file}" if="d.file.exists" />
<includesfile name="${e.file}" if="e.file.exists" />
</fileset>
</path>
</target>
I'd recommend checking out the use of ivy to manage your classpaths.
In your build file use the retrieve command to copy the jars into dedicated directories:
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]"/>
Note the conf parameter. This refers to an ivy configuration (similar to scope in Maven). It allows you to classify each of the jars you depend on.
Now that each collection of jars are conveniently located in separate directories the declaration of the paths in your build file becomes trivial:
<path id="compile.path">
<fileset dir="${lib.dir}/compile"/>
</path>
<path id="test.path">
<fileset dir="${lib.dir}/test"/>
</path>
<path id="runtime.path">
<fileset dir="${lib.dir}/runtime"/>
</path>
The complexity of defining the jar groupings is delegated to ivy and it's configuration management:
Here's an example of the controlling ivy.xml file
<ivy-module version="2.0">
<info organisation="apache" module="hello-ivy"/>
<configurations>
<conf name="compile" description="Libraries needed for compilation"/>
<conf name="runtime" extends="compile" description="Libraries that should be included when deploying the code" />
<conf name="test" extends="runtime" description="Additional test libraries, not deployed" />
</configurations>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.0" conf="build->default"/>
<dependency org="commons-cli" name="commons-cli" rev="1.0" conf="build->default"/>
<dependency org="junit" name="junit" rev="4.7" conf="test->default"/>
</dependencies>
</ivy-module>
The magic bits are the conf attributes associated with each dependency. For example Junit has been declared to be part of the test which means it only appears in the test path. The others will appear in all 3 paths, due to the manner in which the configurations have been declared.