# HG changeset patch # User Dave Smith # Date 1389325289 0 # Node ID 8dd6adab93880fa059295ccf9828f734d55436d6 # Parent 6af68acaf9b27e01885829b02335e42055d66202 add Rule for converting arbitrary environment's to property files diff -r 6af68acaf9b2 -r 8dd6adab9388 init.gradle --- 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: As[Test]Properties: Generates .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 } }