Skip to content

Instantly share code, notes, and snippets.

@tuxdna
Last active May 28, 2018 12:27
Show Gist options
  • Save tuxdna/dd6cb3616cd31a482cc25a1c2f6940fd to your computer and use it in GitHub Desktop.
Save tuxdna/dd6cb3616cd31a482cc25a1c2f6940fd to your computer and use it in GitHub Desktop.
Learn gradle

Groovy

//System.out.println("Hello World!")
//println("Hello World!")
//
//println "Hello World!"
//

class MyClass {
    void doSomething(Closure closure) {
        closure.call()
    }
}

myObject = new MyClass()

myObject.doSomething {
    println new Date()
}

Gradle Command Reference

gradle compileJava
gradle compileScala
gradle projects
gradle --status
gradle build
gradle properties
gradle dependencies --configuration testCompile
gradle htmlDependencyReport
gradle dependencies



gradle tasks


gradle tasks --all

Gradle tasks

task showDateOld {
    dependsOn build
    group = 'my tasks'
    description = "Show current date"
    doLast {
        println ""
        println "Current Date: " + new Date()
        println ""
    }
}


class ShowDate extends DefaultTask {
String dateMessage = "Date is: "
    @TaskAction
    void showDate() {

        println ""
        println dateMessage + new Date()
        println ""
    }

}

task showDate(type: ShowDate)

task customShowDate(type: ShowDate) {
    dateMessage = "Custom date is: "
}

Gradle Plugin

buildscript {
    dependencies {
        classpath files("show-date/build/libs/show-date-1.0-SNAPSHOT.jar")
    }
}

apply plugin: "show-date-plugin"

Gradle Profile

gradle build --profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment