How to execute a command from a tar-filer dependency?

Hi,
I have a dependecy to a tar.gz file that I unpack into a folder using a copy task.
The I want to run a program in the unpacked folder via an exec task:

The tar.gz file has a topfolder that I basically does not know the name of.
I.e. it has the structure ‘unknownFolder/theFiles’.

Basically it looks like:

configurations {
myConf
}
dependencies {
myConf (group: ‘org’,name: ‘module’, version: ‘1.0’, ext: ‘tar.gz’)
}

ext {
myDir = “someDir”
}

task unpack (type: Copy) {
configurations.myConft.asFileTree.each {
from tarTree(it)
}
into “${myDir}”
}

task runCommand(type: Exec, dependsOn: ‘unpack’){
def rootDir = new File("${myDir}").listFiles()[0] // <-- this line fails
def destDir = new File("${buildDir}/myModule")
destDir.mkdirs()

workingDir destDir
executable rootDir + “/myCommand” // <-- this line fails
args ‘arg1’, 'arg’2
}

I tried to get the name of the unknown folder by using ‘file(unpack).files’, but without success.
I guess that there reason I do not get hold of ’ def rootDir = new File("${myDir}").listFiles()[0]’ is because the line is in the configure part and the copy task action has not bee performed at that stage.

But how can I set the executable property of the Exec task during the configuration phase when I do not know the exact path to the executable?

Hmm…

You could always set the executable property during a doFirst block.
I can’t immediately think of an easy way to do what you’re doing though.