Removing jar from default Artifacts configuration

I’m creating my list of Artifacts, that I need to publish (all of them created by another build):

def zipFiles = ["name1.tar.gz", "name2.tar.gz"]
       zipFiles.each{ zipName ->
  def artifactName = zipName - '.tar.gz'
  archives new DefaultPublishArtifact(artifactName, "tar.gz", "tar.gz", null, new Date(),
     new File('softwares/dist', zipName))
configurations.archives.artifacts.each { println "ARTIFACT: ${it}"

I see that I have one artifact, that was added by default:

ARTIFACT: [ArchivePublishArtifact myProj:jar:jar:, DefaultPublishArtifact name1:tar.gz:tar.gz:null, DefaultPublishArtifact name2:tar.gz:tar.gz:null]

I’m trying remove the jar by following (base on

configurations.archives.artifacts.with { archives ->
  def jarArtifact = find { it.class.simpleName == "ArchivePublishArtifact" }
        println "JAR: ${jarArtifact}"

But nothing happened. What wrong with the ‘find’?

JAR: null

The solution:

configurations.archives.artifacts.with { archives ->
    def jarArtifact
 archives.each {
           if (it.file =~ 'jar') {
   jarArtifact = it
  println "JAR to delete: ${jarArtifact}"
1 Like