Cannot create task of type 'Exec'


(Zsolt Kúti) #1

Hello,

I try to run this simple task in 1.0-milestone-7:

task createCert(type:Exec) {
   executable 'keytool'
}

and get an error: “Cannot create task of type ‘Exec’ as it does not implement the Task interface”

I do not understand how this simple thing can fail and what to do with it?

Thanks Zsolt


(Zsolt Kúti) #2

In the meantime, the following worked:

task createCert2 {

def res = exec {

ignoreExitValue = true

executable = ‘keytool’

println "Exit value: " + res; }

but I am still curious…

A follow-up question. If the execution waits for some input, how can one provide with data?

Thanks!


(Zsolt Kúti) #3

Chating with myself :slight_smile:

In this special case there is an option of ‘-noprompt’ that avoids the immediate need, but I am still interested.

Thanks!


(René Groeschke) #4

Hello, your original snippet works just fine for me with milestone-7. are you sure you haven’t any typos there? To provide the Exec task with input during your key tool is executed, you can redirect the standard input/output using the standardInput and standardOutput property of Exec. The DSL reference of Exec has the details: http://gradle.org/docs/current/dsl/org.gradle.api.tasks.Exec.html

regards, René


(Zsolt Kúti) #5

Hello Rene,

I have just tried again with the same result. Then put the task alone in a file, it worked. Then checked the whole build script and recognized a change my IDE made unnoticed: it imported an ant Exec tag.

I missed that part of the DSL, thanks for calling my attention to it.

Zsolt