我正在将maven build迁移到gradle,我正在努力在根项目中定义基本的插件配置.并在子模块中提供特定的配置属性.
这是一个例子:
root:build.gradle
configure(filterSubprojects(['component'])) { apply plugin: "org.flywaydb.flyway" flyway { url = "jdbc:oracle:thin:@${db.host}:${db.port}:${db.name}" user = db.owner.name password = db.owner.password } }
specific-subproject-component:build.gradle
ext { db = [ host :, port : , name : , user : [name: , password: ] ] }
我收到这个错误:
Cannot get property 'db' on extra properties extension as it does not exist
可能是非常基本的问题,但我无法弄清楚如何做到这一点.
这里的问题是,在评估root build.gradle文件时,尚未评估特定组件build.gradle文件,因此当configure块运行时db确实不存在.要解决此问题,您应该能够evaluationDependsOnChildren()
在root build.gradle文件中声明.