Top Banner

Gradle: Harder, Stronger, Better, Faster

Aug 06, 2015



Andres Almiray
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.

1. ANDRES ALMIRAY IX-CHEL RUIZ @AALMIRAY @IXCHELRUIZ HARDER, BETTER, STRONGER, FASTER 2. WHAT 3. Gradle is a build tool designed to take advantage of conventions over (not instead) configuration, while staying flexible enough to be customized to the needs of a particular project. In other words, the build tool bends to the projects will, not the other way around. 4. Follows the Maven conventions. Expressive : Prefers a DSL for describing what needs to be done. Extensible : Has a growing an thriving plugin ecosystem. Productive : Fosters fast and reproducible builds. Convenient : Its CI friendly (gradle wrapper). 5. WHY 6. RebelLabs ZeroTurnaround 7. RebelLabs ZeroTurnaround 8. Caching of task input and outputs Richer, configurable lifecycle The Gradle deamon The Gradle wrapper Multi-project builds are hassle free Plugin development is more intuitive Better documentation overall 9. HOW 10. $ curl -s | bash $ gvm install gradle 11. . build.gradle pom.xml src main java sample test java sample 12. 4.0.0com.acmesamplejar0.0.0-SNAPSHOTjunitjunit4.12test 13. apply plugin: 'java' apply plugin: 'maven-publish' version = '0.0.0-SNAPSHOT' group = 'com.acme' repositories { jcenter() } dependencies { testCompile 'junit:junit:4.12' } 14. SCENARIOS 15. Executable/Launchable application Executable fat jar Installable application 16. EXECUTABLE LAUNCHABLE APPLICATION 17. org.codehaus.mojoexec-maven-plugin1.2.1sample.Foo $ mvn compile exec:java 18. apply plugin: 'java' apply plugin: 'application' mainClassName = 'sample.Foo' $ gradle run 19. EXECUTABLE FAT JAR 20. org.apache.maven.pluginsmaven-shade-plugin2.3sample.Foo $ mvn package DskipTests=true 21. plugins { id 'com.github.johnrengelman.shadow' version '1.2.1' } apply plugin: 'java' apply plugin: 'application' mainClassName = 'sample.Foo' repositories { jcenter() } dependencies { compile 'commons-lang:commons-lang:2.6' } $ gradle shadowJar 22. Installable application . bin sample sample.bat lib commons-lang-2.6.jar sample-0.0.0-SNAPSHOT.jar 23. 1. Add assembly plugin 2. Create assembly descriptor 1. Dist option for building the directory structure 2. Zip option for packing all in a single file 3. Create launch scripts (for all target platforms!) 4. Might require custom profiles OR configure the appassembler plugin 24. apply plugin: 'java' apply plugin: 'application mainClassName = 'sample.Foo' repositories { jcenter() } dependencies { compile 'commons-lang:commons-lang:2.6' } $ gradle distZip 25. BUT WAIT, THERES MORE 26. $ gvm install lazybones $ lazybones create gradle-quickstart sample 27. license versions stats bintray shadow izpack java2html git coveralls asciidoctor jbake markdown livereload gretty Nexus watch wuff spawn 28. THANK YOU! HTTP://PEOPLE.CANOO.COM/SHARE ANDRES ALMIRAY IX-CHEL RUIZ @AALMIRAY @IXCHELRUIZ