GR8Conf 2011: Groovy Maven Builds

  • 915 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
915
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Groovy Maven BuildsEvgeny Goldin Thomson Reuters @evgeny_goldin 11
  • 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. OpenCalais by Thomson Reuters http://www.opencalais.com/ http://viewer.opencalais.com/ 33
  • 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. 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. Groovy is a new Perl. 66
  • 7. Maven and Gradle 77
  • 8. Gradle - dynamic build applications.Maven - repeatable build processes. 88
  • 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. Is the game over?Or can builds become applications? 1010
  • 11. Use case – Build Metadata 1111
  • 12. Ant: ~60 LOC(100 total) 3 files 1212 http://goo.gl/i0ldH
  • 13. Groovy: ~10 LOC(30 total) 1313 http://goo.gl/GdS6y
  • 14. Compiles Groovy codeExecutes Groovy codeGenerates Java Stubs (required for MOJOs)http://delicious.com/evgenyg/gmaven 1414
  • 15. <goal>execute</goal>Runs Groovy codeRuns Groovy scriptRuns Groovy class 1515
  • 16. Get IDEsupport back! 1616 http://goo.gl/8DOe2
  • 17. <goal>execute</goal>Runs Groovy codeRuns Groovy scriptRuns Groovy classMavenProjectMavenSessionMaven’s “ServletContext” 1717
  • 18. MavenProject – Static Infohttp://goo.gl/3Ve31CoordinatesPropertiesArtifactsDependenciesBasedirRemote repositories 1818
  • 19. MavenSession – Runtime Infohttp://goo.gl/Kh8iLCurrent MavenProjectBuild start timeUser propertiesSystem propertiesGoalsLocal repository 1919
  • 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. Use case – Build Metadata 2121
  • 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. something.jar/META-INF/about.txt 2323
  • 24. 2424
  • 25. 2525
  • 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. 2727http://goo.gl/U5eqr
  • 28. 2828http://goo.gl/av0Dx
  • 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. 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. Groovy MOJOsReusableMore exposure to Maven runtime environmenthttp://delicious.com/evgenyg/mojo 3131
  • 32. Use case – Duplicates 3232 http://goo.gl/ZFRvp
  • 33. https://github.com/evgeny-goldin/gmaven-samples  Duplicates Finderhttp://www.flickr.com/photos/rohdesign/3534506648/ (rohdesign.com) 3333
  • 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. 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. Groovy MOJOsA Groovy class + @AnnoMojo 3636
  • 37. Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties 3737 http://goo.gl/UqBqn
  • 38. Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties 3838 http://goo.gl/UqBqn
  • 39. Groovy MOJOsA Groovy class + @AnnoMojoDynamic properties 3939 http://goo.gl/xV73v
  • 40. Groovy MOJOsA Groovy class + @AnnoMojoDynamic propertiesNew Maven properties 4040 http://goo.gl/tEgQa
  • 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. mojo-executor 4242 http://goo.gl/CT6AQ
  • 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. 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. 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. So .. 4646
  • 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. 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. 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. 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. Links@evgeny_goldinhttp://evgeny-goldin.comhttp://evgeny-goldin.orghttp://github.com/evgeny-goldin/ 5151
  • 52. 5252