Hi,
I've created some tasks to clear out cached artifacts for work:
[code]
task("clearGradleCache", type: Delete, group: clearCachesGroup,
description: "Deletes the Gradle cache directory:
${userHome}/.gradle/cache") {
delete "${userHome}/.gradle/cache"
}
task("clearCompanyCache", type: Delete, group: clearCachesGroup,
description: "Deletes any cached artifacts with the domain of
com.example in the Gradle or Maven2 cache directories.") {
file("${userHome}/.gradle/cache").eachFile { cacheFile ->
if (cacheFile.name =~ /^com.example|^resolved-com.example/) delete
cacheFile.path
}
delete "${userHome}/.m2/repository/com/example"
}
[/code]
The odd thing is that the clearGradleCache task works as expected, but the
clearCompanyCache task seems to get executed whenever I run any task which
is not desired.
If I change the clearCompanyCache to use the '<<' notation:
[code]
task("clearCompanyCache", type: Delete, group: clearCachesGroup,
description: "Deletes any cached artifacts with the domain of
com.example in the Gradle or Maven2 cache directories.") << {
....
}
[/code]
It works fine.
It seems to me that the only difference between the two is the eachFile
loop, and I'd like to know why that is. Is the '<<' the correct way to do
this, so I should change all the Delete tasks over to use it? or is this
unexpected behavior?
I'm using milestone3.
Thanks,
Eric
--
Learn from the past. Live in the present. Plan for the future.
Blog: http://eric-berry.blogspot.com
jEdit <http://www.jedit.org> - Programmer's Text Editor
Bazaar <http://bazaar.canonical.com> - Version Control for Humans