SlideShare uma empresa Scribd logo
1 de 25
Gant – the lightweight and Groovy
                   scripting framework


                                 Dr Russel Winder


                                       Partner, Concertant LLP
                                       russel.winder@concertant.com



Copyright © 2009 Russel Winder                                        1
Aims and Objectives of the Session

                       ●    Look at Gant as a way of:
                                 –   Defining a set of targets.
                                 –   Scripting Ant tasks.
                                 –   Using AntBuilder.
                                 –   Using the Groovy meta-object protocol.




                                                            Have a structured “chin wag”
                                                            that is (hopefully) both
                                                            illuminating and enlightening.
Copyright © 2009 Russel Winder                                                               2
Structure of the Session

                       ●    Do stuff.
                       ●    Exit stage (left|right).




                                                       There is significant dynamic binding
                                                       to the session so the above is just a
                                                       set of place holders.

Copyright © 2009 Russel Winder                                                                 3
Protocol for the Session

                       ●    A sequence of slides, interrupted by various bits of
                            code.
                       ●    Example executions of code – with the illuminating
                            presence of a system monitor.
                       ●    Questions (and, indeed, answers) from the audience
                            as and when they crop up.


                                                  If an interaction looks like it is
                                                  getting too involved, we reserve
                                                  the right to stack it for handling
                                                  after the session.
Copyright © 2009 Russel Winder                                                         4
Blatant Advertising

                       Python for Rookies
                       Sarah Mount, James Shuttleworth and
                       Russel Winder
                       Thomson Learning Now called Cengage Learning.


                                          Developing Java Software Third Edition
                                          Russel Winder and Graham Roberts
                                          Wiley




                                                          Buy these books!
Copyright © 2009 Russel Winder                                                     5
XML

                       ●    Does anyone like programming using XML?
                                 –   Ant has always claimed Ant scripts are declarative
                                     programs – at least that is better than trying to write
                                     imperative programs using XML.
                                 –   Most Ant scripts exhibit significant control flow
                                     tendencies.




Copyright © 2009 Russel Winder                                                                 6
gs/XML/Groovy/g

                       ●    Gant started as an Ant-   ●   Gradle (and SCons)
                            style build tool using        shows that build is
                            Groovy instead of XML         better handled using a
                            to specify the build.         system that works using
                                                          a directed acyclic graph
                       ●    Ant <-> Maven warfare,
                                                          of all dependencies.
                            configuration vs.
                            convention.



                 Real Programmers use ed.


Copyright © 2009 Russel Winder                                                       7
If Gradle, why Gant?

                       ●    Gant is a lightweight target-oriented scripting system
                            built on Groovy and its AntBuilder.
                       ●    Gradle is a build framework.


                                      Gant is lightweight, Gradle
                                      is a little more serious.


                                                Lightweight means embeddable,
                                                hence it being used in Grails.


Copyright © 2009 Russel Winder                                                       8
Gant Scripts . . .

                       ●    Are Groovy scripts.
                       ●    Have targets as well as other code.
                       ●    Are executed directly – no data structure building
                            phase as with Gradle and SCons.




                                           Use functions, closures, etc. to structure
                                           the code and make the targets the
                                           multiple entries into the codebase.

Copyright © 2009 Russel Winder                                                          9
Targets are . . .
                                                        Think Fortran entry statement
                       ●    The entry points.
                       ●    Callable -- targets are closures and hence callable
                            from other targets and indeed any other code, but
                            this is a bad coding strategy.
                       ●    Independent – there is no way of specifying
                            dependencies of one target on another except by
                            executing code. Cf. depends function.

                                            Although targets become closures, treat
                                            them as entry points, not callables.


Copyright © 2009 Russel Winder                                                          10
Hello World

                     def helloWorld ( ) {
                       println ( 'Hello World.' )                     Parameter is a Map
                     }
                     target ( 'default' : 'The default target.' ) {
                       helloWorld ( )
                     }



                                                           |> gant -p -f helloWorld.gant

                                                           default The default target.

                                                           Default target is default.

                                                           |>
Copyright © 2009 Russel Winder                                                             11
Hello World – 2

                def helloWorld ( ) {
                  println ( 'Hello World.' )
                }
                target ( printHelloWorld : 'Print Hello World.' ) {
                  helloWorld ( )
                }
                setDefaultTarget ( printHelloWorld )


                                                 |> gant -p -f helloWorld_2.gant

                                                  printHelloWorld Print Hello World.

                                                 Default target is printHelloWorld.

                                                 |>
Copyright © 2009 Russel Winder                                                         12
HelloWorld – 3


         def helloWorld ( ) {
           println ( 'Hello World.' )
         }
         target ( doHelloWorldPrint : 'Print Hello World.' ) {
           helloWorld ( )
         }
         target ( printHelloWorld : 'Force doHelloWorldPrint to be achieved.' ) {
           depends ( doHelloWorldPrint )
         }
         setDefaultTarget ( printHelloWorld )




Copyright © 2009 Russel Winder                                                      13
Hello World – 4


           def helloWorld ( ) {
             println ( 'Hello World.' )
           }
           target ( printHelloWorld : 'Force doHelloWorldPrint to be achieved.' ) {
             depends ( helloWorld )
           }
           setDefaultTarget ( printHelloWorld )




                                                        This does not work :-(

Copyright © 2009 Russel Winder                                                        14
Hello World – 5 & 6
    def helloWorld = {
      println ( 'Hello World.' )                             These work, but is it
    }                                                        better to make the
    target ( printHelloWorld : 'Print Hell World.' ) {       variable local or use
      depends ( helloWorld )                                 the global binding?
    }
    setDefaultTarget ( printHelloWorld )


                                 helloWorld = {
                                   println ( 'Hello World.' )
                                 }
                                 target ( printHelloWorld : 'Print Hell World.' ) {
                                   depends ( helloWorld )
                                 }
                                 setDefaultTarget ( printHelloWorld )
Copyright © 2009 Russel Winder                                                        15
Hello World – 7 & 8

  def helloWorld = {                                           The global hooks are
    println ( 'Hello World.' )                                 just variables in the
  }                                                            binding – callable or
  globalPreHook = helloWorld                                   list of callables
  target ( printHelloWorld : 'Print Hello World.' ) { }        assumed.
  setDefaultTarget ( printHelloWorld )



                                 def helloWorld = {
                                   println ( 'Hello World.' )
                                 }
                                 globalPostHook = [ helloWorld ]
                                 target ( printHelloWorld : 'Print Hello World.' ) { }
                                 setDefaultTarget ( printHelloWorld )

Copyright © 2009 Russel Winder                                                           16
Hello World – 9 & 10

    def helloWorld = {
      println ( 'Hello World.' )
    }
    target ( name : 'printHelloWorld' , description : 'Print Hello World.' ,
    addprehook : helloWorld ) { }
    setDefaultTarget ( printHelloWorld )



                  def helloWorld = {
                    println ( 'Hello World.' )
                  }
                  target ( name : 'printHelloWorld' , description : 'Print Hello World.' ,
                  addposthook : helloWorld ) { }
                  setDefaultTarget ( printHelloWorld )
Copyright © 2009 Russel Winder                                                               17
Hello World – 11 & 12

        def helloWorld = {
          println ( 'Hello World.' )
        }
        target ( name : 'printHelloWorld' , description : 'Print Hello World.' ,
        prehook : helloWorld ) { }
        setDefaultTarget ( printHelloWorld )



               def helloWorld = {
                 println ( 'Hello World.' )
               }
               target ( name : 'printHelloWorld' , description : 'Print Hello World.' ,
               posthook : helloWorld ) { }
               setDefaultTarget ( printHelloWorld )

Copyright © 2009 Russel Winder                                                            18
Hello World – 13 & 14



         target ( 'Hello World.' : 'Print Hello World.' ) { println ( it.name ) }
         setDefaultTarget ( 'Hello World.' )




        target ( printHelloWorld : 'Hello World.' ) { println ( it.description ) }
        setDefaultTarget ( printHelloWorld )



Copyright © 2009 Russel Winder                                                       19
Doing More Than One Thing At Once

                       ●    The world is a parallel place – multicore is now the
                            norm.
                       ●    Workstations have 2, 3, 4, 6, 8, . . . cores.
                       ●    Sequential, uniprocessor thinking is now archaic.




Copyright © 2009 Russel Winder                                                     20
GPars is Groovy Parallelism

                       ●    Was GParallelizer is now GPars.
                       ●    http://gpars.codehaus.org
                       ●    Will have a selection of tools:
                                 –   Actors
                                 –   Active objects
                                 –   Dataflow
                                 –   CSP



                                                CSP – Communicating Sequential Processes
Copyright © 2009 Russel Winder                                                             21
Actors and Data Parallelism

                       ●    Some examples of using GPars in Groovy.
                       ●    Some examples of using GPars in Gant.




Copyright © 2009 Russel Winder                                        22
Summary

                       ●    Interesting things were said.
                       ●    People enjoyed the session.




Copyright © 2009 Russel Winder                              23
Unabashed Advertising




                                 You know you want to buy them!
Copyright © 2008 Russel Winder                                    24
GPars Logo Contest

                       ●    GPars project is having a logo contest: See
                            http://docs.codehaus.org/display/GPARS/Logo+Contest
                       ●    Closing date for entries was 2009-11-30.
                       ●    Voting is now happening.




                                               Late entries are not
                                               accepted, though if
                                               significant bribes to the
                                               organizer are involved . . .
Copyright © 2008 Russel Winder                                                    25

Mais conteúdo relacionado

Semelhante a Gant, the lightweight and Groovy targeted scripting framework

Just Keep Sending The Messages
Just Keep Sending The MessagesJust Keep Sending The Messages
Just Keep Sending The Messages
Russel Winder
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovy
deimos
 

Semelhante a Gant, the lightweight and Groovy targeted scripting framework (20)

Just Keep Sending The Messages
Just Keep Sending The MessagesJust Keep Sending The Messages
Just Keep Sending The Messages
 
GPars Workshop
GPars WorkshopGPars Workshop
GPars Workshop
 
Node.js Test
Node.js TestNode.js Test
Node.js Test
 
Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.
 
Java is Dead, Long Live Ceylon, Kotlin, etc
Java is Dead,  Long Live Ceylon, Kotlin, etcJava is Dead,  Long Live Ceylon, Kotlin, etc
Java is Dead, Long Live Ceylon, Kotlin, etc
 
Vagrant & CFEngine - LOPSA East 2013
Vagrant & CFEngine - LOPSA East 2013Vagrant & CFEngine - LOPSA East 2013
Vagrant & CFEngine - LOPSA East 2013
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovy
 
Gradle: Harder, Stronger, Better, Faster
Gradle: Harder, Stronger, Better, FasterGradle: Harder, Stronger, Better, Faster
Gradle: Harder, Stronger, Better, Faster
 
TechEvent Graal(VM) Performance Interoperability
TechEvent Graal(VM) Performance InteroperabilityTechEvent Graal(VM) Performance Interoperability
TechEvent Graal(VM) Performance Interoperability
 
Android Development Tutorial V3
Android Development Tutorial   V3Android Development Tutorial   V3
Android Development Tutorial V3
 
Agile Project Management - coClarity
Agile Project Management - coClarityAgile Project Management - coClarity
Agile Project Management - coClarity
 
Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.
 
Improving Engineering Processes using Hudson - Spark IT 2010
Improving Engineering Processes using Hudson - Spark IT 2010Improving Engineering Processes using Hudson - Spark IT 2010
Improving Engineering Processes using Hudson - Spark IT 2010
 
M6d cassandra summit
M6d cassandra summitM6d cassandra summit
M6d cassandra summit
 
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...“Startup - it’s not just an IT project” - a random sampling of problems we’ve...
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...
 
Tungsten University: Geographically Distributed Multi-Master MySQL Clusters
Tungsten University: Geographically Distributed Multi-Master MySQL ClustersTungsten University: Geographically Distributed Multi-Master MySQL Clusters
Tungsten University: Geographically Distributed Multi-Master MySQL Clusters
 
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
Java Tech & Tools | Just Keep Passing the Message | Russel WinderJava Tech & Tools | Just Keep Passing the Message | Russel Winder
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
 
Just Keep Passing The Messages
Just Keep Passing The MessagesJust Keep Passing The Messages
Just Keep Passing The Messages
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecture
 
Apache Drill (ver. 0.1, check ver. 0.2)
Apache Drill (ver. 0.1, check ver. 0.2)Apache Drill (ver. 0.1, check ver. 0.2)
Apache Drill (ver. 0.1, check ver. 0.2)
 

Mais de Skills Matter

Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
Skills Matter
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
Skills Matter
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
Skills Matter
 

Mais de Skills Matter (20)

5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberl
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.js
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source world
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testing
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
 
Serendipity-neo4j
Serendipity-neo4jSerendipity-neo4j
Serendipity-neo4j
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Plug 20110217
Plug   20110217Plug   20110217
Plug 20110217
 
Lug presentation
Lug presentationLug presentation
Lug presentation
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
 
Plug saiku
Plug   saikuPlug   saiku
Plug saiku
 

Último

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Gant, the lightweight and Groovy targeted scripting framework

  • 1. Gant – the lightweight and Groovy scripting framework Dr Russel Winder Partner, Concertant LLP russel.winder@concertant.com Copyright © 2009 Russel Winder 1
  • 2. Aims and Objectives of the Session ● Look at Gant as a way of: – Defining a set of targets. – Scripting Ant tasks. – Using AntBuilder. – Using the Groovy meta-object protocol. Have a structured “chin wag” that is (hopefully) both illuminating and enlightening. Copyright © 2009 Russel Winder 2
  • 3. Structure of the Session ● Do stuff. ● Exit stage (left|right). There is significant dynamic binding to the session so the above is just a set of place holders. Copyright © 2009 Russel Winder 3
  • 4. Protocol for the Session ● A sequence of slides, interrupted by various bits of code. ● Example executions of code – with the illuminating presence of a system monitor. ● Questions (and, indeed, answers) from the audience as and when they crop up. If an interaction looks like it is getting too involved, we reserve the right to stack it for handling after the session. Copyright © 2009 Russel Winder 4
  • 5. Blatant Advertising Python for Rookies Sarah Mount, James Shuttleworth and Russel Winder Thomson Learning Now called Cengage Learning. Developing Java Software Third Edition Russel Winder and Graham Roberts Wiley Buy these books! Copyright © 2009 Russel Winder 5
  • 6. XML ● Does anyone like programming using XML? – Ant has always claimed Ant scripts are declarative programs – at least that is better than trying to write imperative programs using XML. – Most Ant scripts exhibit significant control flow tendencies. Copyright © 2009 Russel Winder 6
  • 7. gs/XML/Groovy/g ● Gant started as an Ant- ● Gradle (and SCons) style build tool using shows that build is Groovy instead of XML better handled using a to specify the build. system that works using a directed acyclic graph ● Ant <-> Maven warfare, of all dependencies. configuration vs. convention. Real Programmers use ed. Copyright © 2009 Russel Winder 7
  • 8. If Gradle, why Gant? ● Gant is a lightweight target-oriented scripting system built on Groovy and its AntBuilder. ● Gradle is a build framework. Gant is lightweight, Gradle is a little more serious. Lightweight means embeddable, hence it being used in Grails. Copyright © 2009 Russel Winder 8
  • 9. Gant Scripts . . . ● Are Groovy scripts. ● Have targets as well as other code. ● Are executed directly – no data structure building phase as with Gradle and SCons. Use functions, closures, etc. to structure the code and make the targets the multiple entries into the codebase. Copyright © 2009 Russel Winder 9
  • 10. Targets are . . . Think Fortran entry statement ● The entry points. ● Callable -- targets are closures and hence callable from other targets and indeed any other code, but this is a bad coding strategy. ● Independent – there is no way of specifying dependencies of one target on another except by executing code. Cf. depends function. Although targets become closures, treat them as entry points, not callables. Copyright © 2009 Russel Winder 10
  • 11. Hello World def helloWorld ( ) { println ( 'Hello World.' ) Parameter is a Map } target ( 'default' : 'The default target.' ) { helloWorld ( ) } |> gant -p -f helloWorld.gant default The default target. Default target is default. |> Copyright © 2009 Russel Winder 11
  • 12. Hello World – 2 def helloWorld ( ) { println ( 'Hello World.' ) } target ( printHelloWorld : 'Print Hello World.' ) { helloWorld ( ) } setDefaultTarget ( printHelloWorld ) |> gant -p -f helloWorld_2.gant printHelloWorld Print Hello World. Default target is printHelloWorld. |> Copyright © 2009 Russel Winder 12
  • 13. HelloWorld – 3 def helloWorld ( ) { println ( 'Hello World.' ) } target ( doHelloWorldPrint : 'Print Hello World.' ) { helloWorld ( ) } target ( printHelloWorld : 'Force doHelloWorldPrint to be achieved.' ) { depends ( doHelloWorldPrint ) } setDefaultTarget ( printHelloWorld ) Copyright © 2009 Russel Winder 13
  • 14. Hello World – 4 def helloWorld ( ) { println ( 'Hello World.' ) } target ( printHelloWorld : 'Force doHelloWorldPrint to be achieved.' ) { depends ( helloWorld ) } setDefaultTarget ( printHelloWorld ) This does not work :-( Copyright © 2009 Russel Winder 14
  • 15. Hello World – 5 & 6 def helloWorld = { println ( 'Hello World.' ) These work, but is it } better to make the target ( printHelloWorld : 'Print Hell World.' ) { variable local or use depends ( helloWorld ) the global binding? } setDefaultTarget ( printHelloWorld ) helloWorld = { println ( 'Hello World.' ) } target ( printHelloWorld : 'Print Hell World.' ) { depends ( helloWorld ) } setDefaultTarget ( printHelloWorld ) Copyright © 2009 Russel Winder 15
  • 16. Hello World – 7 & 8 def helloWorld = { The global hooks are println ( 'Hello World.' ) just variables in the } binding – callable or globalPreHook = helloWorld list of callables target ( printHelloWorld : 'Print Hello World.' ) { } assumed. setDefaultTarget ( printHelloWorld ) def helloWorld = { println ( 'Hello World.' ) } globalPostHook = [ helloWorld ] target ( printHelloWorld : 'Print Hello World.' ) { } setDefaultTarget ( printHelloWorld ) Copyright © 2009 Russel Winder 16
  • 17. Hello World – 9 & 10 def helloWorld = { println ( 'Hello World.' ) } target ( name : 'printHelloWorld' , description : 'Print Hello World.' , addprehook : helloWorld ) { } setDefaultTarget ( printHelloWorld ) def helloWorld = { println ( 'Hello World.' ) } target ( name : 'printHelloWorld' , description : 'Print Hello World.' , addposthook : helloWorld ) { } setDefaultTarget ( printHelloWorld ) Copyright © 2009 Russel Winder 17
  • 18. Hello World – 11 & 12 def helloWorld = { println ( 'Hello World.' ) } target ( name : 'printHelloWorld' , description : 'Print Hello World.' , prehook : helloWorld ) { } setDefaultTarget ( printHelloWorld ) def helloWorld = { println ( 'Hello World.' ) } target ( name : 'printHelloWorld' , description : 'Print Hello World.' , posthook : helloWorld ) { } setDefaultTarget ( printHelloWorld ) Copyright © 2009 Russel Winder 18
  • 19. Hello World – 13 & 14 target ( 'Hello World.' : 'Print Hello World.' ) { println ( it.name ) } setDefaultTarget ( 'Hello World.' ) target ( printHelloWorld : 'Hello World.' ) { println ( it.description ) } setDefaultTarget ( printHelloWorld ) Copyright © 2009 Russel Winder 19
  • 20. Doing More Than One Thing At Once ● The world is a parallel place – multicore is now the norm. ● Workstations have 2, 3, 4, 6, 8, . . . cores. ● Sequential, uniprocessor thinking is now archaic. Copyright © 2009 Russel Winder 20
  • 21. GPars is Groovy Parallelism ● Was GParallelizer is now GPars. ● http://gpars.codehaus.org ● Will have a selection of tools: – Actors – Active objects – Dataflow – CSP CSP – Communicating Sequential Processes Copyright © 2009 Russel Winder 21
  • 22. Actors and Data Parallelism ● Some examples of using GPars in Groovy. ● Some examples of using GPars in Gant. Copyright © 2009 Russel Winder 22
  • 23. Summary ● Interesting things were said. ● People enjoyed the session. Copyright © 2009 Russel Winder 23
  • 24. Unabashed Advertising You know you want to buy them! Copyright © 2008 Russel Winder 24
  • 25. GPars Logo Contest ● GPars project is having a logo contest: See http://docs.codehaus.org/display/GPARS/Logo+Contest ● Closing date for entries was 2009-11-30. ● Voting is now happening. Late entries are not accepted, though if significant bribes to the organizer are involved . . . Copyright © 2008 Russel Winder 25