Repository: quarkusio/quarkus
Issue: NPE in QuarkusModelBuilder for Gradle composite builds

## Describe the bug

On a project using Gradle composite build, dev mode fails to start.
The project layout is the following:

- composite
  - composite-subproject 
- project 
  -  utilities
  -  my-artifactId

- my-artifactId depends on utilities
- utilities depends on composite-subproject
- project is including composite as a Gradle composite build

### Expected behavior
Quarkus dev mode should start.

### Actual behavior
Quarkus dev mode fails with:

```
Caused by: java.lang.NullPointerException
        at io.quarkus.gradle.builder.QuarkusModelBuilder.addDevModePaths(QuarkusModelBuilder.java:402)
        at io.quarkus.gradle.builder.QuarkusModelBuilder.collectDependencies(QuarkusModelBuilder.java:360)
        at io.quarkus.gradle.builder.QuarkusModelBuilder.buildAll(QuarkusModelBuilder.java:112)
        at io.quarkus.gradle.extension.QuarkusPluginExtension.create(QuarkusPluginExtension.java:229)
        at io.quarkus.gradle.extension.QuarkusPluginExtension.getQuarkusModel(QuarkusPluginExtension.java:222)
        at io.quarkus.gradle.extension.QuarkusPluginExtension.getAppModelResolver(QuarkusPluginExtension.java:214)
        at io.quarkus.gradle.tasks.QuarkusDev.newLauncher(QuarkusDev.java:224)
        at io.quarkus.gradle.tasks.QuarkusDev.startDev(QuarkusDev.java:180)
        ... 122 more
```

Debugging shows that in `io.quarkus.gradle.builder.QuarkusModelBuilder#addDevModePaths` the project is null when it is referencing the composite module. It looks like with this setup:
`IncludedBuild includedBuild = includedBuild(project, a.getName());`
fails to detect the composite build.

In my case `project.getGradle().includedBuild(projectName)` is checking if project _project_ is including _composite-subproject_ where it is including _composite_.

## To Reproduce

Checkout https://github.com/symphony-youri/quarkus-composite

Steps to reproduce the behavior:
1. Go to project/my-artifactId folder
2. Run `gradle quarkusDev --info --stacktrace`

## Environment (please complete the following information):

### Output of `uname -a` or `ver`

Darwin xxx-mbp 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64 i386 MacBookPro16,1 Darwin

### Output of `java -version`

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05, mixed mode, sharing)

### GraalVM version (if different from Java)

### Quarkus version or git rev

1.13

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Gradle 7.0.2

## Additional context
(Add any other context about the problem here.)


Changed files:
devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java

diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java b/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java
index 8b56fd43364..ff549e1b432 100644
--- a/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java
+++ b/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java
@@ -321,18 +321,22 @@ private void collectDependencies(ResolvedConfiguration configuration,
             final DependencyImpl dep = initDependency(a);
             if ((LaunchMode.DEVELOPMENT.equals(mode) || LaunchMode.TEST.equals(mode)) &&
                     a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) {
-                IncludedBuild includedBuild = includedBuild(project, a.getName());
                 if ("test-fixtures".equals(a.getClassifier()) || "test".equals(a.getClassifier())) {
                     //TODO: test-fixtures are broken under the new ClassLoading model
                     dep.addPath(a.getFile());
                 } else {
+                    IncludedBuild includedBuild = includedBuild(project.getRootProject(), a.getName());
                     if (includedBuild != null) {
                         addSubstitutedProject(dep, includedBuild.getProjectDir());
                     } else {
                         Project projectDep = project.getRootProject()
                                 .findProject(
                                         ((ProjectComponentIdentifier) a.getId().getComponentIdentifier()).getProjectPath());
-                        addDevModePaths(dep, a, projectDep);
+                        if (projectDep != null) {
+                            addDevModePaths(dep, a, projectDep);
+                        } else {
+                            dep.addPath(a.getFile());
+                        }
                     }
                 }
             } else {