1

For example I've got two closures in subprojects configuration (for example task1 - task2)

subprojects { 
    task1 {
        config 1
        config 2
    }
    task2 {
        config 1
        config 2
    }
}

How to apply same configuration for both tasks at once?

I was trying to do something like:

task1, task2 { 
    config 1
    config 2
}

or:

task2 {
    task1
}

However it does not work. How to do it correct if it's possible?

Opal
  • 81,889
  • 28
  • 189
  • 210
lapots
  • 12,553
  • 32
  • 121
  • 242

1 Answers1

2

Please try:

[task1, task2].each { t ->
   configure(t) {
      config1
      config2
   }
}
Opal
  • 81,889
  • 28
  • 189
  • 210
  • @Opal , how can I add this code ? ---for idea and eclipse>>>>>> idea, eclipse { module { excludeDirs -= file("$buildDir/") sourceDirs += file(generatedSrcDir) } } – smilyface Oct 09 '15 at 06:46
  • @smilyface, sorry don't understand. Maybe just add a new question? – Opal Oct 09 '15 at 06:50
  • @Opal , Here it is http://stackoverflow.com/questions/33031863/gradle-how-to-combine-same-code-of-different-tasks – smilyface Oct 09 '15 at 07:00