Copy the content of file into another file


(Firas Fafi) #1

Hello,

Can anyone please tell us how to copy the content of an file into another file. Actually I look to an equivalent to this ANT code:

<move file="${build.dir}/src/log4j.properties" tofile="${build.dir}/src/log4j.properties"/>

Thanks for your help!!!


(Firas Fafi) #2

Well I have found a solution using Ant call from Gradle:

ant.move(file:"${projectDir}/second.properties",tofile:"${projectDir}/first.properties")

But, I still looking for pure gradle code example. Thank you.


(Gary Hale) #3

http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.Copy.html and http://www.gradle.org/docs/current/dsl/org.gradle.api.Project.html#org.gradle.api.Project:copy(groovy.lang.Closure) will do a copy. There is no move task, but most things work better (i.e. incrementally) with copy and clean.