How to lower the priority of jar files in project dependencies in build.gradle.

Gradle Version: 6.7.1

I’m trying to resolve a dependency with gradle in my project. But I am facing a problem.

The foo project depends on the bar project as shown below.

dependencies {
    implementation project(':bar')
}

/foo/build.gradle

/bar/lib/sample.jar(Contains SameName.java)
/bar/src/SameName.java

There is a jar file in this bar project. the names of src/SameName.java and SameName.java contained in the jar file are duplicated. When I try to build the whole project, the foo project references SameName.java in the jar file.

I want to refer to src/SameName.java. Not SameName.java in the jar file Is there any solution to this problem?