Hi Glen,
On Thu, Sep 2, 2010 at 1:29 AM, Glen Stampoultzis <[email protected]> wrote:
> Considering gradle isn't even version 1.0 I think the documentation is
> outstanding. However have trouble understanding certain things. For
> example I came across the following code for creating a "fat" jar.
>
> jar {
> from configurations.compile.collect { it.isDirectory() ? it :
> zipTree(it) }
> }
>
> It's a very concise piece of code considering how much it does but
> there are things I'm struggling to understand about how it works. My
> first question is regarding the jar function. I'm assuming this is a
> reference to the jar task, but I'm not sure, maybe it's a reference to
> a datastructure. I can see several references to this element in the
> documentation but they don't seem to clearly explain this.
>
jar returns an instance of the Jar class, which is a task (i.e. implements
the Task interface). This instance is added and preconfigured by the Java
plugin.
> The other is the from function(?). I wasn't able to find a reference
> to this in the documentation. Is it a built in groovy thing or is it
> part of gradle? What does it do and how does it work?
>
The from method is part of what we call a copy spec. Copy specs are used by
the copy and the archive tasks (jar, zip, tar) to specify the content to be
added/copied when the jar task is executed.
Have a look here to learn more about this:
http://gradle.org/0.9-rc-1/docs/userguide/working_with_files.html#sec:copying_files
On our way to 1.0 is a DSL documentation for each task (Right now you would
need to go to the javadoc/groovydoc for that).
- Hans
--
Hans Dockter
Founder, Gradle
http://www.gradle.org, http://twitter.com/gradleorg
CEO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz