Question about properties

I have a task that prints out the classpath for my project. I tried using to print out the values of some properties, but I am not having any success with that part.

task printClassPath() {
     println( "-- Groovy version: " + groovy.lang.GroovySystem.getVersion() )
     dependsOn classes
     description = 'this prints out the class path'
       println("Printed the path")
     runtimeClasspath.getAsPath().tokenize(":").each { theFile ->
        println theFile
     }
     println "\n"
     // println "destinationDir: " + destinationDir
     // println "output.classesDir: " + output.classesDir.getPath()
     println "reportsDirName: " + reportsDirName
}

If I am reading http://www.gradle.org/docs/current/userguide/java_plugin.html, runtimeClasspath, destinationDir, output.classesDir and reportsDirName are properties defined by the Java plugin. But I can only access runtimeClasspath and reportsDirName. When I try to access the other two, I get: > Could not find property ‘destinationDir’ on task ‘:printClassPath’.

I should probably end with an explicit question: Why can’t I print out the values of destinationDir and output.classesDir? I know they are java.io.File objects, but even when I call a method on File that returns a string I still get the error.

Hi Eric

You need to pay attention to what the properties are defined on - The project? a sourceset? a task?

cheers Perryn

I think I got what I wanted:

println "output.classesDir: " + sourceSets.main.output.classesDir.getPath()