CopyTask doesn't work

I have build.properties: build

= build src.dir

= src

This task doesn’t work:

ant.property(file:‘build.properties’)

task copyTask(type: Copy) {

from ant.properties[‘src.dir’]

into ant.properties[‘build’]

include ‘com/**/*.xml’

include ‘com/**/*.xml’

}

This one works:

ant.property(file:‘build.properties’)

task copyTask(type: Copy) {

copy {

from ant.properties[‘src.dir’]

into ant.properties[‘build’]

include ‘com/**/*.xml’

include ‘com/**/*.xml’

} }

What is wrong?

gradle --version

------------------------------------------------------------ Gradle 1.0-rc-3 ------------------------------------------------------------

Gradle build time: Sunday, April 29, 2012 11:51:52 PM UTC Groovy: 1.8.6 Ant: Apache Ant™ version 1.8.2 compiled on December 20 2010 Ivy: 2.2.0 JVM: 1.6.0_17 (Sun Microsystems Inc. 14.3-b01) OS: Linux 2.6.9-67.ELsmp amd64

Are you sure that the task gets executed? The second snippet will always do the copy, no matter which tasks get executed. (Obviously, that’s not what you want.)

Another try is to move ‘ant.property(file:‘build.properties’)’ inside the task’s configuration block. That said, Gradle’s Ant integration isn’t really meant to be used in this way, so you are probably better off accessing the properties file directly. Something like:

def buildProperties = file('build.properties').withReader { new Properties().load(it) }

Yes. You were right – it seems the task was not executed .