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${info.name}"(MavenPublication) {
                    artifactId "${extension.modelArtifactPrefix}${info.lower}"
                    artifact project.tasks."${info.lower}Jar"
                    artifact project.tasks."source${info.name}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 {
        it.name.endsWith('ToMavenLocal') || it.name.endsWith('ToSnapshotRepository')
    }
    deliverTask.group = '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 it.name.endsWith(‘ToSnapshotRepository’)

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