DEV Community

Query Filter
Query Filter

Posted on

docker18

task buildAnsibleTar(type: Tar) {
    archiveFileName = "ansible.tar.gz"
    destinationDirectory = file("$buildDir/distributions")
    compression = Compression.GZIP

    from(tasks.named('buildRpm'))
    from("${projectDir}/ansible") {
        into('ansible')
    }

    doLast {
        println "------------------------------------------------------------"
        println "VERIFYING ARCHIVE CONTENT (Cross-Platform):"

        File tarFile = archiveFile.get().asFile
        if (tarFile.exists()) {
            // tarTree allows Gradle to peek inside the archive using Java
            // This works on Windows and Linux equally well
            project.tarTree(tarFile).each { File internalFile ->
                // We calculate the path relative to the archive root to see the hierarchy
                // Note: tarTree flattens during iteration, so we show the name
                println " - Found in Tar: ${internalFile.name}"
            }
        } else {
            println "ERROR: Archive not found!"
        }
        println "------------------------------------------------------------"
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)