Gradle

In NixOS, nix-shell -p gradle is enough.

A gradle script handle two things:

  • projects

  • tasks

gradle -q hello :

// build.gradle

task hello {
   doLast {
      println "tutorialspoint [${project}]"
      println "[${path}]"
      println "[${projectDir}]"
      println "[${buildDir}]"
   }
}

task upper {
   doLast {
       String expString = 'TUTORIALS point'
       println "Original: " + expString
       println "Upper case: " + expString.toUpperCase()
   }
}

// Take note it is plural tasks
tasks.create(name: 'abc') {
    doLast {
        println("*** abc ***")
    }
}

Task phases:

  • configuration phase

  • execution phase (doFirst, doLast)

---------------------------------------------------------------------------------------------------------------

Sample ok build.gradle :

Without any java source file, gradle build won't download the jars.

How to reference a local jar within build.gradle:

To create gradle wrapper:

gradle wrapper --gradle-version 5.6.1

These two are the same:

Gradle File API

Control Name of Jar in Gradle

In build.gradle

But you have to invoke the task manually such as: gradle buildjar for the task to run.

Know, that this can also be controlled in settings.gradle as:

Last updated

Was this helpful?