Gradle Basic - How to use Gradle in Java Project

  • View
    2.918

  • Download
    3

Embed Size (px)

DESCRIPTION

This document explains how to use gradle in Java project. It contains a real sample build file using Spring MVC project which is using education example in OSC.

Transcript

  • 1. Introduction to Gradle

2. Overview Gradle . Groovy DSL(Domain Specific Language). . Single Project Multi Project . Maven, Ivy, Jars . Gradle Migration . Ant Task Gradle . Groovy third party libraries . Gradle Wrapper Gradle .2 - Internal Use Only - 3. Installing Gradle Gradle OS . http://www.gradle.org/downloads Current Stable Release . . GRADLE_HOME . PATH $GRADLE_HOME/bin .$ wget http://services.gradle.org/distributions/gradle-1.10-all.zip Connecting to downloads.gradle.org|54.239.186.240|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 54965002 (52M) [application/zip] Saving to: gradle-1.10-all.zip 100%[==================================================>] 54,965,002 11.1MB/s in 4.7s 2014-01-22 14:52:04 (11.0 MB/s) - gradle-1.10-all.zip saved [54965002/54965002] $ sudo unzip -q gradle-1.10-bin.zip -d /usr/local/ $ echo "export GRADLE_HOME=/usr/local/gradle-1.10" >> .bash_profile $ echo "export PATH=$PATH:$GRADLE_HOME/bin" >> .bash_profile3 - Internal Use Only - 4. The Gradle Command Line gradle [option...] [task...] Gradle build , option Help task . -?, -h, --help : help message -q : -x, --exclude-task : task --continue : , -d, --debug : stacktrace debug -i, --info : Log Level INFO -b, --build-file : build.gradle -D, --system-prop : JVM System Property --gui : Gradle GUI projects : sub-project properties : properties tasks : task 4 - Internal Use Only - 5. Build Script Basics (1 / 6) build.gradle project task . Gradle build project . project task , task Ant target .gradle build.gradle . Hello World build.gradle . ( ) task hello { doLast { println 'Hello world!' } } gradle -q hello . $ gradle -q hello Hello world!5 - Internal Use Only - 6. Build Script Basics (2 / 6) Build scripts are code Groovy . build.gradle task upper Import > Gradle > Gradle Project . (/eclipse/workspace/gradle_sample) .22 - Internal Use Only - 23. Building Java Web Application with Gradle(10 / 12) Application https://github.com/OpenSourceConsulting/gradle_sample.git Run Gradle Build task . (eg. :clean, :test, :war)23 - Internal Use Only - 24. Building Java Web Application with Gradle(11 / 12) Test task test task build/test-results , build/reports/test .24 - Internal Use Only - 25. Building Java Web Application with Gradle(12 / 12) War task war task build/libs war .Clean task clean task build .25 - Internal Use Only - 26. OPEN SHARE CONTRIBUTE ADOPT REUSE 26 - Internal Use Only -