Merge pull request #867 from wing328/fix_jar_path

[Bug fix] Fix path inside JAR for non-template files
This commit is contained in:
Tony Tam 2015-06-17 08:28:30 -07:00
commit f66b5cf65b
2 changed files with 4 additions and 3 deletions

View File

@ -60,7 +60,7 @@ public abstract class AbstractGenerator {
throw new RuntimeException("can't load template " + name);
}
private String getCPResourcePath(String name) {
public String getCPResourcePath(String name) {
if (!"/".equals(File.separator)) {
return name.replaceAll(Pattern.quote(File.separator), "/");
}

View File

@ -268,11 +268,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
// continue
}
if (in == null) {
in = this.getClass().getClassLoader().getResourceAsStream(config.templateDir() + File.separator + support.templateFile);
in = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(config.templateDir() + File.separator + support.templateFile));
}
File outputFile = new File(outputFilename);
OutputStream out = new FileOutputStream(outputFile, false);
if (in != null && out != null) {
System.out.println("writing file " + outputFile);
IOUtils.copy(in, out);
} else {
if (in == null) {