Repository: quarkusio/quarkus
Issue: OutputTargetBuildItem.getOutputDirectory() returning a strange value when running a test in the Platform

### Describe the bug

I see `OutputTargetBuildItem.getOutputDirectory()` returning a very strange value 

```
/home/ppalaga/orgs/quarkus/quarkus-platform/generated-platform-project/quarkus-cxf/integration-tests/quarkus-cxf-integration-test-server/..
```
when running a generarated test project on the Platform.

I'd expect something like 

```
/home/ppalaga/orgs/quarkus/quarkus-platform/generated-platform-project/quarkus-cxf/integration-tests/quarkus-cxf-integration-test-server/target
```

Is this a bug or some peculiarity of the Platform test config @aloubyansky ?


Changed files:
test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java
independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java

diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java
index 6c068b88029..e7b1c5a1e4c 100644
--- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java
+++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java
@@ -205,7 +205,7 @@ public CurationResult resolveAppModel() throws BootstrapException {
         if (serializedModel != null) {
             final Path p = Paths.get(serializedModel);
             if (Files.exists(p)) {
-                try (InputStream existing = Files.newInputStream(Paths.get(serializedModel))) {
+                try (InputStream existing = Files.newInputStream(p)) {
                     final ApplicationModel appModel = (ApplicationModel) new ObjectInputStream(existing).readObject();
                     return new CurationResult(appModel);
                 } catch (IOException | ClassNotFoundException e) {
diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java b/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java
index 079f0d7a32d..05fda9bc7c6 100644
--- a/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java
+++ b/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java
@@ -292,14 +292,10 @@ private static Path toPath(URL resource) {
      * @return project build dir
      */
     public static Path getProjectBuildDir(Path projectRoot, Path testClassLocation) {
-        Path outputDir;
-        try {
-            // this should work for both maven and gradle
-            outputDir = projectRoot.resolve(projectRoot.relativize(testClassLocation).getName(0));
-        } catch (Exception e) {
-            // this shouldn't happen since testClassLocation is usually found under the project dir
-            outputDir = projectRoot;
+        if (!testClassLocation.startsWith(projectRoot)) {
+            // this typically happens in the platform testsuite where test classes are loaded from jars
+            return projectRoot.resolve("target");
         }
-        return outputDir;
+        return projectRoot.resolve(projectRoot.relativize(testClassLocation).getName(0));
     }
 }