Groovy Maven Builds


Evgeny Goldin
  Thomson Reuters
  @evgeny_goldin




                    11
Evgeny Goldin
Software Developer – 11 years
Dev : C++ => Perl => Java => Groovy / Scala
CM : Ant => Maven => Gradle
OS : Artifactory, TeamCity, Jenkins
Write for GroovyMag and Methods & Tools
Maven plugins, GCommons library



                                               22
OpenCalais by Thomson Reuters
     http://www.opencalais.com/
    http://viewer.opencalais.com/




                                    33
Maven state of affairs:
Maven is rarely used to its fullest potential
“maven-antrun-plugin” is terribly overused
Plugins development is limited
  http://maven.apache.org/plugins
  http://mojo.codehaus.org/plugins.html




                                                 44
About this session:
Maven can be made better!
 .. especially when you use Groovy
We’ll see how:
  GMaven
  Polyglot Maven
  Groovy MOJOs + Demo




                                      55
Groovy is a new Perl.




                        66
Maven and Gradle




                   77
Gradle - dynamic build applications.
Maven - repeatable build processes.




                                 88
Maven makes it awkward to ..
“if” a model composition / plugin execution
Specify dynamic value when configuring a plugin
Put your own logic in POM
Modify existing plugins behavior
Pass in-memory information between plugins




                                               99
Is the game over?
Or can builds become applications?




                             1010
Use case – Build Metadata




                       1111
Ant:
 ~60 LOC
(100 total)
   3 files




          1212
      http://goo.gl/i0ldH
Groovy:
 ~10 LOC
(30 total)




           1313
      http://goo.gl/GdS6y
Compiles Groovy code
Executes Groovy code
Generates Java Stubs (required for MOJOs)
http://delicious.com/evgenyg/gmaven




                                             1414
<goal>execute</goal>
Runs Groovy code
Runs Groovy script
Runs Groovy class




                                 1515
Get IDE
support
 back!




         1616
   http://goo.gl/8DOe2
<goal>execute</goal>
Runs Groovy code
Runs Groovy script
Runs Groovy class
MavenProject
MavenSession
Maven’s “ServletContext”



                                 1717
MavenProject – Static Info
http://goo.gl/3Ve31
Coordinates
Properties
Artifacts
Dependencies
Basedir
Remote repositories

                               1818
MavenSession – Runtime Info
http://goo.gl/Kh8iL
Current MavenProject
Build start time
User properties
System properties
Goals
Local repository

                            1919
GMaven
“if” a model composition / plugin execution
Specify dynamic value when configuring a plugin
Put your own logic in POM
Modify existing plugins behavior
Pass in-memory information between plugins




                                               2020
Use case – Build Metadata




                       2121
http://evgeny-goldin.com/wiki/Maven-about-plugin

<plugin>
  <groupId>com.goldin.plugins</groupId>
  <artifactId>maven-about-plugin</artifactId>
  <version>0.2.3</version>
</plugin>



                                                2222
something.jar/META-INF/about.txt




                                   2323
2424
2525
Polyglot Maven
https://docs.sonatype.org/display/PMAVEN/
https://github.com/sonatype/polyglot-maven
git clone + mvn clean install
translate pom.xml pom.groovy




                                              2626
2727
http://goo.gl/U5eqr
2828
http://goo.gl/av0Dx
Polyglot Maven
Groovy syntactic sugar to Maven POM
Couldn’t find a way to
  Attach a code to a lifecycle
  Locate MavenProject and MavenSession




                                          2929
Polyglot Maven
“if” a model composition / plugin execution
Specify dynamic value when configuring a plugin
Put your own logic in POM
“validate” phase




                                               3030
Groovy MOJOs
Reusable
More exposure to Maven runtime environment
http://delicious.com/evgenyg/mojo




                                              3131
Use case – Duplicates




                          3232
                    http://goo.gl/ZFRvp
https://github.com/evgeny-goldin/gmaven-samples



                                            


                                                     Duplicates
                                                      Finder
http://www.flickr.com/photos/rohdesign/3534506648/ (rohdesign.com)   3333
http://evgeny-goldin.com/wiki/Duplicates-finder-plugin

 <plugin>
   <groupId>com.goldin.plugins</groupId>
   <artifactId>duplicates-finder-plugin</artifactId>
   <version>0.2.3</version>
 </plugin>



                                                3434
Maven Plugins
Duplicates found in:
-=-= [org.codehaus.plexus:plexus-classworlds:jar:2.2.2:compile,
      classworlds:classworlds:jar:1.1:compile] =-=-
-=-= [commons-logging:commons-logging-api:jar:1.1:compile,
      commons-logging:commons-logging:jar:1.1.1:compile] =-=-
-=-= [nekohtml:xercesMinimal:jar:1.9.6.2:compile,
      xerces:xercesImpl:jar:2.8.1:compile] =-=-
-=-= [nekohtml:nekohtml:jar:1.9.6.2:compile,
      net.sourceforge.nekohtml:nekohtml:jar:1.9.9:compile] =-=-
-=-= [commons-beanutils:commons-beanutils:jar:1.8.0:compile,
      commons-collections:commons-collections:jar:3.2.1:compile] =-=-


                                   Google Guice
Duplicates found in:
-=-= [com.google.inject:guice:jar:3.0-SNAPSHOT:compile,
      com.google.inject:guice:jar:no_deps:3.0-SNAPSHOT:compile] =-=-

                                                                        3535
Groovy MOJOs
A Groovy class + @AnnoMojo




                              3636
Groovy MOJOs
A Groovy class + @AnnoMojo
Dynamic properties




                                    3737
                              http://goo.gl/UqBqn
Groovy MOJOs
A Groovy class + @AnnoMojo
Dynamic properties




                                    3838
                              http://goo.gl/UqBqn
Groovy MOJOs
A Groovy class + @AnnoMojo
Dynamic properties




                                   3939
                              http://goo.gl/xV73v
Groovy MOJOs
A Groovy class + @AnnoMojo
Dynamic properties
New Maven properties




                                   4040
                              http://goo.gl/tEgQa
Groovy MOJOs
Other plugins can be extended or invoked
Their initialization though, may not work well
http://github.com/TimMoore/mojo-executor




                                                   4141
                                              http://goo.gl/tEgQa
mojo-executor




                      4242
                http://goo.gl/CT6AQ
Groovy MOJOs
A Groovy class + @AnnoMojo
Dynamic properties
New Maven properties
Other plugins can be extended or invoked
That’s how you deal with Maven!




                                            4343
Maven 3 vs. Maven 2
IE9 vs. IE6
Maven 3: Aether, mojo-executor, better Mojo support
Maven 3 Mojos will not run on Maven 2
Maven 2 support will seriously hold you back




                                                4444
Groovy MOJOs
“if” a model composition / plugin execution
Specify dynamic value when configuring a plugin
Put your own logic in POM
Modify existing plugins behavior
Pass in-memory information between plugins




                                               4545
So ..




        4646
So ..
GMaven - custom build behavior on any phase
Polyglot Maven is a Groovy syntactic sugar
Groovy Mojos is the way to make it your way




                                               4747
So ..
GMaven - custom build behavior on any phase
Polyglot Maven is a Groovy syntactic sugar
Groovy Mojos is the way to make it your way
Creating build applications with Maven – doable!
  Maven is not a solution, but a platform




                                                4848
So ..
GMaven - custom build behavior on any phase
Polyglot Maven is a Groovy syntactic sugar
Groovy Mojos is the way to make it your way
Creating build applications with Maven – doable!
  Maven is not a solution, but a platform
  We don’t have to be limited by existing plugins
  Perl, IDEA, Jenkins, jQuery, Grails, Gradle ..




                                                     4949
Maven Plugins
http://evgeny-goldin.com/wiki/Maven-plugins
maven-copy-plugin
maven-jenkins-plugin
maven-assert-plugin
maven-mail-plugin
maven-about-plugin
duplicates-finder-plugin


                                               5050
Links
@evgeny_goldin
http://evgeny-goldin.com
http://evgeny-goldin.org
http://github.com/evgeny-goldin/




                                    5151
5252

More Related Content

PPT
Groovy Maven Builds
PPTX
PPTX
Maven
PDF
Enterprise Maven Repository BOF
KEY
How to be effective with JBoss Developer Studio
KEY
Tycho - good, bad or ugly ?
KEY
うさぎ組 in G* WorkShop -うさみみの日常-
PDF
Jenkinsプラグインの作り方
Groovy Maven Builds
Maven
Enterprise Maven Repository BOF
How to be effective with JBoss Developer Studio
Tycho - good, bad or ugly ?
うさぎ組 in G* WorkShop -うさみみの日常-
Jenkinsプラグインの作り方

What's hot (20)

PDF
Testing Drupal with Ghosts and Gherkin
PDF
Hands on the Gradle
PDF
Ant, Maven and Jenkins
PDF
Whats New In Groovy 1.6?
PDF
Nas 也可以揀土豆
PDF
Freeing the cloud, one service at a time
PPTX
Apache Maven 2 Part 2
PDF
Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020
PDF
JBoss Enterprise Maven Repository
PDF
2014-08-19 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Chicago
PDF
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
PDF
Google App Engine: Basic
PDF
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
PDF
Build system
PDF
JDD 2017: 7 things which you should care about before release your code to pr...
PDF
Lightweight javaEE with Guice
PDF
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
PDF
CQCON CQ Maven Methods
PDF
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
PPT
Choosing a Java Web Framework
Testing Drupal with Ghosts and Gherkin
Hands on the Gradle
Ant, Maven and Jenkins
Whats New In Groovy 1.6?
Nas 也可以揀土豆
Freeing the cloud, one service at a time
Apache Maven 2 Part 2
Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020
JBoss Enterprise Maven Repository
2014-08-19 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Chicago
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
Google App Engine: Basic
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Build system
JDD 2017: 7 things which you should care about before release your code to pr...
Lightweight javaEE with Guice
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
CQCON CQ Maven Methods
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
Choosing a Java Web Framework
Ad

Viewers also liked (8)

PDF
GR8Conf 2009: Opening Keynote by Søren Berg Glasius and Guillaume Laforge
PDF
GR8Conf 2011: Neo4j Plugin
PPT
Ethan Chazin 2011 Praxis Retreat
PDF
GR8Conf 2011: Groovy 1.8 update
PDF
GR8Conf 2011: Canoo RIA Suite
PDF
GR8Conf 2009: Griffon by Jim Shingler
PDF
GR8Conf 2011: Grails Infinispanplugin, Tom Fuller
PDF
GR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2009: Opening Keynote by Søren Berg Glasius and Guillaume Laforge
GR8Conf 2011: Neo4j Plugin
Ethan Chazin 2011 Praxis Retreat
GR8Conf 2011: Groovy 1.8 update
GR8Conf 2011: Canoo RIA Suite
GR8Conf 2009: Griffon by Jim Shingler
GR8Conf 2011: Grails Infinispanplugin, Tom Fuller
GR8Conf 2011: Building Progressive UIs with Grails
Ad

Similar to GR8Conf 2011: Groovy Maven Builds (20)

PPTX
Avatar Maven
PDF
In the Brain of Hans Dockter: Gradle
PPTX
Apache Maven
PDF
Groovy 1 7 Update, past, present, future - S2G Forum 2010
PPT
An introduction to maven gradle and sbt
PDF
Java Edge.2009.Grails.Web.Dev.Made.Easy
PDF
Apache Maven - eXo TN presentation
PDF
Lorraine JUG (1st June, 2010) - Maven
PDF
Next Generation Development Infrastructure: Maven, m2eclipse, Nexus & Hudson ...
PPT
Java Build Tools
PDF
Groovy & Grails for Spring/Java developers
PDF
Intelligent Projects with Maven - DevFest Istanbul
PDF
淺談 Groovy 與 AWS 雲端應用開發整合
PPTX
An Introduction to Maven
PDF
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
PDF
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
KEY
Polyglot Grails
PDF
GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook
PDF
Java Builds with Maven and Ant
Avatar Maven
In the Brain of Hans Dockter: Gradle
Apache Maven
Groovy 1 7 Update, past, present, future - S2G Forum 2010
An introduction to maven gradle and sbt
Java Edge.2009.Grails.Web.Dev.Made.Easy
Apache Maven - eXo TN presentation
Lorraine JUG (1st June, 2010) - Maven
Next Generation Development Infrastructure: Maven, m2eclipse, Nexus & Hudson ...
Java Build Tools
Groovy & Grails for Spring/Java developers
Intelligent Projects with Maven - DevFest Istanbul
淺談 Groovy 與 AWS 雲端應用開發整合
An Introduction to Maven
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
Polyglot Grails
GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook
Java Builds with Maven and Ant

More from GR8Conf (20)

PDF
DevOps Enabling Your Team
PDF
Creating and testing REST contracts with Accurest Gradle
PDF
Mum, I want to be a Groovy full-stack developer
PDF
Metaprogramming with Groovy
PDF
Scraping with Geb
PDF
How to create a conference android app with Groovy and Android
PDF
Ratpack On the Docks
PDF
Groovy Powered Clean Code
PDF
Cut your Grails application to pieces - build feature plugins
PDF
Performance tuning Grails applications
PDF
Ratpack and Grails 3
PDF
Grails & DevOps: continuous integration and delivery in the cloud
PDF
Functional testing your Grails app with GEB
PDF
Deploying, Scaling, and Running Grails on AWS and VPC
PDF
The Grails introduction workshop
PDF
Idiomatic spock
PDF
The Groovy Ecosystem Revisited
PDF
Groovy 3 and the new Groovy Meta Object Protocol in examples
PDF
Integration using Apache Camel and Groovy
PDF
CRaSH the shell for the Java Virtual Machine
DevOps Enabling Your Team
Creating and testing REST contracts with Accurest Gradle
Mum, I want to be a Groovy full-stack developer
Metaprogramming with Groovy
Scraping with Geb
How to create a conference android app with Groovy and Android
Ratpack On the Docks
Groovy Powered Clean Code
Cut your Grails application to pieces - build feature plugins
Performance tuning Grails applications
Ratpack and Grails 3
Grails & DevOps: continuous integration and delivery in the cloud
Functional testing your Grails app with GEB
Deploying, Scaling, and Running Grails on AWS and VPC
The Grails introduction workshop
Idiomatic spock
The Groovy Ecosystem Revisited
Groovy 3 and the new Groovy Meta Object Protocol in examples
Integration using Apache Camel and Groovy
CRaSH the shell for the Java Virtual Machine

Recently uploaded (20)

PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
The various Industrial Revolutions .pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Modernising the Digital Integration Hub
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
DOCX
search engine optimization ppt fir known well about this
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PPT
What is a Computer? Input Devices /output devices
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
CloudStack 4.21: First Look Webinar slides
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Abstractive summarization using multilingual text-to-text transfer transforme...
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
The various Industrial Revolutions .pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
A contest of sentiment analysis: k-nearest neighbor versus neural network
A comparative study of natural language inference in Swahili using monolingua...
Modernising the Digital Integration Hub
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
search engine optimization ppt fir known well about this
OpenACC and Open Hackathons Monthly Highlights July 2025
What is a Computer? Input Devices /output devices
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
A review of recent deep learning applications in wood surface defect identifi...
Zenith AI: Advanced Artificial Intelligence
CloudStack 4.21: First Look Webinar slides
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Module 1.ppt Iot fundamentals and Architecture
Getting started with AI Agents and Multi-Agent Systems
Convolutional neural network based encoder-decoder for efficient real-time ob...
How ambidextrous entrepreneurial leaders react to the artificial intelligence...

GR8Conf 2011: Groovy Maven Builds