Managing Data Dependecies of Java Classes that Load Data from the Classpath at Runtime

Posted by Martin Potthast on Stack Overflow See other posts from Stack Overflow or by Martin Potthast
Published on 2010-05-19T14:38:44Z Indexed on 2010/05/19 14:40 UTC
Read the original article Hit count: 230

What is the simplest way to manage dependencies of Java classes to data files present in the classpath?

More specifically:
How should data dependencies be annotated? Perhaps using Java annotations (e.g., @Data)? Or rather some build entries in a build script or a properties file? Is there build tool that integrates and evaluates such information (Ant, Scons, ...)? Do you have examples?

Consider the following scenario:
A few lines of Ant create a Jar from my sources that includes everything found on the classpath. Then jarjar is used to remove all .class files that are not necessary to execute, say, class Foo. The problem is that all the data files that class Bar depends upon are still there in the Jar. The ideal deployment script, however, would recognize that the data files on which only class Bar depends can be removed while data files on which class Foo depends must be retained.

Any hints?

© Stack Overflow or respective owner

Related posts about java

Related posts about data