Javaone 2013 moscow gradle english

Post on 26-Jan-2015

117 views 0 download

description

The English version

Transcript of Javaone 2013 moscow gradle english

Gradle

Evgeny Borisov

Good to be programmer…

You start crooked, everything is crooked

What are the tasks of build today?

• VCS • CI scripts & different xml configurations• Dependency management• Deployment (clustering)• Unit and sanity Tests• Documentation• …

Grandson will not come today, he sent mail that the build failed.

Which build tools do you know?

I use…

1. Gradle2. Maven3. Ant4. Ivy5. I build with my hands…

Declarative & Imperative

Declarative & Imperative

• ANT – Imperative

• Maven - Declarative Not really

Maven

<build>

</build>

We Love you, XML

<build>

</build>

We also have two problems…

• XML - yes, DSL- no

Who will be today’s Chuck Norris?

Why Gradle?

• Not adopted to specific type project• Powerful DSL, which can be extended easily• Groovy• Effective build– Tasks can run in parallel – Incremental build

One doesn’t simply talk. Lets build some project.

Where is my print???

test { testLogging.showStandardStreams = true}

Build task dependency graph

It’s exactly like in maven

Not like maven at all

• You can add dependency to existing task

• You can change task behavior via it’s properties

• You can extend tasks

Build task dependency graph

I need a war!

Lets write a Task

1. Class MyTask extends DefaultTask2. Write a method @TaskAction3. Add it to DSL4. That is all!

Additional plugins

• Groovy Plugin• The Scala Plugin• The War Plugin• The Ear Plugin• The Jetty Plugin• The Eclipse Plugin• The IDEA Plugin

• AspectJ plugin• ClassLoader plugin• Exec plugin• JavaFx Plugin• Tomcat Plugin• Android Plugin• The FindBugs Plugin

Your own Plugin

• Why should I write my own plugin? It’s not enough to write my own tasks?

• Extend DSL. – We want declarative build!

Do you want plugin???

• How to write plugin:https://bitbucket.org/davidmc24/gradle-bintray-plugin/src/6adc1aca5ed712b8802fe6b3830b2d860d9fda88/Bintray.gradle?at=default

• Adding plugin: buildscript: apply from: 'gradle/Bintray.gradle'

• Usage:repositories { bintray.jcenter() }

I can’t get out of here

I deep in this ant shit

You love ant?

Migrating from ant to gradle

Migrating from ant

I can’t migrate from maven

Yes you can!

maven2gradle plugin1. Type this in your build.gradle :

apply plugin:’maven2Gradle’

2. Put this script near you pom

3. Run: gradle build

What to read?

• http://www.gradle.org/docs/current/userguide/userguide.html

• http://www.gradle.org/docs/current/dsl/• http://www.gradle.org/docs/current/javadoc/

Q&A

• bsevgeny@gmail.com