title: Gradle - Dynamically building multiple publishes
body: <p>I have come on to a project which has a Gradle script that builds tasks dynamically based on a list. This is so that when people fork the repository, they can just edit the list. It boils down to something like this:</p>
  
  <pre><code>def files = ['file1', 'file2', 'file3']
  
  files.each { f -&gt;
      task (f, type: Exec) {
          executable 'touch'
          args file
      }
  }
  </code></pre>
  
  <p>What I would like to do is to be able to publish the outputs of the tasks. I ideally want to do this as multiple publishes. I gave it a stab with the below code snippet, but Gradle seems to really hate the fact that I'm using a <code>java.lang.String.call()</code> as a class name!</p>
  
  <pre><code>publishing {
      publications {
          files.each { f -&gt;
              f (IvyPublication) {
                  module f
                  artifact (file(f))
              }
          }
      }
  }
  </code></pre>
  
  <p>Is what I am trying to do possible, or should I completely change tack?</p>
  
  <p>[edit] I <em>think</em> I can do this with <code>IvyPublication.loadClass(f)</code>, but struggling with the details. Any help much appreciated</p>