Kundig Andréas wrote:
Hello
I want to use ivy in several existing WSAD projects.
There are war projects, and ear projects which refer to the wars.
A war project needs to know which jars he puts in the WEB-INF/lib directory
for distribution,
which jars are distributed by the ear (the war must refer to them in the
META-INF/MANIFEST.MF file)
and which jars he needs only for compilation (the jars the server provides to
all ears).
An ear project needs to know which jars he distributes.
I am trying to keep all the information about jar dependencies in the ant/ivy
system.
Is this possible ?
yes, you need to define separate confs for things you want to package
(log4j.jar, etc) from stuff you expect to be there (javaee.jar), your
compile conf depends on both, but you only want some stuff in the runtime:
Here's one for a WAR file, from the forthcoming Ant-in-Action book:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="../xml/ivy-doc.xsl"?>
<ivy-module version="1.0">
<!--
The ivy file for the self-contained WAR file
-->
<info organisation="org.antbook" module="diary"/>
<configurations defaultconfmapping="default">
<conf name="default" extends="master,runtime"/>
<conf name="compile" visibility="private"/>
<conf name="test" extends="compile" visibility="private"/>
<conf name="master" description="contains the artifact but no
dependencies"/>
<conf name="runtime"
description="contains the runtime dependencies but not the
artifacts"/>
<conf name="war" description="war file libraries"
visibility="private"/>
<conf name="jing" description="libraries for the jing task"
visibility="private"/>
</configurations>
<publications>
<!-- the artifact is only produced in the master distro, and it is
a WAR file-->
<artifact conf="master" type="war" />
</publications>
<dependencies>
<!-- we dont want any dependencies at compile or runtime-->
<dependency org="org.antbook"
name="diary-core"
rev="latest.integration"
changing="true"
conf="compile->master;runtime->master;war->master"/>
<dependency org="javax.servlet"
name="servlet-api"
rev="${servlet-api.version}"
conf="compile->master"/>
<dependency org="rome"
name="rome"
rev="${rome.version}"
conf="compile->master;runtime->default;war->default"/>
<!--artifacts for testing-->
<dependency org="httpunit"
name="httpunit"
rev="${httpunit.version}"
conf="test->default">
<exclude org="xerces"/>
</dependency>
<dependency org="junit"
name="junit"
rev="${junit.version}"
conf="test->default"/>
<!--
jing is needed for XML validation
-->
<dependency org="thaiopensource"
name="jing"
rev="${jing.version}"
conf="jing->default"/>
</dependencies>
</ivy-module>
Returning to WAR/EARs. I dont hink you need to have the WAR file refer
to stuff in the EAR in its manifest, not if the EAR manifest declares
them. That gets easier with Java EE 5, but is possible in the predecessors
-steve