Handling duplicate project names in a workspace

I came across this bug report and the solution for it. However, me being new to gradle, i couldn’t figure it out that where i need to write below script. Can anyone please help.

if (project != rootProject) {
  eclipse.project.name = (rootProject.name + project.path).replaceAll(':', '-')
}

This is an old recommendation, which goes to the allprojects {} block in the root project. You’d write something like this:

allprojects {
    if (project != rootProject) {
        apply plugin: 'eclipse'
        eclipse.project.name = (rootProject.name + project.path).replaceAll(':', '-')
    }
}

But using allprojects is discouraged now. Use precomiled script plugins instead.