Groovy Maven BuildsEvgeny Goldin  Thomson Reuters  @evgeny_goldin                    11
Evgeny GoldinSoftware Developer – 11 yearsDev : C++ => Perl => Java => Groovy / ScalaCM : Ant => Maven => GradleOS : A...
OpenCalais by Thomson Reuters     http://www.opencalais.com/    http://viewer.opencalais.com/                             ...
Maven state of affairs:Maven is rarely used to its fullest potential“maven-antrun-plugin” is terribly overusedPlugins d...
About this session:Maven can be made better! .. especially when you use GroovyWe’ll see how:  GMaven  Polyglot Maven ...
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P...
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  ...
<goal>execute</goal>Runs Groovy codeRuns Groovy scriptRuns Groovy class                                 1515
Get IDEsupport back!         1616   http://goo.gl/8DOe2
<goal>execute</goal>Runs Groovy codeRuns Groovy scriptRuns Groovy classMavenProjectMavenSessionMaven’s “ServletConte...
MavenProject – Static Infohttp://goo.gl/3Ve31CoordinatesPropertiesArtifactsDependenciesBasedirRemote repositories  ...
MavenSession – Runtime Infohttp://goo.gl/Kh8iLCurrent MavenProjectBuild start timeUser propertiesSystem propertiesGo...
GMaven“if” a model composition / plugin executionSpecify dynamic value when configuring a pluginPut your own logic in P...
Use case – Build Metadata                       2121
http://evgeny-goldin.com/wiki/Maven-about-plugin<plugin>  <groupId>com.goldin.plugins</groupId>  <artifactId>maven-about-p...
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 ...
2727http://goo.gl/U5eqr
2828http://goo.gl/av0Dx
Polyglot MavenGroovy syntactic sugar to Maven POMCouldn’t find a way to  Attach a code to a lifecycle  Locate MavenPro...
Polyglot Maven“if” a model composition / plugin executionSpecify dynamic value when configuring a pluginPut your own lo...
Groovy MOJOsReusableMore exposure to Maven runtime environmenthttp://delicious.com/evgenyg/mojo                        ...
Use case – Duplicates                          3232                    http://goo.gl/ZFRvp
https://github.com/evgeny-goldin/gmaven-samples                                                                          ...
http://evgeny-goldin.com/wiki/Duplicates-finder-plugin <plugin>   <groupId>com.goldin.plugins</groupId>   <artifactId>dupl...
Maven PluginsDuplicates found in:-=-= [org.codehaus.plexus:plexus-classworlds:jar:2.2.2:compile,      classworlds:classwor...
Groovy MOJOsA Groovy class + @AnnoMojo                              3636
Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties                                    3737                        ...
Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties                                    3838                        ...
Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties                                   3939                         ...
Groovy MOJOsA Groovy class + @AnnoMojoDynamic propertiesNew Maven properties                                   4040    ...
Groovy MOJOsOther plugins can be extended or invokedTheir initialization though, may not work wellhttp://github.com/Tim...
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T...
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...
Groovy MOJOs“if” a model composition / plugin executionSpecify dynamic value when configuring a pluginPut your own logi...
So ..        4646
So ..GMaven - custom build behavior on any phasePolyglot Maven is a Groovy syntactic sugarGroovy Mojos is the way to ma...
So ..GMaven - custom build behavior on any phasePolyglot Maven is a Groovy syntactic sugarGroovy Mojos is the way to ma...
So ..GMaven - custom build behavior on any phasePolyglot Maven is a Groovy syntactic sugarGroovy Mojos is the way to ma...
Maven Pluginshttp://evgeny-goldin.com/wiki/Maven-pluginsmaven-copy-pluginmaven-jenkins-pluginmaven-assert-pluginmaven...
Links@evgeny_goldinhttp://evgeny-goldin.comhttp://evgeny-goldin.orghttp://github.com/evgeny-goldin/                   ...
5252
Upcoming SlideShare
Loading in...5
×

GR8Conf 2011: Groovy Maven Builds

963

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
963
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "GR8Conf 2011: Groovy Maven Builds"

  1. 1. Groovy Maven BuildsEvgeny Goldin Thomson Reuters @evgeny_goldin 11
  2. 2. 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
  3. 3. OpenCalais by Thomson Reuters http://www.opencalais.com/ http://viewer.opencalais.com/ 33
  4. 4. 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
  5. 5. About this session:Maven can be made better! .. especially when you use GroovyWe’ll see how: GMaven Polyglot Maven Groovy MOJOs + Demo 55
  6. 6. Groovy is a new Perl. 66
  7. 7. Maven and Gradle 77
  8. 8. Gradle - dynamic build applications.Maven - repeatable build processes. 88
  9. 9. 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
  10. 10. Is the game over?Or can builds become applications? 1010
  11. 11. Use case – Build Metadata 1111
  12. 12. Ant: ~60 LOC(100 total) 3 files 1212 http://goo.gl/i0ldH
  13. 13. Groovy: ~10 LOC(30 total) 1313 http://goo.gl/GdS6y
  14. 14. Compiles Groovy codeExecutes Groovy codeGenerates Java Stubs (required for MOJOs)http://delicious.com/evgenyg/gmaven 1414
  15. 15. <goal>execute</goal>Runs Groovy codeRuns Groovy scriptRuns Groovy class 1515
  16. 16. Get IDEsupport back! 1616 http://goo.gl/8DOe2
  17. 17. <goal>execute</goal>Runs Groovy codeRuns Groovy scriptRuns Groovy classMavenProjectMavenSessionMaven’s “ServletContext” 1717
  18. 18. MavenProject – Static Infohttp://goo.gl/3Ve31CoordinatesPropertiesArtifactsDependenciesBasedirRemote repositories 1818
  19. 19. MavenSession – Runtime Infohttp://goo.gl/Kh8iLCurrent MavenProjectBuild start timeUser propertiesSystem propertiesGoalsLocal repository 1919
  20. 20. 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
  21. 21. Use case – Build Metadata 2121
  22. 22. 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
  23. 23. something.jar/META-INF/about.txt 2323
  24. 24. 2424
  25. 25. 2525
  26. 26. 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
  27. 27. 2727http://goo.gl/U5eqr
  28. 28. 2828http://goo.gl/av0Dx
  29. 29. 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
  30. 30. Polyglot Maven“if” a model composition / plugin executionSpecify dynamic value when configuring a pluginPut your own logic in POM“validate” phase 3030
  31. 31. Groovy MOJOsReusableMore exposure to Maven runtime environmenthttp://delicious.com/evgenyg/mojo 3131
  32. 32. Use case – Duplicates 3232 http://goo.gl/ZFRvp
  33. 33. https://github.com/evgeny-goldin/gmaven-samples  Duplicates Finderhttp://www.flickr.com/photos/rohdesign/3534506648/ (rohdesign.com) 3333
  34. 34. 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
  35. 35. Maven PluginsDuplicates 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 GuiceDuplicates found in:-=-= [com.google.inject:guice:jar:3.0-SNAPSHOT:compile, com.google.inject:guice:jar:no_deps:3.0-SNAPSHOT:compile] =-=- 3535
  36. 36. Groovy MOJOsA Groovy class + @AnnoMojo 3636
  37. 37. Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties 3737 http://goo.gl/UqBqn
  38. 38. Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties 3838 http://goo.gl/UqBqn
  39. 39. Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties 3939 http://goo.gl/xV73v
  40. 40. Groovy MOJOsA Groovy class + @AnnoMojoDynamic propertiesNew Maven properties 4040 http://goo.gl/tEgQa
  41. 41. 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
  42. 42. mojo-executor 4242 http://goo.gl/CT6AQ
  43. 43. 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
  44. 44. 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
  45. 45. 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
  46. 46. So .. 4646
  47. 47. 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
  48. 48. 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
  49. 49. 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
  50. 50. 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
  51. 51. Links@evgeny_goldinhttp://evgeny-goldin.comhttp://evgeny-goldin.orghttp://github.com/evgeny-goldin/ 5151
  52. 52. 5252

×