Set Ant property from Gradle not working

I will convert our assembly from Ant to Gradle. Our first step is to add Gradle build files, so we can start using Gradle as our build tool. This allows us to use our existing build scripts to create with Ant and convert them to Gradle over time. I want to just Gradle invoke existing Ant build files. Our projects are all NetBeans projects that have build.xml and nbproject / build-impl.xml files. Some projects require NetBeans build properties, which can be found in ~ / .netbeans / 6.5.1 / build.properties. I currently have build.gradle that contains only this:

ant.importBuild 'build.xml' 

I can build a project using Ant as follows:

 ant -Duser.properties.file=/home/me/.netbeans/6.5.1/build.properties dist 

However, when I create using Gradle, Ant complains that it cannot find the properties set in build.properties. I tried to set the Ant property, but it does not seem to be picked up:

 ant.properties['user.properties.file'] = '/home/me/.netbeans/6.5/build.properties' 

I also tried to set the system property:

 systemProperties 'user.properties.file': '/home/me/.netbeans/6.5/build.properties' 

but it doesn’t work either. Ideally, I would like to set this property to ~ / .gradle / gradle.properties, since all our projects need it.

How to set this property in Gradle and Ant select it when called from Gradle?

+4
source share
1 answer

If you want to set property loading in multiple Gradle projects, you can use the Gradle init script, http://www.gradle.org/docs/current/userguide/init_scripts.html . Inside the init script you should put this code:

 allProjects { ant.properties['user.properties.file'] = '/home/me/.netbeans/6.5/build.properties' } 
0
source

All Articles