Skip to content

Latest commit

 

History

History
executable file
·
68 lines (58 loc) · 1.69 KB

gradle-cheat-sheet.md

File metadata and controls

executable file
·
68 lines (58 loc) · 1.69 KB

Gradle cheat sheet

setup

DEST_FOLDER=$HOME_SOFT/gradle/bash_completion
mkdir -p $DEST_FOLDER
curl -LA gradle-completion https://edub.me/gradle-completion-bash -o $DEST_FOLDER/gradle-completion.bash

echo 'source $HOME_SOFT/gradle/bash_completion/gradle-completion.bash' >> ~/.bashrc

gradle commands

print all dependencies for project, dependency tree

gradlew dependencies

download dependencies to separate folder

task downloadDependenciesToRuntime(type: Copy) {
    from sourceSets.main.runtimeClasspath
    into 'runtime/'
}

execute gradle with specific build.gradle file

gradlew.bat -b migration-job/build.gradle build

quite output, output without messages

gradlew.bat -q build

gradle debug

https://docs.gradle.org/current/userguide/build_environment.html gradle -Dorg.gradle.debug=true --no-daemon clean

skip tests

gradlew build -x test gradlew test --test "com.example.android.testing.blueprint.unit.integrationTests.*"

execute single test

gradlew test -Dtest.single=< wildcard of test > build

custom task, run script

init groovy project

gradle init --groovy-application
gradle init --type java-library
  • java-application
  • java-library
  • scala-library
  • groovy-library
  • basic

execute groovy script

add into build.gradle

task runScript (dependsOn: 'classes', type: JavaExec) {
    main = 'App'
    classpath = sourceSets.main.runtimeClasspath
}

execute script

gradle runtScript

proxy settings

gradle build -Dhttp.proxyHost=proxy-host -Dhttp.proxyPort=8080 -Dhttp.proxyUser=q4577777 -Dhttp.proxyPassword=my-password