gradle                                     Thor Åge EldbyMonday, November 21, 2011                             1
Thor Åge Eldby                 @thoraageeldby                            Arktekk                                      2Mon...
Build Systems                   make                                                sbt                                   ...
What: Repeatable                            ear     ear       ear   ear                                          4Monday, ...
What: Flexible                                  5Monday, November 21, 2011                    5Possible to buildSimple-Mav...
What: Readable                                  6Monday, November 21, 2011                    6Not a black boxDiffableGUI ...
What: Conventions                                    7Monday, November 21, 2011                       7RecognisableStructu...
8Monday, November 21, 2011                          8RepeatableFlexible - Groovy (and ant) building DSLReadableConventions...
Simple Example                      apply plugin: java                      repositories {                        mavenCen...
Plugin                      apply plugin: java                      repositories {                        mavenCentral()  ...
Dependencies                      apply plugin: java                      repositories {                        mavenCentr...
Dependencies                      apply plugin: java              repositories {          dependencies {                ma...
Dependencies                      apply plugin: java              repositories {          dependencies {          dependen...
Dependencies                      apply plugin: java          dependencies {              repositories {          dependen...
Dependencies                      apply plugin: java          dependencies {              repositories {          dependen...
Dependencies                      apply plugin: java          dependencies {              repositories {          dependen...
Repositories                      apply plugin: java                      repositories {                        mavenCentr...
Repositories                      apply plugin: java              repositories {          repositories {                ma...
Repositories                      apply plugin: java              repositories {          repositories {                ma...
Repositories                      apply plugin: java          repositories {              repositories {          reposito...
Repositories                      apply plugin: java          repositories {          repositories {               reposit...
Coding It                      apply plugin: java                      repositories {                        mavenCentral(...
Coding It                      apply plugin: java                      repositories {                        mavenCentral(...
Multi Project                               myproject                                  api                                ...
Multi Project                settings.gradle                      include common, api, web                                ...
Multi Project                settings.gradle                      include common, api, web                      def subs(p...
Multi Project               build.gradle                      subprojects {                        apply plugin: java     ...
Multi Project               build.gradle               subprojects {                 apply plugin: java                 re...
Multi Project               build.gradle               subprojects {                 apply plugin: java                 re...
Multi Project              common/common.gradle                                  17Monday, November 21, 2011              ...
Multi Project              common/common.gradle                                  17Monday, November 21, 2011              ...
Multi Project                    api/api.gradle                      dependencies {                        compile project...
Multi Project                web/web.gradle                      apply plugin: ‘war’                      dependencies {  ...
Multi Project                                 myproject                                    api                            ...
Multi Project                                 myproject                                    api                            ...
Multi Project                                 myproject                                    common                         ...
Plugin Support                                             21Monday, November 21, 2011                                    ...
Writing Own Plugins                                22Monday, November 21, 2011                    221.Hack it together2.Co...
IDE Support                                             23Monday, November 21, 2011                         23Plugins for ...
IDE Support                                             23Monday, November 21, 2011                         23Plugins for ...
IDE Support                                             23Monday, November 21, 2011                         23Plugins for ...
IDE Support                              ?                                             23Monday, November 21, 2011        ...
Performance                                         24Monday, November 21, 2011                     24Generally OKLoads al...
Coming Attractions                                  NEW                             25Monday, November 21, 2011           ...
Conclusion                                              26Monday, November 21, 2011                                       ...
:compileJava UP-TO-DATE                      :processResources UP-TO-DATE                            END                  ...
Upcoming SlideShare
Loading in...5
×

Gradle

1,109

Published on

Experience report from porting an Ant and a Maven project to Gradle. Held at javaBin 5. October 2011.

The slides give an overview of the content.

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
1,109
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
36
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Gradle"

  1. 1. gradle Thor Åge EldbyMonday, November 21, 2011 1
  2. 2. Thor Åge Eldby @thoraageeldby Arktekk 2Monday, November 21, 2011 22.5 år in Arktekk16 år in system development
  3. 3. Build Systems make sbt 3Monday, November 21, 2011 3Make, batch-files (COS,Steinar Haugen,Kenneth Stigen)ant -> can compile javamaven -> conventions, dependenciessbt and now gradle
  4. 4. What: Repeatable ear ear ear ear 4Monday, November 21, 2011 4Independent from host, platform, timeAll information in build scripts•How•What•Externals-Ant
  5. 5. What: Flexible 5Monday, November 21, 2011 5Possible to buildSimple-Maven, Ant
  6. 6. What: Readable 6Monday, November 21, 2011 6Not a black boxDiffableGUI is not
  7. 7. What: Conventions 7Monday, November 21, 2011 7RecognisableStructuresCommands-Ant
  8. 8. 8Monday, November 21, 2011 8RepeatableFlexible - Groovy (and ant) building DSLReadableConventions - Follows maven structure partlySystemised, programmable ant
  9. 9. Simple Example apply plugin: java repositories { mavenCentral() } dependencies { compile com.google.guava:guava:r08 } 9Monday, November 21, 2011 9Needed to compile java code into jarBuild DSLScript blocks (many)
  10. 10. Plugin apply plugin: java repositories { mavenCentral() } dependencies { compile com.google.guava:guava:r08 } 10Monday, November 21, 2011 10Interpreted script
  11. 11. Dependencies apply plugin: java repositories { mavenCentral() } dependencies { compile com.google.guava:guava:r08 } 11Monday, November 21, 2011 11Configuration like scope in maven... and classpath in ant
  12. 12. Dependencies apply plugin: java repositories { dependencies { mavenCentral() compile project(:common) } } dependencies { compile com.google.guava:guava:r08 } 11Monday, November 21, 2011 11Configuration like scope in maven... and classpath in ant
  13. 13. Dependencies apply plugin: java repositories { dependencies { dependencies { mavenCentral() testCompile group: junit, name: junit, compile project(:common) } version: 4.+ } } dependencies { compile com.google.guava:guava:r08 } 11Monday, November 21, 2011 11Configuration like scope in maven... and classpath in ant
  14. 14. Dependencies apply plugin: java dependencies { repositories { dependencies { dependencies { compile(org.hibernate:hibernate:3.0.5) { mavenCentral() testCompile group: junit, name: junit, compile project(:common) transitive = false } version: 4.+ } } } dependencies { } compile com.google.guava:guava:r08 } 11Monday, November 21, 2011 11Configuration like scope in maven... and classpath in ant
  15. 15. Dependencies apply plugin: java dependencies { repositories { dependencies { dependencies { compile(org.hibernate:hibernate:3.0.5) { runtime files(libs/a.jar, libs/b.jar) mavenCentral() testCompile group: junit, name: junit, runtime fileTree(dir: libs, compile project(:common) transitive = false } version: 4.+ } } include: *.jar) } dependencies { } compile com.google.guava:guava:r08 } 11Monday, November 21, 2011 11Configuration like scope in maven... and classpath in ant
  16. 16. Dependencies apply plugin: java dependencies { repositories { dependencies { dependencies { compile(org.hibernate:hibernate:3.0.5) { testCompile(org.testng:testng:6.2.1) { runtime files(libs/a.jar, libs/b.jar) mavenCentral() testCompile group: junit, name: junit, runtime fileTree(dir: libs, compile project(:common) transitive = false exclude module: guice } version: 4.+ } } include: *.jar) } dependencies { } compile com.google.guava:guava:r08 } 11Monday, November 21, 2011 11Configuration like scope in maven... and classpath in ant
  17. 17. Repositories apply plugin: java repositories { mavenCentral() } dependencies { compile com.google.guava:guava:r08 } 12Monday, November 21, 2011 12
  18. 18. Repositories apply plugin: java repositories { repositories { mavenCentral() mavenRepo urls: "http://repo.my.com/maven2" } } dependencies { compile com.google.guava:guava:r08 } 12Monday, November 21, 2011 12
  19. 19. Repositories apply plugin: java repositories { repositories { mavenCentral() mavenLocal() mavenRepo urls: "http://repo.my.com/maven2" } } dependencies { compile com.google.guava:guava:r08 } 12Monday, November 21, 2011 12
  20. 20. Repositories apply plugin: java repositories { repositories { repositories { flatDir { mavenCentral() mavenLocal() mavenRepo urls: "http://repo.my.com/maven2" dirs lib } } } dependencies { } compile com.google.guava:guava:r08 } 12Monday, November 21, 2011 12
  21. 21. Repositories apply plugin: java repositories { repositories { repositories { ivy { repositories { flatDir { mavenCentral() url "http://repo.mycompany.com/repo" mavenLocal() mavenRepo urls: "http://repo.my.com/maven2" dirs lib } layout "maven" } } } dependencies { } } compile com.google.guava:guava:r08 } 12Monday, November 21, 2011 12
  22. 22. Coding It apply plugin: java repositories { mavenCentral() } dependencies { compile com.google.guava:guava:r08 } 13Monday, November 21, 2011 13Tasks (like ant targets)•Depends onRepositories•Uses mavenConfigurations (like maven scopes)Building simple example without pluginsCompile java and jar itKeeping out testing and all the other stuffPrefer functions over tasks
  23. 23. Coding It apply plugin: java repositories { mavenCentral() } dependencies { compile com.google.guava:guava:r08 } 13Monday, November 21, 2011 13Tasks (like ant targets)•Depends onRepositories•Uses mavenConfigurations (like maven scopes)Building simple example without pluginsCompile java and jar itKeeping out testing and all the other stuffPrefer functions over tasks
  24. 24. Multi Project myproject api common web 14Monday, November 21, 2011 14
  25. 25. Multi Project settings.gradle include common, api, web 15Monday, November 21, 2011 15Settings object - Including multiprojects
  26. 26. Multi Project settings.gradle include common, api, web def subs(project) { def children = project.children children + children.collect { subs(it) } } subs(rootProject).flatten().each { it.buildFileName = "${it.name}.gradle" } 15Monday, November 21, 2011 15Settings object - Including multiprojects
  27. 27. Multi Project build.gradle subprojects { apply plugin: java repositories { mavenRepo urls: http://here } dependencies { compile com.google.guava:guava:10.0 } } 16Monday, November 21, 2011 16
  28. 28. Multi Project build.gradle subprojects { apply plugin: java repositories { mavenRepo urls: http://here allprojects { ... } } dependencies { compile com.google.guava:guava:10.0 } } 16Monday, November 21, 2011 16
  29. 29. Multi Project build.gradle subprojects { apply plugin: java repositories { mavenRepo urls: http://here project(‘:common’) { allprojects { ... } } dependencies { compile com.google.guava:guava:10.0 } } 16Monday, November 21, 2011 16
  30. 30. Multi Project common/common.gradle 17Monday, November 21, 2011 17Empty -> Remove
  31. 31. Multi Project common/common.gradle 17Monday, November 21, 2011 17Empty -> Remove
  32. 32. Multi Project api/api.gradle dependencies { compile project(‘:common’) } 18Monday, November 21, 2011 18
  33. 33. Multi Project web/web.gradle apply plugin: ‘war’ dependencies { compile project(‘:api’) } war { webAppDir file(‘src/main/webapp’) } 19Monday, November 21, 2011 19
  34. 34. Multi Project myproject api common web 20Monday, November 21, 2011 20Built alphabeticallyUnless dependenciesCross module dependencies•Single cmd to draw out result
  35. 35. Multi Project myproject api common web 20Monday, November 21, 2011 20Built alphabeticallyUnless dependenciesCross module dependencies•Single cmd to draw out result
  36. 36. Multi Project myproject common api web 20Monday, November 21, 2011 20Built alphabeticallyUnless dependenciesCross module dependencies•Single cmd to draw out result
  37. 37. Plugin Support 21Monday, November 21, 2011 21Maven plugin (uploads artifacts)Eclipse/Idea plugin•Never get the maven integration, nothing can be said before all config is loadedJava / Groovy / ScalaWar / Ear / Antlr / Announce / Application / JettySonar / Project Report / Code QualityMore on github
  38. 38. Writing Own Plugins 22Monday, November 21, 2011 221.Hack it together2.Copy it3.Create a plugin
  39. 39. IDE Support 23Monday, November 21, 2011 23Plugins for Idea and EclipseIdea functions very wellNot for gradle code: Gradle support in Idea 11Netbeans being worked on (by Oracle)
  40. 40. IDE Support 23Monday, November 21, 2011 23Plugins for Idea and EclipseIdea functions very wellNot for gradle code: Gradle support in Idea 11Netbeans being worked on (by Oracle)
  41. 41. IDE Support 23Monday, November 21, 2011 23Plugins for Idea and EclipseIdea functions very wellNot for gradle code: Gradle support in Idea 11Netbeans being worked on (by Oracle)
  42. 42. IDE Support ? 23Monday, November 21, 2011 23Plugins for Idea and EclipseIdea functions very wellNot for gradle code: Gradle support in Idea 11Netbeans being worked on (by Oracle)
  43. 43. Performance 24Monday, November 21, 2011 24Generally OKLoads all configuration•Daemon may fix thisCalculates MD5 sums for inputs/outputs
  44. 44. Coming Attractions NEW 25Monday, November 21, 2011 25Release 0.1 @ April 2008A little immature, version 1.0m3 (1.0m4 withdrawn)1.0 milestone 5•Daemon (4)•EAR, Signing (4)•Experimental C++•Multi process safe caches
  45. 45. Conclusion 26Monday, November 21, 2011 26Strangeness:•Hard to test plugins•Low on documentation (search mailing-list)•Changes can be made to early or to late for the process•Silent when it’s unable to find a project artifact (due to missing dependencies)Perfect for reviving ant-projectsFlexible flexible flexible
  46. 46. :compileJava UP-TO-DATE :processResources UP-TO-DATE END :classes UP-TO-DATE :jar UP-TO-DATE :assemble UP-TO-DATE :compileTestJava UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test UP-TO-DATE :check UP-TO-DATE :build UP-TO-DATE BUILD SUCCESSFUL Total time: 3233.278 secs 27Monday, November 21, 2011 27

×