You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Potje rode kool <ev...@gmail.com> on 2010/04/28 14:47:17 UTC

configuration

I am building an webapp and I am using ivy:cachefileset to compile and to
deploy.
Some jars are both needed for compilation and runtime others like el-api are
only needed at compile time
because Tomcat ships it allready. How can I configure this?

Thanks,
Evert

Re: configuration

Posted by Michael Shea <mi...@nitido.com>.
This is a situation where ivy configurations come in handy.

eg, your project could have two configurations: "compile" and "deploy", 
where "compile" extends from "deploy".

When you are building your war to deploy to tomcat, you only include the 
artifacts from the "deploy" configuration.

That's how I would do it, at least =).

http://ant.apache.org/ivy/history/latest-milestone/ivyfile/configurations.html


Mike Shea.

> I am building an webapp and I am using ivy:cachefileset to compile and to
> deploy.
> Some jars are both needed for compilation and runtime others like el-api are
> only needed at compile time
> because Tomcat ships it allready. How can I configure this?
>
> Thanks,
> Evert
>
>   


Re: configuration

Posted by Potje rode kool <ev...@gmail.com>.
Thanks Geoff,

Got thinks working now. I have a macro which I call to init the classpath.
>From my compile target I call
<initClassPath conf="compile,provided" classpathid="compile.classpath" />

>From my deploy target I call
<initClassPath conf="runtime" classpathid="deploy.classpath" />

All working nice now.

Cheers,
Evert

<macrodef name="initClassPath">
 <attribute name="conf" />
 <attribute name="classPathId" />
 <sequential>
  <initIvy/>
  <ivy:cachefileset
   setid="@{classPathId}"
   organisation="${ivy.organisation}"
   module="${ivy.module}"
   conf="@{conf}"
   settingsRef="basic.settings" />
 </sequential>
</macrodef>




2010/4/28 Geoff Clitheroe <g....@gmail.com>

>  On Thu, Apr 29, 2010 at 12:47 AM, Potje rode kool <
> everttigchelaar@gmail.com
> > wrote:
>
> > I am building an webapp and I am using ivy:cachefileset to compile and to
> > deploy.
> > Some jars are both needed for compilation and runtime others like el-api
> > are
> > only needed at compile time
> > because Tomcat ships it allready. How can I configure this?
> >
> > Thanks,
> > Evert
> >
>
>
> Hi,
>
> we do something very similar to Michael.  We have a 'provided' conf which
> is
> for artifacts that don't go into the war.
>
> An example ivy.xml from one of our web apps is below.  If the ant file for
> resolve and creating classpaths would be useful let me know.
>
> Cheers,
> Geoff
>
> <?xml version="1.0" encoding="UTF-8"?>
> <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:m="http://ant.apache.org/ivy/maven">
>
>    <info organisation="nz.org.geonet" module="delta-web" revision="2.0"/>
>
>    <configurations>
>
>        <conf name="default" visibility="public"
>            description="runtime dependencies and master artifact can be
> used with this conf"
>            extends="runtime,master"/>
>
>        <conf name="master" visibility="public"
>            description="contains only the artifact published by this module
> itself, with no transitive dependencies"/>
>
>        <conf name="compile" visibility="public"
>            description="this is the default scope, used if none is
> specified. Compile dependencies are available in all classpaths."/>
>
>        <conf name="provided" visibility="public"
>            description="this is much like compile, but indicates you expect
> the JDK or a container to provide it. It is only available on the co
> mpilation classpath, and is not transitive."/>
>
>        <conf name="runtime" visibility="public"
>            description="this scope indicates that the dependency is not
> required for compilation, but is for execution. It is in the runtime and
>  test classpaths, but not the compile classpath."
>            extends="compile"/>
>
>        <conf name="test" visibility="private"
>            description="this scope indicates that the dependency is not
> required for normal use of the application, and is only available for th
> e test compilation and execution phases."
>            extends="runtime"/>
>
>        <conf name="system" visibility="public"
>            description="this scope is similar to provided except that you
> have to provide the JAR which contains it explicitly. The artifact is
> always available and is not looked up in a repository."/>
>
>        <conf name="sources" visibility="public"
>            description="this configuration contains the source artifact of
> this module, if any."/>
>
>        <conf name="javadoc" visibility="public"
>            description="this configuration contains the javadoc artifact of
> this module, if any."/>
>
>        <conf name="foride" visibility="private"
>            description="this configuration contains the source and/or
> javadoc artifacts of this modules dependecies for use to provide documenta
> tion in IDE."/>
>
>        <conf name="optional" visibility="public" description="contains all
> optional dependencies"/>
>
>    </configurations>
>
>    <publications>
>        <artifact name="delta-web" type="war" ext="war" conf="master"/>
>        <artifact name="delta-web" type="source" ext="jar" conf="sources"
> m:classifier="sources"/>
>        <artifact name="delta-web" type="doc" ext="jar" conf="javadoc"
> m:classifier="javadoc"/>
>    </publications>
>
>    <dependencies>
>
>        <dependency org="nz.org.geonet" name="delta-data-access" rev="2.0.3"
> conf="compile->master; runtime->runtime; provided->provided; foride->sou
> rces" />
>
>        <dependency org="javax.servlet" name="servlet-api" rev="2.4"
> conf="provided->default" />
>
>        <dependency org="log4j" name="log4j" rev="1.2.15"
> conf="compile->master" />
>
>        <dependency org="org.springframework" name="spring" rev="1.2.7"
> conf="compile->default">
>            <exclude org="javax.mail" module="mail"/>
>            <exclude org="javax.activation" module="activation"/>
>            <!-- we get the version is not dependent on ams -->
>            <exclude org="cglib" module="cglib"/>
>            <exclude org="ant" module="ant"/>
>            <exclude org="junit" module="junit"/>
>            <!-- We use dbcp instead of ehcache -->
>            <exclude org="ehcache" module="ehcache"/>
>        </dependency>
>
>        <!-- If it's required this might be better from
> http://maven.geotools.fr/repository/ -->
>        <dependency org="nz.org.geonet-attic" name="gt2-arcsde"
> rev="2.2.3-SNAPSHOT" conf="runtime->default" />
>        <dependency org="nz.org.geonet-attic" name="gt2-main"
> rev="unknown-1" conf="compile->default"/>
>        <dependency org="nz.org.geonet-attic" name="gol-spatial"
> rev="unknown-1" conf="compile->default"/>
>
>        <dependency org="com.lowagie" name="itext" rev="1.3"
> conf="compile->default" />
>
>        <!-- These are tag libraries for tapestry (I think) -->
>        <dependency org="nz.org.geonet-attic" name="valid" rev="unknown-1"
> conf="runtime->default" />
>        <dependency org="nz.org.geonet-attic" name="manLibrary"
> rev="binary23Apr05" conf="runtime->default" />
>
>        <!-- Tapestry 3.0.2 required for compile. -->
>        <dependency org="tapestry" name="tapestry" rev="3.0.2"
> conf="compile->default" />
>
>        <!-- Tapestry runtime dependencies (from 3.0.3) -->
>        <dependency org="bsf" name="bsf" rev="2.3.0" conf="runtime->default"
> />
>        <dependency org="commons-beanutils" name="commons-beanutils"
> rev="1.6.1" conf="runtime->default" />
>        <dependency org="commons-codec" name="commons-codec" rev="1.2"
> conf="runtime->default" />
>        <dependency org="commons-collections" name="commons-collections"
> rev="2.1" conf="runtime->default" />
>        <dependency org="commons-digester" name="commons-digester" rev="1.5"
> conf="runtime->default" />
>        <dependency org="commons-fileupload" name="commons-fileupload"
> rev="1.0" conf="runtime->default" />
>        <dependency org="commons-lang" name="commons-lang" rev="1.0"
> conf="runtime->default" />
>        <dependency org="commons-logging" name="commons-logging" rev="1.0.2"
> conf="runtime->default" />
>        <dependency org="javassist" name="javassist" rev="3.4.GA<http://3.4.ga/>
> "
> conf="runtime->default" />
>        <dependency org="ognl" name="ognl" rev="2.6.7"
> conf="runtime->default" />
>        <dependency org="tapestry" name="tapestry-contrib" rev="3.0.2"
> conf="runtime->default" />
>
>
>        <!-- Required to build without netbeans present; ant will require
> the following definitions -->
>        <!-- -Dlibs.CopyLibs.classpath=lib-ivy/provided/copylibstask-6.5.jar
> -->
>        <!-- -Dj2ee.platform.classpath=lib-ivy/provided/servlet-api-2.4.jar
> -->
>        <dependency org="org.netbeans.modules.java.j2seproject"
> name="copylibstask" rev="6.5" conf="provided->default" />
>
>
>        <dependency org="org.fitnesse" name="fitnesse" rev="20081201"
> conf="test->default" />
>        <dependency org="tomcat" name="catalina-ant" rev="5.5.23"
> conf="test->default" transitive="false" />
>
>    </dependencies>
>
> </ivy-module>
>

Re: configuration

Posted by Geoff Clitheroe <g....@gmail.com>.
On Thu, Apr 29, 2010 at 12:47 AM, Potje rode kool <everttigchelaar@gmail.com
> wrote:

> I am building an webapp and I am using ivy:cachefileset to compile and to
> deploy.
> Some jars are both needed for compilation and runtime others like el-api
> are
> only needed at compile time
> because Tomcat ships it allready. How can I configure this?
>
> Thanks,
> Evert
>


Hi,

we do something very similar to Michael.  We have a 'provided' conf which is
for artifacts that don't go into the war.

An example ivy.xml from one of our web apps is below.  If the ant file for
resolve and creating classpaths would be useful let me know.

Cheers,
Geoff

<?xml version="1.0" encoding="UTF-8"?>
<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:m="http://ant.apache.org/ivy/maven">

    <info organisation="nz.org.geonet" module="delta-web" revision="2.0"/>

    <configurations>

        <conf name="default" visibility="public"
            description="runtime dependencies and master artifact can be
used with this conf"
            extends="runtime,master"/>

        <conf name="master" visibility="public"
            description="contains only the artifact published by this module
itself, with no transitive dependencies"/>

        <conf name="compile" visibility="public"
            description="this is the default scope, used if none is
specified. Compile dependencies are available in all classpaths."/>

        <conf name="provided" visibility="public"
            description="this is much like compile, but indicates you expect
the JDK or a container to provide it. It is only available on the co
mpilation classpath, and is not transitive."/>

        <conf name="runtime" visibility="public"
            description="this scope indicates that the dependency is not
required for compilation, but is for execution. It is in the runtime and
 test classpaths, but not the compile classpath."
            extends="compile"/>

        <conf name="test" visibility="private"
            description="this scope indicates that the dependency is not
required for normal use of the application, and is only available for th
e test compilation and execution phases."
            extends="runtime"/>

        <conf name="system" visibility="public"
            description="this scope is similar to provided except that you
have to provide the JAR which contains it explicitly. The artifact is
always available and is not looked up in a repository."/>

        <conf name="sources" visibility="public"
            description="this configuration contains the source artifact of
this module, if any."/>

        <conf name="javadoc" visibility="public"
            description="this configuration contains the javadoc artifact of
this module, if any."/>

        <conf name="foride" visibility="private"
            description="this configuration contains the source and/or
javadoc artifacts of this modules dependecies for use to provide documenta
tion in IDE."/>

        <conf name="optional" visibility="public" description="contains all
optional dependencies"/>

    </configurations>

    <publications>
        <artifact name="delta-web" type="war" ext="war" conf="master"/>
        <artifact name="delta-web" type="source" ext="jar" conf="sources"
m:classifier="sources"/>
        <artifact name="delta-web" type="doc" ext="jar" conf="javadoc"
m:classifier="javadoc"/>
    </publications>

    <dependencies>

        <dependency org="nz.org.geonet" name="delta-data-access" rev="2.0.3"
conf="compile->master; runtime->runtime; provided->provided; foride->sou
rces" />

        <dependency org="javax.servlet" name="servlet-api" rev="2.4"
conf="provided->default" />

        <dependency org="log4j" name="log4j" rev="1.2.15"
conf="compile->master" />

        <dependency org="org.springframework" name="spring" rev="1.2.7"
conf="compile->default">
            <exclude org="javax.mail" module="mail"/>
            <exclude org="javax.activation" module="activation"/>
            <!-- we get the version is not dependent on ams -->
            <exclude org="cglib" module="cglib"/>
            <exclude org="ant" module="ant"/>
            <exclude org="junit" module="junit"/>
            <!-- We use dbcp instead of ehcache -->
            <exclude org="ehcache" module="ehcache"/>
        </dependency>

        <!-- If it's required this might be better from
http://maven.geotools.fr/repository/ -->
        <dependency org="nz.org.geonet-attic" name="gt2-arcsde"
rev="2.2.3-SNAPSHOT" conf="runtime->default" />
        <dependency org="nz.org.geonet-attic" name="gt2-main"
rev="unknown-1" conf="compile->default"/>
        <dependency org="nz.org.geonet-attic" name="gol-spatial"
rev="unknown-1" conf="compile->default"/>

        <dependency org="com.lowagie" name="itext" rev="1.3"
conf="compile->default" />

        <!-- These are tag libraries for tapestry (I think) -->
        <dependency org="nz.org.geonet-attic" name="valid" rev="unknown-1"
conf="runtime->default" />
        <dependency org="nz.org.geonet-attic" name="manLibrary"
rev="binary23Apr05" conf="runtime->default" />

        <!-- Tapestry 3.0.2 required for compile. -->
        <dependency org="tapestry" name="tapestry" rev="3.0.2"
conf="compile->default" />

        <!-- Tapestry runtime dependencies (from 3.0.3) -->
        <dependency org="bsf" name="bsf" rev="2.3.0" conf="runtime->default"
/>
        <dependency org="commons-beanutils" name="commons-beanutils"
rev="1.6.1" conf="runtime->default" />
        <dependency org="commons-codec" name="commons-codec" rev="1.2"
conf="runtime->default" />
        <dependency org="commons-collections" name="commons-collections"
rev="2.1" conf="runtime->default" />
        <dependency org="commons-digester" name="commons-digester" rev="1.5"
conf="runtime->default" />
        <dependency org="commons-fileupload" name="commons-fileupload"
rev="1.0" conf="runtime->default" />
        <dependency org="commons-lang" name="commons-lang" rev="1.0"
conf="runtime->default" />
        <dependency org="commons-logging" name="commons-logging" rev="1.0.2"
conf="runtime->default" />
        <dependency org="javassist" name="javassist" rev="3.4.GA"
conf="runtime->default" />
        <dependency org="ognl" name="ognl" rev="2.6.7"
conf="runtime->default" />
        <dependency org="tapestry" name="tapestry-contrib" rev="3.0.2"
conf="runtime->default" />


        <!-- Required to build without netbeans present; ant will require
the following definitions -->
        <!-- -Dlibs.CopyLibs.classpath=lib-ivy/provided/copylibstask-6.5.jar
-->
        <!-- -Dj2ee.platform.classpath=lib-ivy/provided/servlet-api-2.4.jar
-->
        <dependency org="org.netbeans.modules.java.j2seproject"
name="copylibstask" rev="6.5" conf="provided->default" />


        <dependency org="org.fitnesse" name="fitnesse" rev="20081201"
conf="test->default" />
        <dependency org="tomcat" name="catalina-ant" rev="5.5.23"
conf="test->default" transitive="false" />

    </dependencies>

</ivy-module>