How to define working directory for ant task


(Ramy Ben Aroya) #1

Hello,

I have to wrap some ant scripts, which I can’t change and are not in the same directory as my build.gradle file. These ant files’ baseDir is set to ‘.’

This is my build.gradle :

ant.importBuild '/tools/build/build.xml'
    task buildMyAnt(dependsOn: build) << {
    }

When I run “gradle buildMyAnt” it fails due to path issues.

However when I copy the gradle.build to /tools/build/ , it passes.

So I guess I need to change the working directory for buildMyAnt task

Is there a way to set gradle ant task working directory?

Thank you,

Ramy


(Peter Niederwieser) #2

Have you tried ‘ant.properties.baseDir=…’ before importing the build?


(Ramy Ben Aroya) #3

Tried it. it fails too.

there isn’t such property as ${baseDir} in my ant scripts. It’s an attribute in the build.xml tag


(Peter Niederwieser) #4

Another try is ‘ant.project.baseDir = …’ after the import. Does that help?


(Ramy Ben Aroya) #5

No. I tried both: ant.project.baseDir=‘tools/build/’

(failed beacuse was expecting File type) ant.project.baseDir=new File(‘tools/build/’)

btw thanks for your effort :slight_smile:


(Ramy Ben Aroya) #6

Is there a way for changing the general working directory (regardless to ant)?


(Peter Niederwieser) #7

You are right, I can’t make it work either. The Ant import sets the base dir to the directory which contains the Ant build file, and I can’t see a way to change this. Looks like something that needs fixing. I’ve heard this problem mentioned before, so maybe a forum/web search will turn up something.


(Peter Niederwieser) #8

http://issues.gradle.org/browse/GRADLE-2039 describes this problem and suggests a workaround.


(Ramy Ben Aroya) #9

I found out what was my real problem. One of my ant scripts had a java task in it. The working directory of the java task is by default the ‘build.gradle’ file base dir. So I have no choice but to specify the java task with a working directory and fork it so it wil use another JVM.

Thanks for the link and your help