2.15+ - Services dependent on libraries without classes no longer build
### Describe the bug

When trying to upgrade to Quarkus `2.15` or higher (tested with `2.15.0.Final`, `2.15.3.Final`, `2.16.0.CR1`), libraries that don't contain classes that are included as a dependency in a Quarkus project no longer can be built because `The project does not contain a class output directory. .../build/classes must exist.`.

In the example provided in the reproducer, the library `lib2` contains `src/main/resources` but no Java classes (i.e. `src/main/java`). The Quarkus service `service4` pulls in `lib2` as a dependency. The build for `service4` fails because `lib2` does not have `build/classes`.

### Expected behavior

Successful build

### Actual behavior

```
org.gradle.api.GradleException: The project does not contain a class output directory. quarkus-test\\common\\subprojects\\lib2\\build\\classes must exist.
        at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.addSubstitutedProject(GradleApplicationModelBuilder.java:552)
        at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.collectDependencies(GradleApplicationModelBuilder.java:305)
        at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.lambda$collectDependencies$0(GradleApplicationModelBuilder.java:218)
        at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.collectDependencies(GradleApplicationModelBuilder.java:217)
        at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.buildAll(GradleApplicationModelBuilder.java:117)
        at io.quarkus.gradle.tooling.ToolingUtils.create(ToolingUtils.java:74)
        at io.quarkus.gradle.tooling.ToolingUtils.create(ToolingUtils.java:70)
        at io.quarkus.gradle.extension.QuarkusPluginExtension.getApplicationModel(QuarkusPluginExtension.java:135)
        at io.quarkus.gradle.tasks.QuarkusGenerateCode.prepareQuarkus(QuarkusGenerateCode.java:95)
```

### How to Reproduce?

Reproducer:

1. Clone https://github.com/mikethecalamity/quarkus-test
2. `./gradlew -p apps service4:build`

Note that the project `lib2` only contains `src/main/resources` so it should not have `build/classes`.

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

17.0.5

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.15.3.Final / 2.16.0.CR1

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Gradle 7.5.1

### Additional information

_No response_
diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java
index fea4982a425..0344dda228d 100644
--- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java
+++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java
@@ -18,7 +18,6 @@
 import java.util.Properties;
 import java.util.Set;
 
-import org.gradle.api.GradleException;
 import org.gradle.api.Project;
 import org.gradle.api.artifacts.Configuration;
 import org.gradle.api.artifacts.ResolvedArtifact;
@@ -570,15 +569,13 @@ private void addSubstitutedProject(PathList.Builder paths, File projectFile) {
         }
         File classesOutput = new File(projectFile, CLASSES_OUTPUT);
         File[] languageDirectories = classesOutput.listFiles();
-        if (languageDirectories == null) {
-            throw new GradleException(
-                    "The project does not contain a class output directory. " + classesOutput.getPath() + " must exist.");
-        }
-        for (File languageDirectory : languageDirectories) {
-            if (languageDirectory.isDirectory()) {
-                for (File sourceSet : languageDirectory.listFiles()) {
-                    if (sourceSet.isDirectory() && sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME)) {
-                        paths.add(sourceSet.toPath());
+        if (languageDirectories != null) {
+            for (File languageDirectory : languageDirectories) {
+                if (languageDirectory.isDirectory()) {
+                    for (File sourceSet : languageDirectory.listFiles()) {
+                        if (sourceSet.isDirectory() && sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME)) {
+                            paths.add(sourceSet.toPath());
+                        }
                     }
                 }
             }
['devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java']