OK, I tried to do as you suggested. I'm customizing com.izforge.izpack.installer.ScriptParser. The only thing I had to modify is the parseFiles method:
public void parseFiles() throws Exception {
// Parses the files
Iterator<ParsableFile> iter = files.iterator();
while (iter.hasNext()) {
// If interrupt is desired, return immediately.
if (Unpacker.isInterruptDesired()) {
return;
}
// Create a temporary file for the parsed data
// (Use the same directory so that renaming works later)
ParsableFile pfile = iter.next();
// check whether the OS matches
if (!OsConstraint.oneMatchesCurrentSystem(pfile.osConstraints)) {
continue;
}
de.schlichtherle.io.File file = new de.schlichtherle.io.File(pfile.path);
System.out.println("source file: " + file.getAbsolutePath() + "(" + file.exists() + ")");
java.io.File tempFile = java.io.File.createTempFile("izpp", null, null);
de.schlichtherle.io.File parsedFile = new de.schlichtherle.io.File(tempFile);
BufferedInputStream in;
BufferedOutputStream out;
de.schlichtherle.io.FileInputStream inFile = new de.schlichtherle.io.FileInputStream(file); //FileNotFoundException thrown here
in = new BufferedInputStream(inFile, 5120);
FileOutputStream outFile = new FileOutputStream(parsedFile);
out = new BufferedOutputStream(outFile, 5120);
vs.substitute(in, out, pfile.type, pfile.encoding);
in.close();
out.close();
file.delete();
if (!parsedFile.renameTo(file)) {
throw new IOException("Could not rename file " + parsedFile + " to " + file);
}
}
}
Here is my parsable in my installer descriptor:
<parsable targetfile="$INSTALL_PATH/plugins/com.mycompany.myapp_1.0.0.jar/myapp.properties"
type="javaprop"/>
But when I run the installer I get the following exception:
java.io.FileNotFoundException: C:\Program Files\KMC Client\plugins\com.mycompany.myapp_1.0.0.jar\myapp.properties (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at de.schlichtherle.io.FileInputStream.createInputStream(FileInputStream.java:138)
at de.schlichtherle.io.FileInputStream.<init>(FileInputStream.java:108)
at com.izforge.izpack.installer.ScriptParser.parseFiles(ScriptParser.java:159)
at com.izforge.izpack.installer.Unpacker.run(Unpacker.java:444)
at java.lang.Thread.run(Thread.java:619)
And I've double checked: the JAR exists and the properties file is well inside.
Any idea of what is going on?