Deploy with maven-publish using your own task instead of auto-generated

(Vladimir) #1

Want to create my own task, that would deploy artifacts to specific(release or snapshot) repo using maven-publish.

Problem is there are two repos - release and snapshot.
Maven-publish create automatically tasks for each repos,

I have did this way:

project.publishing {
        publications {
            labels.each { info ->
                "model${}"(MavenPublication) {
                    artifactId "${extension.modelArtifactPrefix}${info.lower}"
                    artifact project.tasks."${info.lower}Jar"
                    artifact project.tasks."source${}Jar"

        repositories {
            maven { name "release"; auth 'release-local'; url extension.releaseRepository }
            maven { name "snapshot"; auth 'snapshot-local'; url extension.snapshotRepository }

and here is my custom task

def deliverTask = project.task('modelDeliver')
    deliverTask.dependsOn project.tasks.matching {'ToMavenLocal') ||'ToSnapshotRepository')
    } = 'Model release'
    deliverTask.description = 'Build new version of model and put it to maven'

The problem is at that moment when my custom task “modelDeliver” is creating - there is no any tasks that match condition‘ToSnapshotRepository’)

Any suggestions how to initiate deploying to snapshot repo by my own task?