views:

51

answers:

2

Hi.

I have 204 total classes (most of the classes are inner classes). For months, I have been building fine with SCons (SCons just calls the jar command).

For some reason, it stopped adding the last inner class for a particular class. For example, suppose I have the following classes:

class1
class2
class3
class4
class5
class6
...
class79
class80

Before this last change, SCons would jar everything fine. But NOW... it specifically does not add class80 to it's jar command. (I see an omission of the class80 in the jar command).

Is there an instance where the jar command just ignores certain classes?

----------- EDIT. I found the culprit. For some reason this inner class is not recognized my SCons!

vehicleFilter = new RowFilter<Object, Object>(){ 
public boolean include(Entry<? extends Object, ? extends Object> entry)                {                                                 
    {return false;}  
};
A: 

SCons may construct a command line by listing all classes to jar on it and that may get too long (either a platform limitation or a heuristic inside SCons).

You need to peek inside the SCons package to see what goes on.

Any particular reason you don't just use ant?

Thorbjørn Ravn Andersen
Yes ... my project is mostly all C++ with this exception. I personally don't think it's the limit is too long (although 204 is pretty big). I've narrowed it down to the RowFilter Class. See My edited q
Carlo del Mundo
+1  A: 

Rather than pass a whole list of class files to the Jar command, you can pass a directory. This avoids problems with SCons's java parser as SCons will scan the directory for files and jar up anything it finds.

Something like the following will compile files in "src" to the directory "classes", then create a jar from the contents of "classes":

env = Environment(tools=['javac', 'jar'])
env.Java(target='classes', source='src')
env.Jar(target='foo.jar', source=['classes', 'Manifest.txt'],
        JARCHDIR='$SOURCE')

The manifest file "Manifest.txt" is in the root of your project here. The only requirement is that it begins with the text "Manifest-Version".

rq
Things get complicated if I had a Manifest.txt file in the mix. If I have this Manifest, and I want it to be the root level directory of my project (the dir before src/ and classes/), how would I accomplish this? SCons skips it if we let JARCHDIR to classes/
Carlo del Mundo
You can copy the manifest to the build dir (classes).
rq
In fact, no need to copy. I'll update the answer for manifests...
rq