You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Aaron Kelley <ak...@ecsplus.com> on 2002/12/17 03:09:47 UTC

Problem with ClassFileSet

I still cannot get the ClassFileSet to work.  I am most likely doing
something incorrect.  Here is how I am using it:
 
<delete file="${cvs.package}.jar"/>
 
<classfileset id="reqClasses" dir="/build/mylib/classes"
includes="**/*.class">
    <rootfileset dir="/build/myclient/classes" includes="**/*.class"/>
</classfileset>
 
<jar destfile="${cvs.package}.jar">
 
    <fileset refid="reqClasses"/>
 
    <fileset dir="/build/myclient/classes"
             excludes="**/*Test*,**/test/"
    />
</jar>
 
These are both in a target together that is being called.
 
This is what I am seeing in the log (when I run with the debug option.)
 
fileset: Setup scanner in dir /build/myclient/classes with patternSet{
includes: [**/*.class] excludes: [] }
classfileset: Setup scanner in dir /build/mylib/classes with patternSet{
includes: [**/*.class] excludes: [] }
fileset: Setup scanner in dir /build/myclient/classes with patternSet{
includes: [] excludes: [**/*Test*, **/test/] }
 
After the last entry, it starts including files (which is not the
classfileset), but as you can see, none are included for the first two.
So what am I doing wrong?
 
Aaron

RE: Problem with ClassFileSet

Posted by Aaron Kelley <ak...@ecsplus.com>.
Actually, I originally tried it without the includes.  I only had them
in this example because I was trying to be thorough.  I have tried the
includes on each set and every combination and always the same results.
The ClassFileSet extends from FileSet and includes only *.class by
default.  So it probably was redundant, but in either case, I cannot get
it to work.

Aaron

-----Original Message-----
From: Vilya Harvey [mailto:vilya.harvey@digitalsteps.com] 
Sent: Tuesday, December 17, 2002 7:16 AM
To: Ant Users List
Subject: Re: Problem with ClassFileSet

See inline comments below. Hope they help...

Vil.

----- Original Message -----
From: "Aaron Kelley" <ak...@ecsplus.com>
To: <an...@jakarta.apache.org>
Sent: Tuesday, December 17, 2002 2:09 AM
Subject: Problem with ClassFileSet


> I still cannot get the ClassFileSet to work.  I am most likely doing
> something incorrect.  Here is how I am using it:
>
> <delete file="${cvs.package}.jar"/>
>
> <classfileset id="reqClasses" dir="/build/mylib/classes"
> includes="**/*.class">
>     <rootfileset dir="/build/myclient/classes" includes="**/*.class"/>
> </classfileset>

Don't use the includes attribute on the <classfileset> tag. This
attribute,
which I'm guessing is inherited from <fileset>, seems to take precedence
over any nested specification of the files to include; that means you'll
get
exactly the files you specify in the attribute, without any
dependencies. Is
that the incorrect behaviour you're seeing?


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with ClassFileSet

Posted by Vilya Harvey <vi...@digitalsteps.com>.
See inline comments below. Hope they help...

Vil.

----- Original Message -----
From: "Aaron Kelley" <ak...@ecsplus.com>
To: <an...@jakarta.apache.org>
Sent: Tuesday, December 17, 2002 2:09 AM
Subject: Problem with ClassFileSet


> I still cannot get the ClassFileSet to work.  I am most likely doing
> something incorrect.  Here is how I am using it:
>
> <delete file="${cvs.package}.jar"/>
>
> <classfileset id="reqClasses" dir="/build/mylib/classes"
> includes="**/*.class">
>     <rootfileset dir="/build/myclient/classes" includes="**/*.class"/>
> </classfileset>

Don't use the includes attribute on the <classfileset> tag. This attribute,
which I'm guessing is inherited from <fileset>, seems to take precedence
over any nested specification of the files to include; that means you'll get
exactly the files you specify in the attribute, without any dependencies. Is
that the incorrect behaviour you're seeing?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with ClassFileSet

Posted by Frank-Michael Moser <mo...@decodon.com>.
Frank-Michael Moser wrote:
> 
> You will see that GenJar (and the current version of classpath, too) now 
> is able to pick up MyClass as dependency automatically.
> 
TYPO WARNING: please replace classpath by classfileset :-)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Problem with ClassFileSet

Posted by Aaron Kelley <ak...@ecsplus.com>.
Changing the code is not an option.  Not all of it is my code (many
developers) and the number of projects we are building is getting pretty
massive.  Also, we have an odd convention where Views are loaded from
Modules.  The View is loaded way back in a base class by a naming
convention.  So this would not work either.

Aaron

-----Original Message-----
From: Frank-Michael Moser [mailto:moser@decodon.com] 
Sent: Thursday, December 19, 2002 9:02 AM
To: Ant Users List
Subject: Re: Problem with ClassFileSet

How about a workaround: To all your source-files which contain a 
declaration like

  MyClass.class

add a dummy member

  MyClass myClassDummy;

You will see that GenJar (and the current version of classpath, too) now

is able to pick up MyClass as dependency automatically.

I don't know if this is an option for you, but however it is a generic 
and simple work-around.

Frank-Michael


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with ClassFileSet

Posted by Frank-Michael Moser <mo...@decodon.com>.
Aaron Kelley wrote:
> The problem with that (at least for me) is that you have to list all the
> individual classes you want to be included as dependencies.  My classes
> that form my dependencies load each other dynamically.  This means that
> I would have to list 30 classes out.  As far as I am aware, it does not
> allow you to define a set of classes by just pointing it at a folder.
> Since I am doing all this for automated building on many projects, it
> will not work at all (I would have to constantly change the build
> script).
> 

How about a workaround: To all your source-files which contain a 
declaration like

  MyClass.class

add a dummy member

  MyClass myClassDummy;

You will see that GenJar (and the current version of classpath, too) now 
is able to pick up MyClass as dependency automatically.

I don't know if this is an option for you, but however it is a generic 
and simple work-around.

Frank-Michael


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Problem with ClassFileSet

Posted by Aaron Kelley <ak...@ecsplus.com>.
The problem with that (at least for me) is that you have to list all the
individual classes you want to be included as dependencies.  My classes
that form my dependencies load each other dynamically.  This means that
I would have to list 30 classes out.  As far as I am aware, it does not
allow you to define a set of classes by just pointing it at a folder.
Since I am doing all this for automated building on many projects, it
will not work at all (I would have to constantly change the build
script).

Aaron

-----Original Message-----
From: Frank-Michael Moser [mailto:moser@decodon.com] 
Sent: Thursday, December 19, 2002 8:38 AM
To: Ant Users List
Subject: Re: Problem with ClassFileSet

Aaron Kelley wrote:
> 
> I think that would make the most sense.  I am new to ant and so far I
> have been able to figure everything out, but this does not seem
> intuitive.  Also, pulling stuff out of jars would be a cool feature.
I
> extracted all my jars to one directory, which works, but again it
would
> be nice if it was not required.
> 

How about the GenJar task:

http://genjar.sourceforge.net/



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with ClassFileSet

Posted by Frank-Michael Moser <mo...@decodon.com>.
Aaron Kelley wrote:
> 
> I think that would make the most sense.  I am new to ant and so far I
> have been able to figure everything out, but this does not seem
> intuitive.  Also, pulling stuff out of jars would be a cool feature.  I
> extracted all my jars to one directory, which works, but again it would
> be nice if it was not required.
> 

How about the GenJar task:

http://genjar.sourceforge.net/



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Problem with ClassFileSet

Posted by Aaron Kelley <ak...@ecsplus.com>.


>I guess you could make an argument for using the bytecodes from the 
>rootfileset rather than in the main set. I'm open to suggestions as to
how 
>this should work and what enhancements it can support - e.g. pulling
stuff 
>out of jars, other paths, etc.

I think that would make the most sense.  I am new to ant and so far I
have been able to figure everything out, but this does not seem
intuitive.  Also, pulling stuff out of jars would be a cool feature.  I
extracted all my jars to one directory, which works, but again it would
be nice if it was not required.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with ClassFileSet

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Aaron Kelley wrote:
> If I copy all my classes from my rootfileset to the classfileset
> directory it works.  Why is that?  

The root fileset is about determining which classes are the root classes - 
this works as you expect. Internally the task produces a list of class names 
from the rootfileset, e.g.

org.apache.tools.ant.Project
org.apache.tools.ant.Task

This is all the rootfileset is used for. The classes are detemrined from 
their filenames and not by reading the bytecodes.

These class names are then searched for within the main classfileset dir. If 
they are not found, no information is known about the classes. Internally 
the task is structured in this two phase approach (1. determine classes to 
examine, 2. read in bytecodes of classes.

I guess you could make an argument for using the bytecodes from the 
rootfileset rather than in the main set. I'm open to suggestions as to how 
this should work and what enhancements it can support - e.g. pulling stuff 
out of jars, other paths, etc.

> So is this the
> correct solution then?  Just do a copy before I build the JAR?

It is *A* solution with the current task, yes.

Conor



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Problem with ClassFileSet

Posted by Aaron Kelley <ak...@ecsplus.com>.
If I copy all my classes from my rootfileset to the classfileset
directory it works.  Why is that?  I thought that it built all the
dependencies from the rootfileset and then looked for them in the
classfileset.  I must not understand how it works.  So is this the
correct solution then?  Just do a copy before I build the JAR?

Thanks for your input.

Aaron

-----Original Message-----
From: Conor MacNeill [mailto:conor@cortexebusiness.com.au] 
Sent: Wednesday, December 18, 2002 7:46 AM
To: Ant Users List
Subject: Re: Problem with ClassFileSet

Aaron Kelley wrote:
> I still cannot get the ClassFileSet to work.  I am most likely doing
> something incorrect.  Here is how I am using it:
>  
> <delete file="${cvs.package}.jar"/>
>  
> <classfileset id="reqClasses" dir="/build/mylib/classes"
> includes="**/*.class">
>     <rootfileset dir="/build/myclient/classes" includes="**/*.class"/>
> </classfileset>
> 

The issue is probably that the rootfileset has a different basedir from
the 
classfileset - why is that? I can't say what classes are common to the
two 
dirs. If the classes from build/myclient/classes are not found also in 
build/mylib/classes it is likely that you will end up with an empty set.

Conor


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with ClassFileSet

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Aaron Kelley wrote:
> I still cannot get the ClassFileSet to work.  I am most likely doing
> something incorrect.  Here is how I am using it:
>  
> <delete file="${cvs.package}.jar"/>
>  
> <classfileset id="reqClasses" dir="/build/mylib/classes"
> includes="**/*.class">
>     <rootfileset dir="/build/myclient/classes" includes="**/*.class"/>
> </classfileset>
> 

The issue is probably that the rootfileset has a different basedir from the 
classfileset - why is that? I can't say what classes are common to the two 
dirs. If the classes from build/myclient/classes are not found also in 
build/mylib/classes it is likely that you will end up with an empty set.

Conor


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>