Last active
December 23, 2015 07:29
-
-
Save fancellu/6601111 to your computer and use it in GitHub Desktop.
Quick app to postprocess source files. Created because Scalaxb was converting '-' to u45 in class names.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.felstar.playpen.scalaxb | |
import java.io.File | |
object PostProcessScalaxb { | |
def allFiles(path:File):List[File]= { | |
val (dirs,files)=path.listFiles.toList.partition(_.isDirectory) | |
files ::: dirs.flatMap(allFiles) | |
} | |
def writeToFile(file: File, s: String) { | |
val pw = new java.io.PrintWriter(file) | |
try { | |
pw.write(s) | |
} finally { | |
pw.close() | |
} | |
} | |
def main(args: Array[String]): Unit = { | |
val src=new File(".","target/generated-sources") | |
val getChar="""u45(.)""".r | |
for (f<-allFiles(src).filter(_.getName().endsWith(".scala"))) { | |
println(f) | |
val fileLines = io.Source.fromFile(f).getLines.toList | |
.map(line=>getChar.replaceAllIn(line, _.group(1).toUpperCase)) | |
writeToFile(f,fileLines.mkString("\n")) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment