forked from loafle/openapi-generator-original
Merge pull request #867 from wing328/fix_jar_path
[Bug fix] Fix path inside JAR for non-template files
This commit is contained in:
commit
f66b5cf65b
@ -60,10 +60,10 @@ public abstract class AbstractGenerator {
|
|||||||
throw new RuntimeException("can't load template " + name);
|
throw new RuntimeException("can't load template " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCPResourcePath(String name) {
|
public String getCPResourcePath(String name) {
|
||||||
if (!"/".equals(File.separator)) {
|
if (!"/".equals(File.separator)) {
|
||||||
return name.replaceAll(Pattern.quote(File.separator), "/");
|
return name.replaceAll(Pattern.quote(File.separator), "/");
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,11 +268,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
// continue
|
// continue
|
||||||
}
|
}
|
||||||
if (in == null) {
|
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);
|
File outputFile = new File(outputFilename);
|
||||||
OutputStream out = new FileOutputStream(outputFile, false);
|
OutputStream out = new FileOutputStream(outputFile, false);
|
||||||
if (in != null && out != null) {
|
if (in != null && out != null) {
|
||||||
|
System.out.println("writing file " + outputFile);
|
||||||
IOUtils.copy(in, out);
|
IOUtils.copy(in, out);
|
||||||
} else {
|
} else {
|
||||||
if (in == null) {
|
if (in == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user