Need to capture activity of the UploadArchive and publish Gradle tasks

前端 未结 1 2025
野趣味
野趣味 2020-12-21 20:01

I have a scenario where I need to capture below details in the init.gradle file.

Can we get all the activity of task ?

the Inputs params for UploadArchive and

相关标签:
1条回答
  • 2020-12-21 20:26

    A task to list the same be made as below

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

    Sample output

    > 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
    
    0 讨论(0)
提交回复
热议问题