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

Continuing the discussion from Adding a library to gradle ant classpath for use by custom task:

I finally found a satisfying solution to this problem: http://stackoverflow.com/a/34992684/589329