changeset 185:e1762e4ad070

write properties to correct sourceset output. allow property filename to overridden more easily
author smith@nwoca.org
date Sun, 01 Mar 2015 21:17:19 +0000
parents acd8d3b58440
children 21b4b58e3cd8
files init20.gradle
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/init20.gradle	Mon Dec 22 20:56:20 2014 +0000
+++ b/init20.gradle	Sun Mar 01 21:17:19 2015 +0000
@@ -229,13 +229,15 @@
 
     tasks.addRule("Pattern: <environment>As[Test]Properties: Generates <environment>.properties as resource or Test resource") { String taskName ->
         if ((taskName - 'Test').endsWith("AsProperties") && !taskName.startsWith('clean')) {
-            def t = taskName.contains('Test') ? processTestResources.destinationDir : processResources.destinationDir
+     //       def t = taskName.contains('Test') ? processTestResources.destinationDir : processResources.destinationDir
+            def t = taskName.contains('Test') ? sourceSets.test.output.resourcesDir : sourceSets.main.output.resourcesDir
             def e = (taskName - 'Test' - 'AsProperties').capitalize()
             task(taskName) {
-                ext.propertyFile = new File(t, "${e.toLowerCase()}.properties")
+				ext.outputDir = t
+                ext.propertyFile = "${e.toLowerCase()}.properties"
                 ext.buildenv = project.file('build/buildenv.txt')
                 inputs.files project.file("../environment${e}.groovy"), project.file("../private${e}.groovy"), project.file('../private.properties')
-                outputs.files propertyFile, buildenv
+                outputs.files new File(outputDir,propertyFile), buildenv
                 outputs.upToDateWhen {
                     gradle.env == project.previousBuildenv
                 }
@@ -244,9 +246,10 @@
                     buildenv.text = gradle.env
                     def ps = gradle."environment${e}".toProperties()
                     ps['ssdt.project'] = project.name
-                    ps.store(propertyFile.newOutputStream(), "by $taskName of $this")
-                    def l = propertyFile.readLines().sort()
-                    propertyFile.text = l.join('\n')
+					def pf = new File(outputDir,propertyFile)
+                    ps.store(pf.newOutputStream(), "by $taskName of $this")
+                    def l = pf.readLines().sort()
+                    pf.text = l.join('\n')
                 }
             }
         }