Getting list of artifacts/ filter artifacts inside the gradle plugin task

I am writing a standalone Gradle plugin for some static analysis of JVM byte codes. Similar functionality exists in another maven plugin. In the maven plugin, we have the function that returns artifacts list like this:

Set<Artifact> artifacts = getResolvedDependencies(false);
            for (Artifact a : artifacts) {
                String file = a.getFile().getPath();

getResolvedDependencies() function comes from the abstract class AbstractDependencyFilterMojo of maven.plugin.dependency. * package.

I need to add a similar function as the above in my Gradle plugin. How to retrieve the artifact list with Gradle?