Thomas Kinnen wrote:
Hi everyone,
is there an easier way to copy files then using ant.copy or a Copy Task?
The copy task is very verbose for just copying one file to another
directory. If you want to rename it on the way it gets even more
complicated.
Something like project.copy(from, to) would be great. I know it exists
in the current build, but there you also have to specify a copySpec, so
it's not really less verbose. project.copy(from: filea, to: fileb) would
be great. Thereby renaming filea to fileb. Maybe an option would be to
make the copySpec check if the source is a file and if yes, also treat
the destination as file(if not yet created as directory). Thereby
allowing something like
task test(type: Copy) {
from: "dir/file1.txt"
into: "dir2/file2.txt"
}
If you aren't renaming it isn't that bad. You can currently use something
similar to what you suggested inside another task like:
task doStuff << {
// do some things
copy {
from 'dir1/file1.txt'
into 'dir2'
}
}
That seems fairly straightforward.
If you want to rename the file, however, it isn't as easy. The copySpec was
designed originally to handle groups of files and renaming was only done through
rules.
I don't really like overloading 'into' to mean either a directory or a file.
How about using 'to' instead of 'into' for single files. Like:
copy {
from 'dir/file1.txt'
to 'dir/file2.txt'
}
This would have to throw an exception if the source wasn't a single file or you
used one of the renaming specs. I think I could do this fairly easily.
When using an ant.copy(from, to) it seems that Gradle is eager
evaluating it. Therefor it will throw an error message if the file I
want to copy is not yet available. This seems to be a general problem
with ant tasks. If I want to copy something from or into the libsDir,
ant will complain that the directory is not available (which is true at
evaluation time). Therefor I would have to add an mkdir(dir: libsDir)
before each of these tasks(copy, jar, etc.). Maybe I am missing something?
Another problem i have encountered is Java Memory out of Heap Space when
running a compile over a lot of subprojects. I have added the following
clause to the subprojects closure on my main project:
compile.getOptions().forkOptions.memoryMaximumSize = "1024m"
compile.getOptions().fork = true
Still I get out of heap space errors, so something seems to be wrong.
What version are you working with? Trunk?
Other then that it has been a pleasure working with Gradle. Keep up the
great work.
Thomas
--
Steve Appling
Automated Logic Research Team
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email