4

I'm converting our build from Ant to Gradle. Our first step is to add the Gradle build files so we can start using Gradle as our build tool. This lets us use our existing build scripts to build using Ant and convert them to Gradle over time. I want to simply have Gradle call the existing Ant build files. Our projects are all NetBeans projects, which have build.xml and nbproject/build-impl.xml files. Some of the projects require NetBeans build properties, which can be found at ~/.netbeans/6.5.1/build.properties. I currently have build.gradle which contains only this:

ant.importBuild 'build.xml'

I can build the project using Ant like this:

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

However, when I build with Gradle, Ant complains it cannot find the properties set in build.properties. I've tried setting the Ant property, but it doesn't seem to get picked up:

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

I've also tried setting a system property:

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

but this doesn't work either. Ideally I'd like to set this property in ~/.gradle/gradle.properties as just about all of our projects need it.

How can I set this property in Gradle and have Ant pick it up when called from Gradle?

4

1 回答 1

0

如果要在多个 Gradle 项目上设置加载属性,可以使用 Gradle 初始化脚本http://www.gradle.org/docs/current/userguide/init_scripts.html。在初始化脚本中,您将放置以下代码:

allProjects {
    ant.properties['user.properties.file'] = '/home/me/.netbeans/6.5/build.properties'
}
于 2013-06-16T07:38:20.703 回答