Mercurial > public > develkit
comparison init20.gradle @ 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 |
comparison
equal
deleted
inserted
replaced
184:acd8d3b58440 | 185:e1762e4ad070 |
---|---|
227 | 227 |
228 project.ext.previousBuildenv = project.file('build/buildenv.txt').exists() ? project.file('build/buildenv.txt').text : 'none' | 228 project.ext.previousBuildenv = project.file('build/buildenv.txt').exists() ? project.file('build/buildenv.txt').text : 'none' |
229 | 229 |
230 tasks.addRule("Pattern: <environment>As[Test]Properties: Generates <environment>.properties as resource or Test resource") { String taskName -> | 230 tasks.addRule("Pattern: <environment>As[Test]Properties: Generates <environment>.properties as resource or Test resource") { String taskName -> |
231 if ((taskName - 'Test').endsWith("AsProperties") && !taskName.startsWith('clean')) { | 231 if ((taskName - 'Test').endsWith("AsProperties") && !taskName.startsWith('clean')) { |
232 def t = taskName.contains('Test') ? processTestResources.destinationDir : processResources.destinationDir | 232 // def t = taskName.contains('Test') ? processTestResources.destinationDir : processResources.destinationDir |
233 def t = taskName.contains('Test') ? sourceSets.test.output.resourcesDir : sourceSets.main.output.resourcesDir | |
233 def e = (taskName - 'Test' - 'AsProperties').capitalize() | 234 def e = (taskName - 'Test' - 'AsProperties').capitalize() |
234 task(taskName) { | 235 task(taskName) { |
235 ext.propertyFile = new File(t, "${e.toLowerCase()}.properties") | 236 ext.outputDir = t |
237 ext.propertyFile = "${e.toLowerCase()}.properties" | |
236 ext.buildenv = project.file('build/buildenv.txt') | 238 ext.buildenv = project.file('build/buildenv.txt') |
237 inputs.files project.file("../environment${e}.groovy"), project.file("../private${e}.groovy"), project.file('../private.properties') | 239 inputs.files project.file("../environment${e}.groovy"), project.file("../private${e}.groovy"), project.file('../private.properties') |
238 outputs.files propertyFile, buildenv | 240 outputs.files new File(outputDir,propertyFile), buildenv |
239 outputs.upToDateWhen { | 241 outputs.upToDateWhen { |
240 gradle.env == project.previousBuildenv | 242 gradle.env == project.previousBuildenv |
241 } | 243 } |
242 doLast { | 244 doLast { |
243 t.mkdirs() | 245 t.mkdirs() |
244 buildenv.text = gradle.env | 246 buildenv.text = gradle.env |
245 def ps = gradle."environment${e}".toProperties() | 247 def ps = gradle."environment${e}".toProperties() |
246 ps['ssdt.project'] = project.name | 248 ps['ssdt.project'] = project.name |
247 ps.store(propertyFile.newOutputStream(), "by $taskName of $this") | 249 def pf = new File(outputDir,propertyFile) |
248 def l = propertyFile.readLines().sort() | 250 ps.store(pf.newOutputStream(), "by $taskName of $this") |
249 propertyFile.text = l.join('\n') | 251 def l = pf.readLines().sort() |
252 pf.text = l.join('\n') | |
250 } | 253 } |
251 } | 254 } |
252 } | 255 } |
253 } | 256 } |
254 | 257 |