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
Have you tried ‘ant.properties.baseDir=…’ before importing the build?
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
Another try is ‘ant.project.baseDir = …’ after the import. Does that help?
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
Is there a way for changing the general working directory (regardless to ant)?
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.
http://issues.gradle.org/browse/GRADLE-2039 describes this problem and suggests a workaround.
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