在自定义gradle插件闭包中使用项目属性

时间:2019-01-31 17:01:42

标签: gradle build.gradle gradle-plugin

我有一个需要插件的build.gradle文件。该插件需要配置。我正在尝试从build.gradle文件中引用属性,但无法使该属性成功传递。

定义变量:

def registryUrl
buildscript {
    ext {
        registryUrl = findProperty("schemaRegistryUrl")
        println ("Setting url $registryUrl")
    }
}

插件配置:

schemaRegistry {
    url = "$registryUrl"
    avroPath = 'src/main/avro'
    schemaDirectory = 'schemas'
    commonsDirectory = 'commons'
    outputDirectory = "out/avro"
}

任务被调用

task cleanGenBuildPublish(type: GradleBuild) {
    tasks = ['clean',
             'registerSchemasTask', 
             'compileJava', 
             'generateAvroJava', 
             'artifactoryPublish']
}

命令行

 ./gradlew -PschemaRegistryUrl="http://localhost:8081" cleanGenBuildPublish --stacktrace

> Configure project :
Setting url http://localhost:8081
Cannot publish pom for project ':' since it does not contain the Maven plugin install task and task ':artifactoryPublish' does not specify a custom pom path.

> Configure project :domain-event-catalog
Setting url null

但是从插件内部我得到

java.net.MalformedURLException: no protocol: null/subjects/order.OrderCancelledEvent/versions

0 个答案:

没有答案