forked from loafle/openapi-generator-original
added support for copying directories
This commit is contained in:
parent
51437245e4
commit
aef4190624
@ -491,7 +491,7 @@ class Codegen(config: CodegenConfig) {
|
|||||||
"models" -> modelList)
|
"models" -> modelList)
|
||||||
|
|
||||||
config.supportingFiles.map(file => {
|
config.supportingFiles.map(file => {
|
||||||
val srcTemplate = file._1
|
val supportingFile = file._1
|
||||||
val outputDir = file._2
|
val outputDir = file._2
|
||||||
val destFile = file._3
|
val destFile = file._3
|
||||||
|
|
||||||
@ -499,9 +499,9 @@ class Codegen(config: CodegenConfig) {
|
|||||||
val outputFolder = new File(outputFilename).getParent
|
val outputFolder = new File(outputFilename).getParent
|
||||||
new File(outputFolder).mkdirs
|
new File(outputFolder).mkdirs
|
||||||
|
|
||||||
if (srcTemplate.endsWith(".mustache")) {
|
if (supportingFile.endsWith(".mustache")) {
|
||||||
val output = {
|
val output = {
|
||||||
val resourceName = config.templateDir + File.separator + srcTemplate
|
val resourceName = config.templateDir + File.separator + supportingFile
|
||||||
val is = getInputStream(resourceName)
|
val is = getInputStream(resourceName)
|
||||||
if (is == null)
|
if (is == null)
|
||||||
throw new Exception("Resource not found: " + resourceName)
|
throw new Exception("Resource not found: " + resourceName)
|
||||||
@ -515,15 +515,22 @@ class Codegen(config: CodegenConfig) {
|
|||||||
fw.close()
|
fw.close()
|
||||||
println("wrote " + outputFilename)
|
println("wrote " + outputFilename)
|
||||||
} else {
|
} else {
|
||||||
val is = getInputStream(config.templateDir + File.separator + srcTemplate)
|
val file = new File(config.templateDir + File.separator + supportingFile)
|
||||||
val outputFile = new File(outputFilename)
|
if(file.isDirectory()) {
|
||||||
val parentDir = new File(outputFile.getParent)
|
// copy the whole directory
|
||||||
if (parentDir != null && !parentDir.exists) {
|
FileUtils.copyDirectory(file, new File(outputDir))
|
||||||
println("making directory: " + parentDir.toString + ": " + parentDir.mkdirs)
|
println("copied directory " + supportingFile)
|
||||||
|
} else {
|
||||||
|
val is = getInputStream(config.templateDir + File.separator + supportingFile)
|
||||||
|
val outputFile = new File(outputFilename)
|
||||||
|
val parentDir = new File(outputFile.getParent)
|
||||||
|
if (parentDir != null && !parentDir.exists) {
|
||||||
|
println("making directory: " + parentDir.toString + ": " + parentDir.mkdirs)
|
||||||
|
}
|
||||||
|
FileUtils.copyInputStreamToFile(is, new File(outputFilename))
|
||||||
|
println("copied " + outputFilename)
|
||||||
|
is.close
|
||||||
}
|
}
|
||||||
FileUtils.copyInputStreamToFile(is, new File(outputFilename))
|
|
||||||
println("copied " + outputFilename)
|
|
||||||
is.close
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
//a shutdown method will be added to scalate in an upcoming release
|
//a shutdown method will be added to scalate in an upcoming release
|
||||||
|
Loading…
x
Reference in New Issue
Block a user