Repository: quarkusio/quarkus
Issue: Regression in 2.13.2: NPE in `LocalProject` during `quarkus-maven-plugin:build` when activating `quarkus.bootstrap.workspace-discovery`

### Describe the bug

Updating from 2.13.1 to 2.13.2 results in:
```
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:2.13.2.Final:build (default) on project somecomp-server: Failed to build quarkus application: Failed to initialize Quarkus bootstrap Maven artifact resolver: Failed to load current project at /home/fmo/proj/someproj/somecomp/dev1/server/.flattened-pom.xml: Cannot invoke "java.io.File.toPath()" because the return value of "org.apache.maven.model.Model.getProjectDirectory()" is null -> [Help 1]
...
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.File.toPath()" because the return value of "org.apache.maven.model.Model.getProjectDirectory()" is null
    at io.quarkus.bootstrap.resolver.maven.workspace.LocalProject.<init> (LocalProject.java:172)
    at io.quarkus.bootstrap.resolver.maven.workspace.WorkspaceLoader.loadAndCacheProject (WorkspaceLoader.java:143)
    at io.quarkus.bootstrap.resolver.maven.workspace.WorkspaceLoader.project (WorkspaceLoader.java:118)
    at io.quarkus.bootstrap.resolver.maven.workspace.WorkspaceLoader.loadProject (WorkspaceLoader.java:178)
    at io.quarkus.bootstrap.resolver.maven.workspace.WorkspaceLoader.load (WorkspaceLoader.java:230)
    at io.quarkus.bootstrap.resolver.maven.workspace.LocalProject.loadWorkspace (LocalProject.java:118)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.resolveCurrentProject (BootstrapMavenContext.java:321)
    at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.<init> (BootstrapMavenContext.java:173)
    at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.<init> (MavenArtifactResolver.java:91)
    at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver$Builder.build (MavenArtifactResolver.java:75)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.artifactResolver (QuarkusBootstrapProvider.java:152)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.doBootstrap (QuarkusBootstrapProvider.java:206)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.bootstrapApplication (QuarkusBootstrapProvider.java:284)
    at io.quarkus.maven.QuarkusBootstrapProvider.bootstrapApplication (QuarkusBootstrapProvider.java:86)
    at io.quarkus.maven.QuarkusBootstrapMojo.bootstrapApplication (QuarkusBootstrapMojo.java:272)
    at io.quarkus.maven.QuarkusBootstrapMojo.bootstrapApplication (QuarkusBootstrapMojo.java:268)
    at io.quarkus.maven.BuildMojo.doExecute (BuildMojo.java:130)
    at io.quarkus.maven.QuarkusBootstrapMojo.execute (QuarkusBootstrapMojo.java:154)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
```

### Expected behavior

No error

### Actual behavior

Error during build

### How to Reproduce?

n/a at this point

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

_No response_

### Output of `java -version`

17.0.4

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

_No response_

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

Maven 3.8.6

### Additional information

Build happens via profile:
```xml
        <profile>
            <id>image-build</id>
            <properties>
                <!-- switch on early Quarkus workspace discovery for smaller layers -->
                <quarkus.bootstrap.workspace-discovery>true</quarkus.bootstrap.workspace-discovery>
                <quarkus.container-image.name>somecomp</quarkus.container-image.name>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.quarkus</groupId>
                        <artifactId>quarkus-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
```
Jib plugin is used to build the image (but it doesn't get that far).

Changed files:
devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java, devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java

diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
index 387fcb3a42f..0d300ecc92a 100644
--- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
+++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
@@ -43,7 +43,6 @@
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.BuildBase;
 import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Model;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.PluginExecution;
 import org.apache.maven.model.Profile;
@@ -121,8 +120,6 @@
 @Mojo(name = "dev", defaultPhase = LifecyclePhase.PREPARE_PACKAGE, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
 public class DevMojo extends AbstractMojo {
 
-    private static final String EXT_PROPERTIES_PATH = "META-INF/quarkus-extension.properties";
-
     private static final String KOTLIN_MAVEN_PLUGIN_GA = "org.jetbrains.kotlin:kotlin-maven-plugin";
 
     /**
@@ -1105,11 +1102,7 @@ private QuarkusDevModeLauncher newLauncher() throws Exception {
                 mvnConfig.setRepositorySystemSession(repoSession).setRepositorySystem(repoSystem);
                 // there could be Maven extensions manipulating the project versions and models
                 // the ones returned from the Maven API could be different from the original pom.xml files
-                final Map<Path, Model> projectModels = new HashMap<>(session.getAllProjects().size());
-                for (MavenProject mp : session.getAllProjects()) {
-                    projectModels.put(mp.getBasedir().toPath(), mp.getOriginalModel());
-                }
-                mvnConfig.setProjectModelProvider(projectModels::get);
+                mvnConfig.setProjectModelProvider(QuarkusBootstrapProvider.getProjectMap(session)::get);
             }
 
             final BootstrapMavenContext mvnCtx = new BootstrapMavenContext(mvnConfig);
diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java
index f340b2048d4..2c4e876d7e1 100644
--- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java
+++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java
@@ -16,6 +16,7 @@
 import java.util.concurrent.ExecutionException;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Model;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -63,6 +64,16 @@ static ArtifactKey getProjectId(MavenProject project) {
         return ArtifactKey.ga(project.getGroupId(), project.getArtifactId());
     }
 
+    static Map<Path, Model> getProjectMap(MavenSession session) {
+        final List<MavenProject> allProjects = session.getAllProjects();
+        final Map<Path, Model> projectModels = new HashMap<>(allProjects.size());
+        for (MavenProject mp : allProjects) {
+            mp.getOriginalModel().setPomFile(mp.getFile());
+            projectModels.put(mp.getBasedir().toPath(), mp.getOriginalModel());
+        }
+        return projectModels;
+    }
+
     public RepositorySystem repositorySystem() {
         return repoSystem;
     }
@@ -143,11 +154,7 @@ private MavenArtifactResolver artifactResolver(QuarkusBootstrapMojo mojo, Launch
                         .setRemoteRepositories(mojo.remoteRepositories())
                         .setRemoteRepositoryManager(remoteRepoManager);
                 if (mode == LaunchMode.DEVELOPMENT || mode == LaunchMode.TEST || isWorkspaceDiscovery(mojo)) {
-                    final Map<Path, Model> projectModels = new HashMap<>(mojo.mavenSession().getAllProjects().size());
-                    for (MavenProject mp : mojo.mavenSession().getAllProjects()) {
-                        projectModels.put(mp.getBasedir().toPath(), mp.getOriginalModel());
-                    }
-                    builder.setWorkspaceDiscovery(true).setProjectModelProvider(projectModels::get);
+                    builder.setWorkspaceDiscovery(true).setProjectModelProvider(getProjectMap(mojo.mavenSession())::get);
                 }
                 return builder.build();
             } catch (BootstrapMavenException e) {