Raw
Example 1. Task list from the imported Ant project
$ gradle tasks :tasks dependencies - Displays the dependencies of root project 'ant-import-to-gradle'. help - Displays a help message projects - Displays the sub-projects of root project 'ant-import-to-gradle'. properties - Displays the properties of root project 'ant-import-to-gradle'. tasks - Displays the tasks in root project 'ant-import-to-gradle'.
---------------------------------------------------------------------
#
# Useful Ruby base class extensions.
#
class Array
# Execute a block passing it corresponding items in # +self+ and +other_array+. # If self has less items than other_array it is repeated.
def cycle(other_array) # :yields: item, other_item other_array.each_with_index do |item, index| yield(self[index % self.length], item) end end
end
if $0 == __FILE__ # (1) # Array#cycle test # true => 0 # false => 1 # true => 2 # false => 3 # true => 4 puts 'Array#cycle test' # (2) [true, false].cycle([0, 1, 2, 3, 4]) do |a, b| puts "#{a.inspect} => #{b.inspect}" end end ---------------------------------------------------------------------
<1> First callout. <2> Second callout.
Java Highlighted
Example 2. Gradle build script defining variables
def helloName = "Fird Birfle"
int personAge = 43
task hello << {
println "Hello ${helloName}. I believe you are ${personAge} years of age."
}
Java Raw
Example 3. Gradle build script defining variables
def helloName = "Fird Birfle"
int personAge = 43
task hello << {
println "Hello ${helloName}. I believe you are ${personAge} years of age."
}
XML Highlighted
Example 4. Ant build.xml zipping the source files.
source~~ example_code/ant-closuresforantbuilder/build.xml source~~