Calling external ant from gradle

(rajesh.eq) #1

I want to call an external ant script from gradle build. But I am getting

org.gradle.process.internal.ExecException: A problem occurred starting process 'command ‘ant’.

Caused by: Cannot run program “ant” (in directory “C:\Users\rajesh\eclipseworkspace\Sample7”): CreateProcess error=2, The system cannot find the file specified

at java.lang.ProcessBuilder.start(

Though I am able to execute the same ant command outside gradle from a commandline.

task printHello(type: Exec){

executable “ant”

args “build.xml”

workingDir projectDir }

build.xml just contains echo hello world message.

(Peter Niederwieser) #2

If this is Windows, try:

executable "cmd"
args "\c", "ant.bat", "build.xml"

(rajesh.eq) #3

With above code I just got the output below. ant build.xml is not at all called

Microsoft Windows [Version 6.1.7601] Copyright © 2009 Microsoft Corporation. All rights reserved.