changeset 180:1bdb6e1f2fdb

handle outputs update handling including env changes
author smith@nwoca.org
date Fri, 19 Dec 2014 04:27:16 +0000
parents f9087f939b0a
children d90208c97ec5
files init20.gradle
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/init20.gradle	Sat Dec 13 22:44:49 2014 +0000
+++ b/init20.gradle	Fri Dec 19 04:27:16 2014 +0000
@@ -116,8 +116,6 @@
 
 apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle"
 
-task wrapper(type: Wrapper) {}
-
 rootProject.afterEvaluate { r ->
 
     if (r.plugins.hasPlugin(org.gradle.plugins.ide.idea.IdeaPlugin)) {
@@ -227,15 +225,23 @@
         project.repositories.any { it.name == 'local' }
     }
 
+    project.ext.previousBuildenv = project.file('build/buildenv.txt').exists() ? project.file('build/buildenv.txt').text : 'none'
+
     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 e = (taskName - 'Test' - 'AsProperties').capitalize()
             task(taskName) {
                 ext.propertyFile = new File(t, "${e.toLowerCase()}.properties")
+                ext.buildenv = project.file('build/buildenv.txt')
                 inputs.files "../environment${e}.groovy", "../private${e}.groovy", '../private.properties'
+                outputs.files propertyFile, buildenv
+                outputs.upToDateWhen {
+                    gradle.env == project.previousBuildenv
+                }
                 doLast {
                     t.mkdirs()
+                    buildenv.text = gradle.env
                     def ps = gradle."environment${e}".toProperties()
                     ps['ssdt.project'] = project.name
                     ps.store(propertyFile.newOutputStream(), "by $taskName of $this")