[Cook] Cook and Java.... the pain continues
Matthew Lee
leematthewrobert at yahoo.com.au
Sat Apr 10 15:44:09 EST 2004
[cross-posted from aegis-users, since this is more relevant to cook users]
Walter Franzini wrote:
>Matthew Lee <leematthewrobert at yahoo.com.au> writes:
>
>[...]
>
>
>
>>Perhaps what we need is j_incl (c_incl clone for java)? Any
>>volunteers?? :-)
>>
>>
>
>A quick google search:
>
>http://www.vet.com.au/java/javadeps/
>
>Maybe a wrapper sould be enough.
>
>Never used :-)
>
This is a bit long and rambling. Hopefully someone will persist and
offer advice?
Continuing my quest to get a reasonably large Java project to build
under cook, I've tried JavaDeps as a dependency generator. (Please
excuse my Java ignorance in the following explanation.... I don't write
this code, but I'm maintaining the build system).
I've got several C++ projects that generate dependency files using the
cascade method (as described in the user's guide). Naturally, I'm
trying to do something similar with Java.
JavaDeps generates a file of the form:
# Some comments
one or more .class filenames : one or more .class and one or more .java
filenames
CLASSES = \
list of class files
I've included some recipes here. Maybe we can get a collaborative
effort going to make cook and java play nice together?
Here is the recipe I've used to generate the JavaDeps output:
java/src/deps.javadeps :
[match_mask java/src/%0%.java [manifest]]
set no-cascade
{
java -jar /home/matt/install/JavaDeps-1.1/jdeps.jar
--dir\=java/bin -n -o [target]
[resolve [match_mask java/src/%0%.java [manifest]]];
}
And here is the recipe I've used to convert that file into one more
acceptable to cook:
java/src/deps.d : java/src/deps.javadeps
{
sed -e '/^CLASSES/,\\$d' /* Delete from "CLASSES" to end of file */
-e '/^#/d' /* Delete commented lines */
-e 's/^java/cascade\\ java/' /* Add cascade to front of each line */
-e 's/:/\\ =/' /* Change '=' to ';' */
-e 's/bl\\\\///g' /* Get rid of 'bl/' from paths */
-e 's/$/\\;/' /* Add a semicolon onto end of every line */
-e 's/^\\;$//' /* Delete semicolons*/
java/src/deps.javadeps > [target];
}
Here are a few example entries from the resultant file:
cascade java/bin/com/symbio/sona/core/data/Tokens.class =
java/src/core/data/Tokens.java;
cascade java/bin/com/symbio/sona/core/data/Record.class
java/bin/com/symbio/sona/core/data/SQL.class
java/bin/com/symbio/sona/core/data/Schema.class
java/bin/com/symbio/sona/core/data/Configuration.class
java/bin/com/symbio/sona/core/data/Log.class =
java/src/core/data/Record.java java/src/core/data/SQL.java
java/src/core/data/Schema.java java/src/core/data/Configuration.java
java/src/core/data/Log.java ;
So far, it all looks good.
In my cookbook, I've also got the following:
build-dep-file = java/src/deps.d;
#include-cooked [build-dep-file]
This is so that cook will "cook" my dependencies file. As an aside,
this is broken somehow. It's pretty much exactly like my C++ project,
but the recipes that generated my project manifest are not run before
the java dependency stuff, so I have to run "aeb" twice.
Since there are inter-dependencies within a package, we need to provide
all the java source files within a package to the java compiler. Here's
a recipe I've been using, prior to trying JavaDeps and using
hand-crafted dependencies. There is one of these for each package, with
dependencies on other packages hard-coded:
java/bin/com/symbio/sona/core/data/%1.class : java/src/core/data/%1.java
{
javac
-sourcepath [sourcepath]
-classpath [classpath]
-d java/bin
[resolve [match_mask java/src/core/data/%%1.java [manifest]]]
;
}
So, now with the JavaDeps generated dependency file, I should be able to
make a single, generic recipe:
java/bin/com/symbio/sona/%0%1.class :
[match_mask java/src/%0%%.java [manifest]]
{
javac
-sourcepath [sourcepath]
-classpath [classpath]
-d java/bin
[resolve [match_mask java/src/%0%%.java [manifest]]]
;
}
Here is where cook fails:
cook: javac -sourcepath ./java/src/:bl/java/src/:blbl/java/src/:blblbl/java/
src/ -classpath ./java/bin:bl/java/bin:blbl/java/bin:blblbl/java/
bin:bl/third-party/java/classes12.zip -d java/bin
bl/java/src/operations/cdr/io/ReaderExcel4_1.java
bl/java/src/operations/cdr/io/ReaderMysql.java
bl/java/src/operations/cdr/io/WriterExcel4_1.java
bl/java/src/operations/cdr/io/ReaderExcel4_1.java:17: package
com.symbio.sona.core.data does not exist
import com.symbio.sona.core.data.*;
So, the dependency that the com.symbio.sona.operations.cdr.io package
has on the com.symbio.sona.core.data package has not been detected and
it built first.
Relevant contents of the deps file show that the dependency does exist:
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
= java/src/operations/cdr/io/ReaderExcel4_1.java;
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
=
java/bin/com/symbio/sona/operations/cdr/CdrIteratorAbstract.class;
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
= java/bin/com/symbio/sona/core/data/GlobalDefs.class;
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
= java/bin/com/symbio/sona/core/data/Record.class
java/bin/com/symbio/sona/core/data/SQL.class
java/bin/com/symbio/sona/core/data/Schema.class
java/bin/com/symbio/sona/core/data/Configuration.class
java/bin/com/symbio/sona/core/data/Log.class ;
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
= java/bin/com/symbio/sona/operations/cdr/CdrStoreFile.class;
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
= java/bin/com/symbio/sona/operations/cdr/Cdr.class;
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
= java/bin/com/symbio/sona/operations/cdr/CdrVoiceSingle.class;
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
= java/bin/com/symbio/sona/core/data/CdrRawVoice.class;
cascade java/bin/com/symbio/sona/operations/cdr/io/ReaderExcel4_1.class
= java/bin/com/symbio/sona/core/data/Utils.class;
So that's as far as I've got. Any assistance is much appreciated.
Regards,
Matt
More information about the Cook-users
mailing list