Need a plugin implementation to access other project artifacts

I am new to gradle & needed help in below.
Right now i have Gradle plugin in java which download all the dependencies of a specified module into the required project(This module can be another component)
However i need a way to access all the dependent modules artifacts as well.Is there a way to do.

Lets Say we have component X and component Y
Currently how we download the dependencies of component X into Component Y lib folder is like below

def moduleTask = project.tasks.register(“deploy_$moduleName”, Sync, new Action(){
void execute(Sync copyTask) {

                copyTask.dependsOn project.configurations[moduleName]
                copyTask.from  project.configurations[moduleName]
                copyTask.into "${project.extensions.getByName("ext").viewRoot}/$moduleName/lib"

Is there a way that i can downlaod component X artifacts also instead of dependencies.