protected static void checkPattern(final String arg) throws IOException {
        var failBuild = new AtomicBoolean(false);
        var pattern = Pattern.compile("implementation\\s+(project.+)");
        var testPattern = Pattern.compile("testImplementation\\s+(project.+)");

        Files.walk(Paths.get(arg))
            .filter(file -> Files.isRegularFile(file) && "build.gradle".equals(file.toFile().getName()))
            .forEach(file -> {
                var text = readFile(file);
                var matcher = pattern.matcher(text);

                while (matcher.find()) {
                    var match = matcher.group(1);
                    var p2 = matcher.group().replace("(", "\\(").replace(")", "\\)");
                    if (Pattern.compile(p2).matcher(text).results().count() > 1) {
                        print("\tFound duplicated configuration for %s at %s", match, file);
                        failBuild.set(true);
                    }

                    var testImpl = "testImplementation " + match;
                    if (text.contains(testImpl)) {
                        print("\tFound duplicate test configuration for %s at %s", testImpl, file);
                        failBuild.set(true);
                    }
                }

                matcher = testPattern.matcher(text);
                while (matcher.find()) {
                    var p2 = matcher.group().replace("(", "\\(").replace(")", "\\)");
                    var compiled = Pattern.compile(p2);
                    if (compiled.matcher(text).results().count() > 1) {
                        print("\tFound duplicate test configuration for %s at %s", matcher.group(), file);
                        failBuild.set(true);
                    }
                }
            });
        if (failBuild.get()) {
            System.exit(1);
        }
    }
This is {@link CheckDuplicateGradleConfiguration}.

@author Misagh Moayyed
@since 7.1.0
ci/checks/CheckDuplicateGradleConfiguration.java