Excluding jars from .war files generated

393 views
Skip to first unread message

Soupdragon

unread,
Sep 22, 2010, 5:13:56 AM9/22/10
to usr-ivybeans
When building web applications I commonly want to exclude some of the
jar files needed for compilation because I know they are already in
the server's shared library area, in particular the library containing
the J2EE stuff, like the servlet interfaces, clearly should be
excluded.

In normal Netbeans projects there's a check box on the libraries tab
rows for the library to be included in the war file.

Any equivalent for IvyBeans?


Laurent Forêt

unread,
Sep 22, 2010, 5:54:52 AM9/22/10
to usr-iv...@googlegroups.com
You do not need a check box. But you need a customized configuration.

It is similar to the maven scope "provided". I suppose you can create a "provided" configuration in your ivy.xml and map correctly with the netbeans scope (http://ivybeans.googlecode.com/svn/trunk/docs/resources/properties.jpg)


Hope it helps.

Laurent Forêt
http://www.devcoop.fr,
http://laurentforet.org
IvyBeans Creator
Membre du JUG Bordeaux




--
You received this message because you are subscribed to the Google Groups "usr-ivybeans" group.
To post to this group, send email to usr-iv...@googlegroups.com.
To unsubscribe from this group, send email to usr-ivybeans...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/usr-ivybeans?hl=en.


Soupdragon

unread,
Sep 22, 2010, 8:19:42 AM9/22/10
to usr-ivybeans
Thanks. I'll give it a go.


On Sep 22, 10:54 am, Laurent Forêt <laurent.fo...@gmail.com> wrote:
> You do not need a check box. But you need a customized configuration.
>
> It is similar to the maven scope "provided". I suppose you can create a
> "provided" configuration in your ivy.xml and map correctly with the netbeans
> scope (http://ivybeans.googlecode.com/svn/trunk/docs/resources/properties.jpg)
>
> Hope it helps.
>
> Laurent Forêthttp://www.devcoop.fr,http://laurentforet.org
> IvyBeans Creator
> Membre du JUG Bordeaux
>
> On Wed, Sep 22, 2010 at 11:13 AM, Soupdragon <Malcolm.McMa...@costcutter.com
>
> > wrote:
> > When building web applications I commonly want to exclude some of the
> > jar files needed for compilation because I know they are already in
> > the server's shared library area, in particular the library containing
> > the J2EE stuff, like the servlet interfaces, clearly should be
> > excluded.
>
> > In normal Netbeans projects there's a check box on the libraries tab
> > rows for the library to be included in the war file.
>
> > Any equivalent for IvyBeans?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "usr-ivybeans" group.
> > To post to this group, send email to usr-iv...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > usr-ivybeans...@googlegroups.com<usr-ivybeans%2Bunsu...@googlegroups.com>
> > .

Soupdragon

unread,
Sep 23, 2010, 6:41:51 AM9/23/10
to usr-ivybeans
Well, I've tried it.

I edited project.xml as follows:

<ivyConfiguration xmlns="http://code.google.com/p/ivybeans/ns/
ivy-module/1">
<descriptorFile>ivy.xml</descriptorFile>
<settingsFile>C:\s3resolv\ivysettings.xml</settingsFile>
<configurationMapping>
<scope confs="compile,provided" name="COMPILE"/>
<scope confs="compile,runtime" name="RUNTIME"/>
<scope confs="compile,compile-test"
name="COMPILE_TEST"/>
<scope confs="compile,compile-test,runtime,runtime-
test,provided" name="RUNTIME_TEST"/>
</configurationMapping>
</ivyConfiguration>

and the ivy.xml looks like:

<configurations>
<conf name="provided"/>
<conf name="compile"/>
<conf name="runtime"/>
<conf name="compile-test"/>
<conf name="runtime-test"/>
</configurations>
<dependencies>
<dependency org="apache" name="commons-logging" rev="1.1"
conf="provided->default" />
<dependency org="springsource" name="spring-framework"
rev="2.5.6" conf="compile->default" />
<dependency org="springsource" name="spring-web" rev="2.5.6"
conf="compile->default" />
<dependency org="amazon" name="aws-sdk" rev="1.0.004"
conf="compile->default" />
<dependency org="soupdragon" name="base64" rev="1.0"
conf="provided->default;runtime-test->default" />
<dependency org="sun" name="openmq" rev="1.0" conf="compile-
>default" />
<dependency org="json" name="json-parser" rev="1.0"
conf="compile->default" />
<dependency org="costcutter" name="mercury-jms" rev="1.1.1"
conf="" />
<dependency org="costcutter" name="awslib" rev="1.0" conf="" /
>
</dependencies>

And yet both the commons logging and the base-64 have found their way
into the war file.

Now, in the case of the commons logging, it may be because one or more
of the other libraries has it as a dependency. Of course that doesn't
stop it being a problem.

In the case of the base64 library, though, I don't think any
dependencies would invoke it.

Another symptom: on the ivy tab of the project properties the scope
list hasn't changed to reflect the changes in project.xml




On Sep 22, 10:54 am, Laurent Forêt <laurent.fo...@gmail.com> wrote:
> You do not need a check box. But you need a customized configuration.
>
> It is similar to the maven scope "provided". I suppose you can create a
> "provided" configuration in your ivy.xml and map correctly with the netbeans
> scope (http://ivybeans.googlecode.com/svn/trunk/docs/resources/properties.jpg)
>
> Hope it helps.
>
> Laurent Forêthttp://www.devcoop.fr,http://laurentforet.org
> IvyBeans Creator
> Membre du JUG Bordeaux
>
> On Wed, Sep 22, 2010 at 11:13 AM, Soupdragon <Malcolm.McMa...@costcutter.com
>
> > wrote:
> > When building web applications I commonly want to exclude some of the
> > jar files needed for compilation because I know they are already in
> > the server's shared library area, in particular the library containing
> > the J2EE stuff, like the servlet interfaces, clearly should be
> > excluded.
>
> > In normal Netbeans projects there's a check box on the libraries tab
> > rows for the library to be included in the war file.
>
> > Any equivalent for IvyBeans?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "usr-ivybeans" group.
> > To post to this group, send email to usr-iv...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > usr-ivybeans...@googlegroups.com<usr-ivybeans%2Bunsu...@googlegroups.com>
> > .

Soupdragon

unread,
Sep 23, 2010, 9:00:41 AM9/23/10
to usr-ivybeans
Found a slightly clutzy work-around (may need tweaking for later
netbeans releases.)

I've simply overridden the ant task that builds the war file in
build.xml as:

<target depends="init,compile,compile-jsps,-pre-dist"
if="do.war.package.with.custom.manifest" name="-do-dist-with-
manifest">
<dirname file="${dist.war}" property="dist.jar.dir"/>
<mkdir dir="${dist.jar.dir}"/>
<jar compress="${jar.compress}" jarfile="${dist.war}"
manifest="${build.meta.inf.dir}/MANIFEST.MF">
<fileset dir="${build.web.dir}">
<exclude name="WEB-INF/lib/commons-logging*"/>
<exclude name="WEB-INF/lib/base64*"/>
</fileset>
</jar>
</target>

It's copied from build-impl.xml and the exclusions added.

After looking through the ivybeans ant stuff it's clear that the
source libraries are resolved into the WEB-INF/lib directory in the
build directory, and while that's true it's bound to wind up in the
war file.


Bruce Chapman

unread,
Sep 24, 2010, 1:12:03 AM9/24/10
to usr-iv...@googlegroups.com
Yes.

We need to improve that.

We could retrieve to another location, then copy the runtime scoped
configs into the lib explicitly later (but before -do-dist-* tasks)

What I do currently for web projects, is to not use ivybeans. Just
modify the netbeans ant tasks in the usual way to retrieve the
dependencies early on in the build, and place these in a libs directory
somewhere, then use the normal netbeans library stuff to add those jars,
including or excluding in war as desired.

Bruce

Reply all
Reply to author
Forward
0 new messages