Hello folks! I'm building a static analysis tool f...
# plugin-development
Hello folks! I'm building a static analysis tool for automatic vulnerability discovery and I'm trying to use the Gradle API to copy all the Gradle dependencies of a project into a specific folder so they can be used for type resolution. I've managed to establish a connection using the GradleConnector class, and I can trigger Gradle tasks automatically, but I'm a bit stuck trying to define a task programatically. It seems the Project class exposes the
method which could be used for this purpose, but unfortunately I only have a GradleProject class and it doesn't seem staightforward to translate between the two. I've also tried instantiating a Copy task directly, but that fails on an NPE around logging, and using the TaskFactory class doesn't seem to work either, except in the context of a test suite. Can anyone point me in the right direction? I'd appreciate any hint or pointers to errors in my thinking
IIRC, the way InteliJ IDEA does it when you want to run a Java class, is to use an init-script that will register the task.
That said, I think you could resolve any configuration and get its files (stored in the
) and then do the copying on your side, rather than injecting a task into the build.
Interesting, thank you, I'll try that approach as well
I wrote a plugin for this and already shared a gist elsewhere in this slack, feel free to borrow or steal https://gist.github.com/autonomousapps/f0133e58a612b6837f3f4f6554337035
Still trying to do this from a non-plugin context in which Project is not available (only GradleProject), but should that not work, your gist looks exactly like what I need. Much appreciated
👍 1