Repository: quarkusio/quarkus
Issue: Quarkus Unit tests fail when running from IntelliJ for Gradle project

**Describe the bug**
In #8737 support for IntelliJ builder/runner was added. But it seems that it does not work. 
Reproducible: https://github.com/asodja/quarkus-gradle-idea-multi-module
Error:
```
java.lang.RuntimeException: java.io.UncheckedIOException: Error while reading file as JAR: /Users/anzes/prototype-dev/quarkus-gradle-idea-multi-module/module-1/build/libs/module-1-my-version.jar
	at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:513)
	at io.quarkus.test.junit.QuarkusTestExtension.beforeEach(QuarkusTestExtension.java:363)
Caused by: java.io.UncheckedIOException: Error while reading file as JAR: /Users/anzes/prototype-dev/quarkus-gradle-idea-multi-module/module-1/build/libs/module-1-my-version.jar
	at io.quarkus.bootstrap.classloading.JarClassPathElement.<init>(JarClassPathElement.java:46)
	at io.quarkus.bootstrap.classloading.ClassPathElement.fromPath(ClassPathElement.java:51)
	at io.quarkus.bootstrap.app.CuratedApplication.processCpElement(CuratedApplication.java:156)
	at io.quarkus.bootstrap.app.CuratedApplication.getBaseRuntimeClassLoader(CuratedApplication.java:235)
	at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:198)
	at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:491)
	at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:524)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$7(ClassBasedTestDescriptor.java:359)
	... 29 more
Caused by: java.io.FileNotFoundException: /Users/anzes/prototype-dev/quarkus-gradle-idea-multi-module/module-1/build/libs/module-1-my-version.jar (No such file or directory)
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:225)
	at java.util.zip.ZipFile.<init>(ZipFile.java:155)
	at java.util.jar.JarFile.<init>(JarFile.java:166)
	at java.util.jar.JarFile.<init>(JarFile.java:130)
	at io.smallrye.common.io.jar.JarFiles.create(JarFiles.java:34)
	at io.quarkus.bootstrap.classloading.JarClassPathElement.<init>(JarClassPathElement.java:44)
	... 41 more
```

The problems are two:
1. IntelliJ compiles files to `out/` and Gradle Model expects things in `build/` directory
2. Gradle Model expects Jars for test sources (IntelliJ does not create jars)

This can be workaround with: https://github.com/quarkusio/quarkus/pull/11339

If you run `./gradlew build` test will pass since jars are in `build/` folder.

**Expected behavior**
Unit test passes, no exception is thrown.

**Actual behavior**
Unit test fails, exception is thrown.

**To Reproduce**
Steps to reproduce the behavior:
1. git clone https://github.com/asodja/quarkus-gradle-idea-multi-module
2. In IntelliJ set Preferences -> Gradle -> Build and run using IntelliJ and Run tests using IntelliJ
3. Run `MyTest` (Note: you should not have `build/` folder) 


**Environment (please complete the following information):**
 - Mac OS Catalina
 - OpenJDK 1.8.0_242
 - Quarkus version: 1.7.0.Final
 - Build tool: Gradle 6.5.1


Changed files:
independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/resolver/QuarkusGradleModelFactory.java
independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/util/QuarkusModelHelper.java
independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/utils/BuildToolHelper.java
test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java

diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/utils/BuildToolHelper.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/utils/BuildToolHelper.java
index babc69bd053..90d9c68dbfa 100644
--- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/utils/BuildToolHelper.java
+++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/utils/BuildToolHelper.java
@@ -59,13 +59,13 @@ public static Path getBuildFile(Path project, BuildTool tool) {
         return null;
     }
 
-    public static QuarkusModel enableGradleAppModel(Path projectRoot, String mode)
+    public static QuarkusModel enableGradleAppModel(Path projectRoot, String mode, String... tasks)
             throws IOException, AppModelResolverException {
         if (isMavenProject(projectRoot)) {
             return null;
         }
         final QuarkusModel model = QuarkusGradleModelFactory.create(getBuildFile(projectRoot, BuildTool.GRADLE).toFile(),
-                mode);
+                mode, tasks);
         QuarkusModelHelper.exportModel(model);
         return model;
     }
diff --git a/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/resolver/QuarkusGradleModelFactory.java b/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/resolver/QuarkusGradleModelFactory.java
index 8f025f98f15..69ef1e314ef 100644
--- a/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/resolver/QuarkusGradleModelFactory.java
+++ b/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/resolver/QuarkusGradleModelFactory.java
@@ -8,10 +8,11 @@
 
 public class QuarkusGradleModelFactory {
 
-    public static QuarkusModel create(File projectDir, String mode) {
+    public static QuarkusModel create(File projectDir, String mode, String... tasks) {
         try (ProjectConnection connection = GradleConnector.newConnector()
                 .forProjectDirectory(projectDir)
                 .connect()) {
+            connection.newBuild().forTasks(tasks).run();
             return connection.action(new QuarkusModelBuildAction(mode)).run();
         }
     }
diff --git a/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/util/QuarkusModelHelper.java b/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/util/QuarkusModelHelper.java
index c90a7d07ef4..dd295b6797f 100644
--- a/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/util/QuarkusModelHelper.java
+++ b/independent-projects/bootstrap/gradle-resolver/src/main/java/io/quarkus/bootstrap/util/QuarkusModelHelper.java
@@ -36,6 +36,7 @@ private QuarkusModelHelper() {
     }
 
     public final static String[] DEVMODE_REQUIRED_TASKS = new String[] { "classes" };
+    public final static String[] TEST_REQUIRED_TASKS = new String[] { "classes", "testClasses" };
 
     public static void exportModel(QuarkusModel model) throws AppModelResolverException, IOException {
         Path serializedModel = QuarkusModelHelper
diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java
index aec84b21510..4cf1e341e5f 100644
--- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java
+++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java
@@ -57,6 +57,7 @@
 import io.quarkus.bootstrap.app.StartupAction;
 import io.quarkus.bootstrap.model.PathsCollection;
 import io.quarkus.bootstrap.runner.Timing;
+import io.quarkus.bootstrap.util.QuarkusModelHelper;
 import io.quarkus.bootstrap.utils.BuildToolHelper;
 import io.quarkus.builder.BuildChainBuilder;
 import io.quarkus.builder.BuildContext;
@@ -181,7 +182,7 @@ private ExtensionState doJavaStart(ExtensionContext context, Class<? extends Qua
             Path root = Paths.get("").normalize().toAbsolutePath();
             // If gradle project running directly with IDE
             if (System.getProperty(BootstrapConstants.SERIALIZED_APP_MODEL) == null) {
-                BuildToolHelper.enableGradleAppModel(root, "TEST");
+                BuildToolHelper.enableGradleAppModel(root, "TEST", QuarkusModelHelper.TEST_REQUIRED_TASKS);
             }
 
             runnerBuilder.setApplicationRoot(rootBuilder.build());