Gradle build issues after upgrade from gradle 2 version to gradle 4 version

when i was using Gradle 2 + version builds are good. But, recently we are upgrading version to 4+ getting below error.

> No such property: archiveTask for class: org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact

Our build.gradle is having below block and giving error on that for new version.

Could any one suggest here.

tasks.distTar.enabled = false

configurations.archives.with {
artifacts.remove artifacts.find { it.archiveTask.is distTar }
artifacts.remove artifacts.find { it.archiveTask.is jar }
}

This is written to remove tar and jar from upload.

We use the following statement to remove all JAR artifacts:

configurations.archives.artifacts.removeAll { it.type == 'jar' }

Thank you “MartijnDwars” for reply.
Yes, I have used following statement to fix the issue.

configurations.archives.with {
artifacts.remove artifacts.find { it.file =~ ‘tar’ }
artifacts.remove artifacts.find { it.file =~ ‘jar’ }

}