Is it possible to add random print statements to g...
# gradle
n
Is it possible to add random print statements to gradle tasks?
Copy code
tasks {
    jar {
        archiveName = "onboarding.jar"
        println("Hello world")
        }
    }
}
This compiles just fine, but doesn’t print for me, so I assume not.
c
As written this
println
will be executed during jar task configuration. Unless jar is actually configured by gradle,
println
won't be executed.
If you expect it to be executed during jar execution as opposed to configuration, you need to write it differently
n
Copy code
tasks.register("hello") {
    group = "build"
    doFirst {
        val runtimes = configurations.runtimeClasspath.get().joinToString(" ") { it.name }
        println("Runtimes: $runtimes")

        val compiles = configurations.compile.get().joinToString(" ") { it.name }
        println("Compiles: $compiles")
    }
}
i added group to “build” but when the build group is run, nothing prints. is that expected?
c
yes, adding "hello" to group "build" does just that, now "hello" is in group "build", has nothing to do with executing the task.
If you run
./gradlew hello
then it will print