private void setupPackage(Package pkg, ExistPkgInfo info)
throws PackageException
{
// TODO: FIXME: Bad, BAD design! But will be resolved naturally by moving the
// install code within the storage class (because we are writing on disk)...
final FileSystemResolver res = (FileSystemResolver) pkg.getResolver();
final File classpath = res.resolveResourceAsFile(".exist/classpath.txt");
// create [pkg_dir]/.exist/classpath.txt if not already
final File exist = classpath.getParentFile();
if ( ! exist.exists() && ! exist.mkdir() ) {
throw new PackageException("Impossible to create directory: " + exist);
}
final Set<String> jars = info.getJars();
try {
final FileWriter out = new FileWriter(classpath);
for ( final String jar : jars ) {
StreamSource jar_src;
try {
jar_src = res.resolveComponent(jar);
}
catch ( final NotExistException ex ) {
final String msg = "Inconsistent package descriptor, the JAR file is not in the package: ";
throw new PackageException(msg + jar, ex);
}