diFirst, doLast, do in the middle?


(Maksim Kostromin) #1

Hello,

to pass into gradle task some configurations we usually doing something like:

  distZip {
    from project(':docs').asciidoctor, {
      into "$project.name"
    }
  }

  distTar {
    from project(':docs').asciidoctor, {
      into "$project.name"
    }
  }

but how can I apply DRY principle here? I mean, this:

  [distZip, distTar].each {
    it.apply {
      from project(':docs').asciidoctor, {
        into "$project.name"
      }
    }
  }

or that:

  [distZip, distTar].each { distTask ->
    distTask.from project(':docs').asciidoctor, {
      distTask.into "$project.name"
    }
  }

Regards,
Maksim


(Maksim Kostromin) #2

my apology,

this is working as expected:

  [distZip, distTar].each { distTask ->
    distTask.from project(':docs').asciidoctor, {
      distTask.into "$project.name"
    }
  }

I just had some typo with my tryings: distTaks -> distTask


Regards,
Maksim