|
|
There is a Perl script javanlp/bin/gen-dependencies.pl in the repository which can generate JAR files containing just those .class or .java files that are needed in order to run some set of classes. It does this by calling on three components: DependencyExtractor, which is part of the Dependency Finder package at depfind.sourceforge.net; DepedencyAnalyzer, which lives in edu/stanford/nlp/misc, and which I wrote to parse DependencyExtractor's output and generate a transitive dependency closure; and the 'jar' command. To run it, you'll need to update your tree and do a compile to get the DependencyAnalyzer component.
Here's a typical usage to generate a JAR file that contains all the files necessary for running CMMClassifier:
jacob:~/javanlp> perl bin/gen-dependencies.pl -srcdir src/ -classdir classes/ -srcjar ~/mySrcJar.jar -classjar ~/myClassJar.jar edu.stanford.nlp.ie.ner.CMMClassifier -jarfile CMMClassifier.jar
#####
EXTRACTING DEPENDENCIES
#####
Dependency dump file:
./depdump
java -classpath /u/nlp/java/liball/DependencyFinder.jar:/u/nlp/java/lib/jakarta-oro.jar:/u/nlp/java/liball/log4j.jar:/u/nlp/java/liball/xalan.jar:/u/nlp/java/liball/xercesImpl.jar:/u/nlp/java/liball/xml-apis.jar com.jeantessier.dependencyfinder.cli.DependencyExtractor -maximize -out ./depdump classes/
log4j:WARN No appenders could be found for logger (com.jeantessier.classreader.PermissiveDispatcher).
log4j:WARN Please initialize the log4j system properly.
#####
GENERATING CLOSURE
#####
Dependency dump file:
./depdump
Starting classes:
edu.stanford.nlp.ie.ner.CMMClassifier
java edu.stanford.nlp.misc.DependencyAnalyzer ./depdump edu.stanford.nlp.ie.ner.CMMClassifier
Class list:
[*SNIP*]
#####
GENERATING JAR FILE
#####
JAR file:
/user/grenager/myClassJar.jar
DependencyExtractor will generate a large (~40MB) file containing a textual dump of all the dependencies in the tree. By default, this will get written to the file "./depdump". You can direct it somewhere else with the "-depdump" argument.
You can get a sort of man page for the program by running it without arguments, or by running it with no arguments. Here's the complete usage information:
gen-dependencies.pl [-depdump ]
[-reusedepdump ] [-classjar ]
[-classdir ] [-classlistfile ]
[-srcjar ] [-srcdir ] [-javadocdir ]
[class]...
Analyzes class dependencies, generates a transitive dependency closure,
and generates a JAR file containing all necessary classes.
-depdump F
Output dependency dump generated by DependencyExtractor to file F.
Default is "./depdump". This option is mutually exclusive with
-reusedepdump.
-reusedepdump F
Re-use the dependency dump in file F that was originally generated
with -depdump. This dependency graph will not reflect any changes
made to the code since the dependency dump was generated.
This option is mutually exclusive with -depdump.
-classjar F
Create JAR file with name F containing all the class files in the
dependency closure. If not specified, no class JAR file will
be created.
-classdir D
Root directory of .class file hierarchy. Default is the current
directory.
-classlistfile F
F contains a list of classes, one per line, in fully-qualified dotted
notation (e.g., edu.stanford.nlp.misc.Counter). Lines beginning with '#'
are ignored. The listed classes will be used as the starting set of
the dependency closure. If this argument is not specified, at least one
class must be specified on the command line.
-srcdir D
Root directory of source file hierarchy. Default is the current
directory.
-srcjar F
Create JAR file with name F containing all the source files
in the dependency closure. If not specified, no source JAR file will
be created.
-javadocdir D
Create javadocs for all the source files and packages used in
the dependency closure, and put them in D. If not specified,
no javadocs will be created.
[class]...
List of classes to be used as the starting set for the dependency
closure. This can be used instead of, or in addition to, the
-classlistfile option. Classes are given in fully-qualified
dotted notation, for example edu.stanford.nlp.util.Counter.
|
Local links: NLP lunch · PAIL lunch · NLP Reading Group · JavaNLP (javadocs) · machines · Wiki |
Site design by Bill MacCartney |