需要捕获 activity 个 UploadArchive 并发布 Gradle 个任务

Need to capture activity of the UploadArchive and publish Gradle tasks

我有一个场景需要在 init.gradle 文件中捕获以下详细信息。

我们能得到任务的所有activity吗?

UploadArchive 和发布任务的输入参数,哪个 repo 是正在上传的工件,所有 GAV 详细信息……因为 POM 可以在 uploadArchive 任​​务中自定义。

我们有应用 运行 v3.5 到 v6.3 版本 Gradle。

你能帮忙吗

嗨@PrasadU

我们能否确定 url、uploadArchive 任​​务将在运行时选择哪个部署。

uploadArchive {
    repositories {
       mavenDeployer {
            repository(url: ReleaseURL) {
                authentication(userName: Username, password: Password)
            }
            snapshotRepository(url: SnapshotURL ) {
                authentication(userName: Username, password: Password)
            }
        }
    }
}

列出相同任务如下

publishing {
    publications {
        maven(MavenPublication) {
            groupId = 'abc.xyz'
            artifactId = 'overr-name'
            version = '1.1-OV'

            from components.java
        }
    }
    repositories {
        maven {
            url = uri("$buildDir/repos/releases")
        }
        maven {
            url = uri("$buildDir/repos/snaps")
        }
    }
}

task printML() {
    doLast {
        tasks.findAll {task ->
            if (task.name.matches("publish.*PublicationToMavenLocal")) {
                def publication = task.publicationInternal
                println("Local => $publication.artifactId $publication.groupId $publication.version")
            }
            if (task.name.matches("publish.*PublicationTo.*Repository")) {
                def publication = task.publicationInternal
                println("Remote => $publication.artifactId $publication.groupId $publication.version  $task.repository.url")
            }
        }
    }
}

示例输出

> Task :printML
Remote => overr-name abc.xyz 1.1-OV  file:/Users/projects/Store/combined-samples/build/repos/snaps
Local => overr-name abc.xyz 1.1-OV
Remote => overr-name abc.xyz 1.1-OV  file:/Users/projects/Store/combined-samples/build/repos/releases