在 gradle文档中,我们可以阅读:
对于项目中的每个配置,Gradle 提供了任务uploadConfigurationName和buildConfigurationName [18]。
据我了解,我可以创建看起来像这样的构建(没有任何插件,因为我不想在这个项目中使用插件):
configurations {
productSrc
}
// create zip file which will be published
buildProductSrc(type: Copy) << {
// do the job
}
// publish zip which were build by buildProductSrc
uploadProductSrc {
repositories {
ivy {
url "http://ivy.repo/repo"
}
}
}
因此,如果我运行gradle buildProductSrc uploadProductSrc
它,它将构建 zip 并在 ivy 存储库上进行 piblish。我是否正确理解它,因为它不起作用?
[更新] 根据 Peter Niederwieser 的回答,这是构建的工作版本:
apply plugin: 'base'
configurations {
productSrc
}
// create zip file which will be published
buildProductSrc << { // unable to create specific task, for example 'type: Copy'
// do the job
}
// publish zip which were build by buildProductSrc
uploadProductSrc {
repositories {
ivy {
url "http://ivy.repo/repo"
}
}
}