Dependency analysis

G

groupknowledge

I needed some help in figuring out how to approach the following
problem:
I am trying to use only some parts of a huge application. I am
basically using only one class in my simple application that belongs to
the huge app. Currently, I am having to manually import this class and
then import all its dependencies and check for their dependencies and
so on until all references are resolved. This is painful and I was
wondering if it there was a simple script (ANT or otherwise) that given
a particular java class, analyzes all the packages that are required to
compile it (recursively) successfully, jars them into a single file?
Thank you,
Gknowledge
 
L

Larry Barowski

I needed some help in figuring out how to approach the following
problem:
I am trying to use only some parts of a huge application. I am
basically using only one class in my simple application that belongs to
the huge app. Currently, I am having to manually import this class and
then import all its dependencies and check for their dependencies and
so on until all references are resolved. This is painful and I was
wondering if it there was a simple script (ANT or otherwise) that given
a particular java class, analyzes all the packages that are required to
compile it (recursively) successfully, jars them into a single file?

If you have the source code for the huge application, you
can let javac do the work. Just delete all the class files and
compile that one class you use.
 
M

Mike Schilling

Larry Barowski said:
If you have the source code for the huge application, you
can let javac do the work. Just delete all the class files and
compile that one class you use.

Unless any reflection is done; then all bets are off. This can be more
insidious than it might appear. If, for instance, the app contains an XML
parser found using JAXP's usual search algorithm (i.e. its class is named in
a resource file), that's reflection done inside Java's built-in classes, so
grepping the app for Class.forName won't find it.
 
R

Roedy Green

I am
basically using only one class in my simple application that belongs to
the huge app. Currently, I am having to manually import this class and
then import all its dependencies and check for their dependencies and
so on until all references are resolved.

see http://mindprod.com/jgloss/genjar.html

With Genjar/ANT, you have to manually add the classForName type
classes, and the getResource resources, but once you have that it will
find the rest of the dependencies. You can specify with flexible
wildcards that select files, directories or directory trees.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top