Skipping task as it has no source files and no previous output files

3.2k views Asked by At

This is my build.gradle which has three tasks (one for downloading the zip, one for unzipping it and other for executing the sh file). These tasks are dependent on each other. I am using Gradle 6. As these are dependent tasks I have used following command:

gradlew C

I get the error:

Skipping task 'B' as it has no source files and no previous output files.

build.gradle:

task A {
    description = 'Rolls out new changes'
    doLast {
        def url = "https://${serverName}/xxx/try.zip"
        def copiedZip = 'build/newdeploy/try.zip'
        logger.lifecycle("Downloading $url...")
        file('build/newdeploy').mkdirs()
        ant.get(src: url, dest: copiedZip, verbose: true)
    }
}
          
task B (type: Copy, dependsOn: 'A') {
    doLast {
        def zipFile = file('build/newdeploy/try.zip') 
        def outputDir = file("build/newdeploy")
        from zipTree(zipFile)
        into outputDir
    }
}

task C (type: Exec, dependsOn: 'B') {
    doLast {
       workingDir 'build/newdeploy/try/bin'
       executable 'sh'
       args arguments, url
       ext.output = { return standardOutput.toString() }                        
    }
}
1

There are 1 answers

0
PeaceIsPearl On BEST ANSWER

I tried following and it worked. Rather than adding a separate task to copy, added the copy function in the task A itself

task A {
    description = 'Rolls out new changes'
    doLast {
        def url = "https://${serverName}/xxx/try.zip"
        def copiedZip = 'build/newdeploy/try.zip'
        logger.lifecycle("Downloading $url...")
        file('build/newdeploy').mkdirs()
        ant.get(src: url, dest: copiedZip, verbose: true)
        def outputDir = file("build/newdeploy")
        copy {
          from zipTree(zipFile)
          into outputDir
        }
    }
}

task C (type: Exec, dependsOn: 'A') {
    doLast {
       workingDir 'build/newdeploy/try/bin'
       executable 'sh'
       args arguments, url
       ext.output = { return standardOutput.toString() }                        
    }
}