Sidharth Sidharth - 1 month ago 5
Groovy Question

How to get the path in build.gradle

I am working on build.gradle in a project directory. i want to know how can I get the path of the directory with one folder back in gradle task

task myTask << {
println file('.')
println projectDir}


This would return me the path which say is
c:\a\b\c
which is current directory

but i want to go to the path
c:\a\b

Answer
task currentDir << {
    println file('.')
    println projectDir
}

task previousDir << {
    println file('..')
    println file("$projectDir/..")
}
Comments