Top Banner
ANDRES ALMIRAY IX-CHEL RUIZ @AALMIRAY @IXCHELRUIZ HARDER, BETTER, STRONGER, FASTER
32

Gradle: Harder, Stronger, Better, Faster

Aug 06, 2015

Download

Software

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.
Transcript
Page 1: Gradle: Harder, Stronger, Better, Faster

ANDRES ALMIRAY IX-CHEL RUIZ @AALMIRAY @IXCHELRUIZ

HARDER, BETTER,

STRONGER, FASTER

Page 2: Gradle: Harder, Stronger, Better, Faster
Page 3: Gradle: Harder, Stronger, Better, Faster
Page 4: Gradle: Harder, Stronger, Better, Faster

WHAT

Page 5: Gradle: Harder, Stronger, Better, Faster

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 project’s will, not the other way around.

Page 6: Gradle: Harder, Stronger, Better, Faster

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 : It’s CI friendly (gradle wrapper).

Page 7: Gradle: Harder, Stronger, Better, Faster

WHY

Page 8: Gradle: Harder, Stronger, Better, Faster

RebelLabs © ZeroTurnaround

Page 9: Gradle: Harder, Stronger, Better, Faster

RebelLabs © ZeroTurnaround

Page 10: Gradle: Harder, Stronger, Better, Faster
Page 11: Gradle: Harder, Stronger, Better, Faster

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

Page 12: Gradle: Harder, Stronger, Better, Faster

HOW

Page 13: Gradle: Harder, Stronger, Better, Faster

$ curl -s get.gvmtool.net | bash $ gvm install gradle

Page 14: Gradle: Harder, Stronger, Better, Faster

.

├── build.gradle

├── pom.xml

└── src

├── main

│   └── java

│   └── sample

│   └── Foo.java

└── test

└── java

└── sample

└── FooTest.java

Page 15: Gradle: Harder, Stronger, Better, Faster

<project xmlns="http://maven.apache.org/POM/4.0.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.acme</groupId>

<artifactId>sample</artifactId>

<packaging>jar</packaging>

<version>0.0.0-SNAPSHOT</version>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.12</version>

<scope>test</scope>

</dependency>

</dependencies>

</project>

😐

Page 16: Gradle: Harder, Stronger, Better, Faster

apply plugin: 'java'

apply plugin: 'maven-publish'

version = '0.0.0-SNAPSHOT'

group = 'com.acme'

repositories {

jcenter()

}

dependencies {

testCompile 'junit:junit:4.12'

}

😎

Page 17: Gradle: Harder, Stronger, Better, Faster

SCENARIOS

Page 18: Gradle: Harder, Stronger, Better, Faster

ü  Executable/Launchable application

ü  Executable fat jar

ü  Installable application

Page 19: Gradle: Harder, Stronger, Better, Faster

EXECUTABLELAUNCHABLE APPLICATION

Page 20: Gradle: Harder, Stronger, Better, Faster

<project ...>

<build>

<plugins>

<plugin>

<groupId>org.codehaus.mojo</groupId>

<artifactId>exec-maven-plugin</artifactId>

<version>1.2.1</version>

<configuration>

<mainClass>sample.Foo</mainClass>

</configuration>

</plugin>

</plugins>

</build>

</project>

$ mvn compile exec:java

😐

Page 21: Gradle: Harder, Stronger, Better, Faster

apply plugin: 'java'

apply plugin: 'application'

mainClassName = 'sample.Foo'

$ gradle run

😎

Page 22: Gradle: Harder, Stronger, Better, Faster

EXECUTABLE FAT JAR

Page 23: Gradle: Harder, Stronger, Better, Faster

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-shade-plugin</artifactId>

<version>2.3</version>

<configuration>

<transformers>

<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">

<manifestEntries>

<Main-Class>sample.Foo</Main-Class>

</manifestEntries>

</transformer>

</transformers>

</configuration>

</plugin>

<plugins>

$ mvn package –DskipTests=true

😐

Page 24: Gradle: Harder, Stronger, Better, Faster

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

😎

Page 25: Gradle: Harder, Stronger, Better, Faster

Installable application .

├── bin

│   ├── sample

│   └── sample.bat

└── lib

├── commons-lang-2.6.jar

└── sample-0.0.0-SNAPSHOT.jar

Page 26: Gradle: Harder, Stronger, Better, Faster

1.   Add assembly plugin

2.   Create assembly descriptor

1.  Dist option for building the directory structure2.  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

😐

Page 27: Gradle: Harder, Stronger, Better, Faster

apply plugin: 'java'

apply plugin: 'application’

mainClassName = 'sample.Foo'

repositories {

jcenter()

}

dependencies {

compile 'commons-lang:commons-lang:2.6'

}

$ gradle distZip

😎

Page 28: Gradle: Harder, Stronger, Better, Faster

BUT WAIT, THERE’S

MORE

Page 29: Gradle: Harder, Stronger, Better, Faster

$ gvm install lazybones $ lazybones create gradle-quickstart sample

Page 30: Gradle: Harder, Stronger, Better, Faster
Page 31: Gradle: Harder, Stronger, Better, Faster

license versions stats bintray shadow izpack java2html git coveralls

asciidoctor jbake markdown livereload gretty Nexus watch wuff spawn

Page 32: Gradle: Harder, Stronger, Better, Faster

THANK YOU!

HTTP://PEOPLE.CANOO.COM/SHARE

ANDRES ALMIRAY IX-CHEL RUIZ @AALMIRAY @IXCHELRUIZ