I used plugin { java } and implementation and probably this automatically marks the folders, where the generated code lies, as source sets.
No, afair the Proto plugin you use correctly marks the generated sources as sources of the main source set.
But here, AI told me to use plugin { ´java-library´ } and dependencies { api(libs.protobuf.java) }
If it is to be consumed by other projects, java-library is more appropriate than java, yes.
java is more for “end projects”, java-library is for libraries which also means projects consumed only by other projects in the same build, not necessarily that it gets published separately somewhere.
api vs. implementation is about how the dependencies are used.
You did not say what classes were not found.
It sounded like your generated sources were not found, but if that helped, then most probably the proto classes were not found. If you would have mentioned that or had shown an MCVE, the problem would have been obvious to me. 
If you use a dependency only in non-public API or only in method bodies, then the dependency is an implementation dependency, because you only need it for your implementation in that project but it is not part of the public API.
If you use a dependency in your public API, like in public or protected method signatures as return type or parameter type, or as super-type of public classes and so on, then it is an api dependency which means that downstream projects depending on it also get those dependencies in their compile classpath automatically which they don’t with implementation dependencies to not pollute the downstream compile classpath, which makes compilation faster, more reliable, and also increases the probability of up-to-dateness or cacheability, …
If you use a dependency only at compile-time, like for using annotation classes to annotate things, then it for example is a compileOnly dependency, as downstream projects should neither get this dependency at compile-time, nor at runtime, because a consumer of annotations has to make sure the annotation classes are present and otherwise the annotations are treated like they would not be present. even with runtime retention.
There is also this great plugin, which helps ensuring that you put dependencies to the proper configurations: GitHub - autonomousapps/dependency-analysis-gradle-plugin: Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins · GitHub
However, in the proto sub-project, I added
No, don’t do that.
Do not configure paths, but wire task outputs to task inputs.
The Proto plugin already does that correctly for you, so you do not need to configure this explicitly in any way.
If it still does not work, again, please provide an MCVE.
Would you agree?
If you only have one build with several projects, you don’t need to configure the version catalog.
This snippet you only need if you build a composite build of multiple builds that typically reside in the same repository to use the same version catalog across all those builds in the composite build.
With one build you only need that snippet if you put the version catalog to a non-standard place, name it in a non-standard way, or want to have multiple version catalogs for different use-cases like build-dependencies and production-dependencies or similar.
Moreover, isn’t it possible to centralize these lines
As mentioned earlier, yes, the repository can for example be centralized in the settings script in the dependencyResolutionManagement { ... } block.
To centralize other settings that are project-specific like the toolchain version, the idiomatic best-practice is to have a convention plugin, for example in buildSrc or better in an included build like build-logic, for example implemented as precompiled Kotlin DSL script plugins. Those have almost the same syntax as regular build scripts, and you then group releated settings in those plugin(s) and then just apply that plugin to your individual projects to apply the whole settings at once where you want those conventions to be effective.
also, such that each sub-project is consolidated?
No idea what you mean here.
According to Core Concepts there exists the Build, which produces output.
Of course a build produces outputs, or you would not have a build.
.
But not everything that produces outputs is called a build.
The build is the whole thing that is defined in your settings script and your project build scripts where the settings script configures the build as a whole and the project build scripts configure each individual project in the build.
Thus, this multi-project approach is for me more a question of organizing and keeping related source code together.
Yes, multi-project builds, as well as composite builds, are ways to organize your sources in logical ways and to also have some kind of architecture boundaries.
You could theoretically also have all in one big single-project build with different source sets and whatnot, but that is usually not a good or idiomatic approach.
From my understanding, I could create jar-files from both proto and lib sub-project java-files.
Not “you could”, “you do”.
And jar-file is my artifact
Yes
my build
No
which I include into the other sub-projects, right?
Kind of, yes.
Then I would literally “composite” builds
No, a build is something defined by a settings script.
And if a settings script includes other builds using includeBuild, then you form a composite build consisting of those two (or more) builds.
But since they are organized in a common repository, I only need the plain java-files, why should I access them via an imported / included jar-file, when I can use them “directly”?
Because that’s the way you do it.
If you organize your sources into multiple projects, then each project produces a jar and at runtime you use all those jars together as individual jars on the classpath or module path.
You could build fat / uber / whatever you call it jar, containing all the class files and even your dependencies’ classes, but this is horribly bad practice that also only works in narrow use-cases and you should imho never try to do that but just do it properly.
When compiling lib that depends on proto, you for example actually do not build the jar and compile against the jar, but you indeed compile against the plain class files on disk, at least if you properly used the java-library plugin and not the java plugin, because - as I said - one of the biggest strenghts of Gradle is to avoid unnecessary work and building the proto jar just to compile lib would be unnecessary. When packaging lib for runtime and getting its dependencies to pack them along, that is when the proto jar is then built, because then you actually need it.