Repository: quarkusio/quarkus
Issue: [1.3.0.CR1] Gradle build breaks with local non-jar project dependencies

**Describe the bug**
The feature introduced in #7441 seems too naive. It seems to scan every `project` dependency for a `jar` task without checking if there is one at all.

**Expected behavior**
Gradle builds a multi project build where a sub project with the Quarkus plugins depends on another sub project without a `jar` task (e.g. a `java-platform` project) without any issues.

**Actual behavior**
Gradle fails at configuring the Quarkus sub project because of missing `jar` task in dependent project:
```
❯ ./gradlew tasks

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':service'.
> Task with name 'jar' not found in project ':platform'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
```


**To Reproduce**
Steps to reproduce the behavior:
1. clone https://github.com/pschyma/quarkus-gradle-multi-project
2. `./gradlew tasks`

**Environment (please complete the following information):**
 - Output of `uname -a` or `ver`:  `Linux enterprise 5.5.8-arch1-1 #1 SMP PREEMPT Fri, 06 Mar 2020 00:57:33 +0000 x86_64 GNU/Linux`
 - Output of `java -version`: 
```openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07)
OpenJDK 64-Bit Server VM GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07, mixed mode, sharing)
```
 - GraalVM version (if different from Java): 
 - Quarkus version or git rev: `1.3.0.CR1`
 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): `6.2.2`

**Additional context**
Another note: simply scanning for the presence of `jar` task could also lead to unexpected results if there is a jar producing task but with another name. Maybe it would be more reliable to scan the project artifacts.


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

diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
index eb7d7a10321..a5015c420e4 100644
--- a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
+++ b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java
@@ -7,6 +7,7 @@
 import org.gradle.api.Plugin;
 import org.gradle.api.Project;
 import org.gradle.api.Task;
+import org.gradle.api.UnknownTaskException;
 import org.gradle.api.artifacts.ConfigurationContainer;
 import org.gradle.api.artifacts.ProjectDependency;
 import org.gradle.api.plugins.BasePlugin;
@@ -76,7 +77,7 @@ private void registerTasks(Project project) {
         project.getPlugins().withType(
                 JavaPlugin.class,
                 javaPlugin -> {
-                    project.afterEvaluate(p -> afterEvaluate(p));
+                    project.afterEvaluate(this::afterEvaluate);
 
                     Task classesTask = tasks.getByName(JavaPlugin.CLASSES_TASK_NAME);
                     quarkusDev.dependsOn(classesTask);
@@ -119,7 +120,7 @@ private void registerTasks(Project project) {
                         t.useJUnitPlatform();
                     };
                     tasks.withType(Test.class).forEach(configureTestTask);
-                    tasks.withType(Test.class).whenTaskAdded(t -> configureTestTask.accept(t));
+                    tasks.withType(Test.class).whenTaskAdded(configureTestTask::accept);
                 });
     }
 
@@ -135,16 +136,22 @@ private void afterEvaluate(Project project) {
                 .getIncoming().getDependencies()
                 .forEach(d -> {
                     if (d instanceof ProjectDependency) {
-                        configProjectDependency(project, project.getRootProject().findProject(d.getName()));
+                        configProjectDependency(project, ((ProjectDependency) d).getDependencyProject());
                     }
                 });
     }
 
     private void configProjectDependency(Project project, Project dep) {
-        project.getLogger().debug("Configuring %s task dependencies on %s tasks", project, dep);
-        final Task quarkusBuild = project.getTasks().findByName(QUARKUS_BUILD_TASK_NAME);
-        final Task jarTask = dep.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
-        quarkusBuild.dependsOn(jarTask);
-        extension.addProjectDepJarTask(dep, jarTask);
+        try {
+            final Task jarTask = dep.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
+            final Task quarkusBuild = project.getTasks().findByName(QUARKUS_BUILD_TASK_NAME);
+            project.getLogger().debug("Configuring %s task dependencies on %s tasks", project, dep);
+            if (quarkusBuild != null) {
+                quarkusBuild.dependsOn(jarTask);
+            }
+            extension.addProjectDepJarTask(dep, jarTask);
+        } catch (UnknownTaskException e) {
+            project.getLogger().debug("Expected tasks not present", e);
+        }
     }
 }