Discussion:
[XOM-interest] split jars
Elliotte Rusty Harold
2010-04-03 23:39:26 UTC
Permalink
Does anyone happen to know how to write a jar task in Ant that would
bundle up everything in src/nu/xom except nu/xom/tests, nu/xom/tools,
nu/xom/samples, and nu/xom/pantry? This is a prerequisite for an
upgraded maven package.

I've been able to get Ant to exclude one directory, but not all of them.

This, for example, does not work:

<jar destFile="${sources.jar}" basedir="${build.dir}/src"
excludes="**/tests/**, **/tools/**"/>

It excludes tests but not tools. Contrary to all rational expectation
this also excludes tests but not tools:

<jar destFile="${sources.jar}" basedir="${build.dir}/src"
excludes="**/tools/**, **/tests/**"/>

I have not been able to make any rational sense out of which
directories Ant excludes when. :-(
--
Elliotte Rusty Harold
elharo at ibiblio.org
alanhzone-xom
2010-04-04 02:48:39 UTC
Permalink
Try this:


??????? <jardestFile="${sources.jar}" basedir="${build.dir}/src" >
??????????? <fileset dir=".">
??????????????? <include name= "**/src/**" />
??????????????? <exclude name= "**/tools/**" />
??????????????? <exclude name= "**/test/**" />
??????????? </fileset>
??????? </jar>

I think you'll get what you're looking for.

alan


--- On Sat, 4/3/10, Elliotte Rusty Harold <elharo at ibiblio.org> wrote:

From: Elliotte Rusty Harold <elharo at ibiblio.org>
Subject: [XOM-interest] split jars
To: "XOM interest" <xom-interest at lists.ibiblio.org>
Date: Saturday, April 3, 2010, 5:39 PM

Does anyone happen to know how to write a jar task in Ant that would
bundle up everything in src/nu/xom except nu/xom/tests, nu/xom/tools,
nu/xom/samples, and nu/xom/pantry? This is a prerequisite for an
upgraded maven package.

I've been able to get Ant to exclude one directory, but not all of them.

This, for example, does not work:

? ? <jar destFile="${sources.jar}" basedir="${build.dir}/src"
excludes="**/tests/**, **/tools/**"/>

It excludes tests but not tools. Contrary to all rational expectation
this also excludes tests but not tools:

? ? <jar destFile="${sources.jar}" basedir="${build.dir}/src"
excludes="**/tools/**, **/tests/**"/>

I have not been able to make any rational sense out of which
directories Ant excludes when. :-(
--
Elliotte Rusty Harold
elharo at ibiblio.org
Elliotte Rusty Harold
2010-04-04 13:15:12 UTC
Permalink
Post by alanhzone-xom
<jardestFile="${sources.jar}" basedir="${build.dir}/src" >
<fileset dir=".">
<include name= "**/src/**" />
<exclude name= "**/tools/**" />
<exclude name= "**/test/**" />
</fileset>
</jar>
I think you'll get what you're looking for.
Nope. Just tried it and this one excludes tools but not tests. :-(

At this point I'm willing to believe in either a bug or a design flaw in Ant
1.7.1.
--
Elliotte Rusty Harold
elharo at ibiblio.org
alanhzone-xom
2010-04-04 17:51:49 UTC
Permalink
Ok, sorry I messed the file structure on my last test so it looked like it was working. reread the doc for the jar task, and this should do what you need:

??????? <jar jarfile="${sources.jar}" basedir="${build.dir}/src">
??????????????? <exclude name= "nu/xom/tools/**" />
??????????????? <exclude name= "nu/xom/test/**" />
??????????????? <exclude name= "nu/xom/pantry/**" />
??????????????? <exclude name= "nu/xom/samples/**" />
??????? </jar>

alan

--- On Sun, 4/4/10, Elliotte Rusty Harold <elharo at ibiblio.org> wrote:

From: Elliotte Rusty Harold <elharo at ibiblio.org>
Subject: Re: [XOM-interest] split jars
To: alanhzone-xom at yahoo.com
Cc: xom-interest at lists.ibiblio.org
Date: Sunday, April 4, 2010, 7:15 AM



On Sat, Apr 3, 2010 at 10:48 PM, <alanhzone-xom at yahoo.com> wrote:

Try this:


??????? <jardestFile="${sources.jar}" basedir="${build.dir}/src" >
??????????? <fileset dir=".">

??????????????? <include name= "**/src/**" />
??????????????? <exclude name= "**/tools/**" />
??????????????? <exclude name= "**/test/**" />
??????????? </fileset>

??????? </jar>

I think you'll get what you're looking for.


Nope. Just tried it and this one excludes tools but not tests.? :-(


At this point I'm willing to believe in either a bug or a design flaw in Ant 1.7.1.
--
Elliotte Rusty Harold
elharo at ibiblio.org
Elliotte Rusty Harold
2010-04-04 23:06:11 UTC
Permalink
Post by alanhzone-xom
Ok, sorry I messed the file structure on my last test so it looked like it
was working. reread the doc for the jar task, and this should do what you
<jar jarfile="${sources.jar}" basedir="${build.dir}/src">
<exclude name= "nu/xom/tools/**" />
<exclude name= "nu/xom/test/**" />
<exclude name= "nu/xom/pantry/**" />
<exclude name= "nu/xom/samples/**" />
</jar>
Thank you! That did it.

I was tearing my hair out over this one.

I'll probably release 1.2.5 soon, and then see if the maven folks accept
this one.
--
Elliotte Rusty Harold
elharo at ibiblio.org
Dave Pawson
2010-04-05 07:28:32 UTC
Permalink
Post by Elliotte Rusty Harold
? ? ? ? <jar jarfile="${sources.jar}" basedir="${build.dir}/src">
? ? ? ? ? ? ? ? <exclude name= "nu/xom/tools/**" />
? ? ? ? ? ? ? ? <exclude name= "nu/xom/test/**" />
? ? ? ? ? ? ? ? <exclude name= "nu/xom/pantry/**" />
? ? ? ? ? ? ? ? <exclude name= "nu/xom/samples/**" />
? ? ? ? </jar>
Thank you! That did it.
I was tearing my hair out over this one.
http://ant.apache.org/manual/CoreTasks/jar.html

Think of a four letter acronym Elliotte.

regards
--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk
Loading...