Adding a library to gradle ant classpath for use by custom task

I have a custom task in buildSrc

class MyTask extends DefaultTask {
      @TaskAction
    void runTask() {
       project.ant.taskdef(..., classpath: projects.configurations.myConfig.asPath)
    }
  }

This works if myConfig is a configuration on the project using the task, not on buildSrc. That makes sense.

Is there a way to only define this configuration once in build.gradle for buildSrc and make it available to the projects using this task? Or do I need to define it for all of the projects that use this task?

‘buildSrc’ is a totally separate/isolated build, so a configuration on ‘buildSrc’ won’t do. What might work is to declare the Ant task as a ‘runtime’ dependency in ‘buildSrc/build.gradle’, rather than setting a classpath in ‘ant.taskdef’.

Doesn’t look like that worked. Thanks for the suggestion though.

Worst case is I put all of that configuration into its own gradle file and then just apply it in the subprojects block, not too bad.