How to reference to a task in a plugin in the Gradle script (project.tasks.task1 ?)

I am using a plugin with a task, called, say ‘task1’. How do I reference to task1 in the Gradle script (project.tasks.task1 ??)

In the code below, build task of java plugin is referenced inside a custom gradle task

//Custom Task task ci(dependsOn: [‘clean’, ‘build’, ‘uploadArchives’]) //build is the java plugin task being referenced to be run after clean. build.mustRunAfter clean

OR

def taskCi = project.tasks.findByPath(‘ci’); println ‘printing’+taskCi