Gradle and Spring-bootRun can not find my class

As far as I could understand from the question we are dealing with a multiple project scenario. In this case the multi project builds documentation tells us that it is necessary to have a settings.gradle in the folder that contains the two projects:

enter image description here

then it is possible to run both the projects without cd change directory into the specific folder , but directly from the multi-project root by command: gradle advanced:bootRun

enter image description here

EDIT according to 20200610 EDIT of the question acknowledging the specification: commits can only be made to the Advanced project.

we can still get a solution but in this scenario ( actually not a gradle multi-project)

  • no need to have a settings.gradle at the parent directory level of Advanced; it satisfy the requirement of not being able to commit outside of Advanced

  • it doesn't matter how it's built the Classic project, we don't care about it since we can't commit on it

  • we can't use in Advanced/build.gradle the implementation project(':classic') as dependency since this works only in real gradle multi-project scenarios ; in here we must use a file dependency or another type of dependecy available for the user's development environment.

enter image description here

In this case it is possible to run the Advanced project by cd Advanced then , from the Advanced directory run th command: gradle bootRun

Limited-commit-to-advanced

why it works ?

..In order to better understand how it works lets's inspect the SystemClassLoader's current paths by adding this lines of code in Advanced/src/main/java/com/example/springboot/Application.java

ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for(URL url: urls){
    System.out.println(url.getFile());
}

the output is:

<multi-project-root>/Advanced/build/classes/java/main/
<multi-project-root>/Advanced/build/resources/main/
<multi-project-root>/Classic/build/libs/Classic-0.0.1-SNAPSHOT.jar
~/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring
... [suppressed many othe spring devtools and gradle related caches  ]

this allow both the Advanced and the Classic classes to find each others

source code of a proof of concempt

The POC source-code new branch has been updated accordingly


What you need is Gradle's composite build. See my POC project. The advanced project includes the classic project by this line

The advanced/App.java calls classic.App.main, And the classic.App class can load foo.Bar from the advanced project. No need to do a commit to classic project.

Execute "gradlew run" in the advanced folder

to see how it works.