aboutsummaryrefslogtreecommitdiff
path: root/stage2
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-03-05 06:30:03 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2017-03-05 06:30:03 -0500
commita0b8651fee9dca977c22a598d680746f1373e97c (patch)
treec9a405db81db4007150c75487e86e62e4d2e3898 /stage2
parent5cd8bc68728f6968310d3d1bbb382c14de53b601 (diff)
downloadcbt-a0b8651fee9dca977c22a598d680746f1373e97c.tar.gz
cbt-a0b8651fee9dca977c22a598d680746f1373e97c.tar.bz2
cbt-a0b8651fee9dca977c22a598d680746f1373e97c.zip
improve whitespace readability in proguard plugin
Diffstat (limited to 'stage2')
-rw-r--r--stage2/Lib.scala11
-rw-r--r--stage2/plugins/GeneratedSections.scala9
2 files changed, 12 insertions, 8 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala
index dbcd06f..50b7389 100644
--- a/stage2/Lib.scala
+++ b/stage2/Lib.scala
@@ -540,4 +540,15 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){
( directory.getParentFile ++ ("/" ++ lib.buildDirectoryName) ).exists
) findOuterMostModuleDirectory(directory.getParentFile) else directory
}
+
+ def transformFiles( files: Seq[File], transform: String => String ): Seq[File] = {
+ files.flatMap{ file =>
+ val string = file.readAsString
+ val replaced = transform( string )
+ if( string != replaced ) {
+ write( file, replaced )
+ Some(file)
+ } else None
+ }
+ }
}
diff --git a/stage2/plugins/GeneratedSections.scala b/stage2/plugins/GeneratedSections.scala
index 417278c..dc065cf 100644
--- a/stage2/plugins/GeneratedSections.scala
+++ b/stage2/plugins/GeneratedSections.scala
@@ -26,14 +26,7 @@ trait GeneratedSections extends BaseBuild{
}.getOrElse(subject)
}
- val updated = sourceFiles.flatMap{ file =>
- val template = file.readAsString
- val replaced = replaceSections( template, replacements )
- if( template != replaced ) {
- write( file.toPath, replaced.getBytes )
- Some(file)
- } else None
- }
+ val updated = lib.transformFiles( sourceFiles, replaceSections( _, replacements ) )
logger.log("generated-sections","Updated:" + updated.map(_ ++ "\n").mkString)
}