How to use uploadConfigurationName and buildConfig

2019-08-29 04:30发布

问题:

In gradle documentation we can read:

For each configuration in your project, Gradle provides the tasks uploadConfigurationName and buildConfigurationName [18].

As I understand I can create build which looks like this (without any plugin because I don't want to use plugins in this project):

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"
        }
    }
}

So if I run gradle buildProductSrc uploadProductSrc it will build zip and piblish it on ivy repository. Do I understand it correctly becouse it doesn't work?

[UPDATE] According to Peter Niederwieser answer this is a working version of build:

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"
        }
    }
}

回答1:

To get uploadConfigurationName and buildConfigurationName tasks, you'll have to apply the base plugin, or a plugin that in turn applies the base plugin (java, groovy, etc.). Alternatively, you can declare and configure such tasks yourself (but it takes more effort).



标签: groovy gradle