Archives configuration


I am getting below error when I am adding the archive for the zip file task I have created
Could not find method archives() for arguments [task ‘:task1’] on object of type org.gradle.api.internal.artifacts.dsl.DefaultArtifactHandler

Here is my build.gradle where I am generating zip files dynamically.

def source = [“task1”,“task2”]
task myZip(){


task "$taskName"(type: Zip) {
println "task name : ${taskName}"
    from "build/libs/"+taskName
    destinationDir file('build/libs/')
    archiveName "${taskName}.zip"
myZip.dependsOn taskName

	artifacts {
	 archives taskName