diff init.gradle @ 161:8dd6adab9388

add Rule for converting arbitrary environment's to property files
author Dave Smith <smith@nwoca.org>
date Fri, 10 Jan 2014 03:41:29 +0000
parents 6af68acaf9b2
children 29c3af8dc031
line wrap: on
line diff
--- a/init.gradle	Wed Nov 06 16:36:31 2013 +0000
+++ b/init.gradle	Fri Jan 10 03:41:29 2014 +0000
@@ -202,6 +202,23 @@
     cleanLocal.onlyIf { 
         project.repositories.any { it.name == 'local' }
     }    
+	
+	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")
+                inputs.files "../environment${e}.groovy", "../private${e}.groovy", '../private.properties'
+                outputs.file propertyFile
+                doLast {
+                    t.mkdirs()
+                    gradle."environment${e}".toProperties().store(propertyFile.newOutputStream(), "by $taskName of $this")
+                }
+            }
+        }
+    }
+
     
 }
 
@@ -242,11 +259,11 @@
                     add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
                         name = 'local'
                         addIvyPattern gradle.ivyUserDir + "/local/[module]-ivy-[revision].xml"
-                        addArtifactPattern gradle.ivyUserDir + '/local/[module]-[artifact]-[revision](-[classifier]).[ext]'
+                        addArtifactPattern gradle.ivyUserDir + '/local/[artifact]-[revision](-[classifier]).[ext]'
                         descriptor = 'optional'
                         checkmodified = true
                         changingMatcher = 'regexp'
-                        changingPattern = '.*SNAPSHOT'   
+                        changingPattern = '.*SNAPSHOT'
                         force = true
                     }                       
                 }