Repository: quarkusio/quarkus
Issue: The QuarkusBootstrapProvider caches the AppArtifact causing problems

The `QuarkusBoostrapProvider` has a cache of `QuarkusAppBootstrapProvider` which itself has a field for the `AppArtifact`.
This field is initialised with the `initAppArtifact` if not yet initialized.
However, this method creates the output build directory if it does not exists.

The causes problems if the cache is actually reused in a subsequent built after cleaning the project and leads to problems because the output directory has not been created.
```
➜  log-sink git:(main) ✗ mvnd clean verify
[INFO] Processing build on daemon 887b51d4[INFO] Scanning for projects...
[INFO] BuildTimeEventSpy is registered.
[INFO] 
[INFO] Using the SmartBuilder implementation with a thread count of 11
[INFO] Task segments : [clean, verify]
[INFO] Build maximum degree of concurrency is 11
[INFO] Total number of projects is 1
[INFO] 
[INFO] --------------------------< org.bf2:log-sink >--------------------------
[INFO] Building connectors-images :: log-sink 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ log-sink ---
[INFO] 
[INFO] --- directory-maven-plugin:0.3.1:highest-basedir (directories) @ log-sink ---
[INFO] Highest basedir set to: /Users/gnodet/work/git/cos-fleet-catalog-camel
[INFO] 
[INFO] --- quarkus-maven-plugin:2.0.0.CR3:generate-code (default) @ log-sink ---
[INFO] 
[INFO] --- formatter-maven-plugin:2.14.0:format (format) @ log-sink ---
[INFO] Using 'UTF-8' encoding to format source files.
[INFO] Number of files to be formatted: 0
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ log-sink ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ log-sink ---
[INFO] No sources to compile
[INFO] 
[INFO] --- quarkus-maven-plugin:2.0.0.CR3:generate-code-tests (default) @ log-sink ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ log-sink ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/gnodet/work/git/cos-fleet-catalog-camel/cos-fleet-catalog-connectors-images/log-sink/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ log-sink ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ log-sink ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ log-sink ---
[INFO] Building jar: /Users/gnodet/work/git/cos-fleet-catalog-camel/cos-fleet-catalog-connectors-images/log-sink/target/log-sink-0.1.jar
[INFO] 
[INFO] --- quarkus-maven-plugin:2.0.0.CR3:build (default) @ log-sink ---
[INFO] [org.jboss.threads] JBoss Threads version 3.4.0.Final
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 1103ms
[INFO] Segment walltime 2 s, segment projects service time 2 s, effective/maximum degree of concurrency 1.00/11
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.830 s (Wall Clock)
[INFO] Finished at: 2021-06-23T10:33:47+02:00
[INFO] ------------------------------------------------------------------------
➜  log-sink git:(main) ✗ mvnd clean verify
[INFO] Processing build on daemon 887b51d4[INFO] Scanning for projects...
[INFO] BuildTimeEventSpy is registered.
[INFO] 
[INFO] Using the SmartBuilder implementation with a thread count of 11
[INFO] Task segments : [clean, verify]
[INFO] Build maximum degree of concurrency is 11
[INFO] Total number of projects is 1
[INFO] 
[INFO] --------------------------< org.bf2:log-sink >--------------------------
[INFO] Building connectors-images :: log-sink 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ log-sink ---
[INFO] Deleting /Users/gnodet/work/git/cos-fleet-catalog-camel/cos-fleet-catalog-connectors-images/log-sink/target
[INFO] 
[INFO] --- directory-maven-plugin:0.3.1:highest-basedir (directories) @ log-sink ---
[INFO] Highest basedir set to: /Users/gnodet/work/git/cos-fleet-catalog-camel
[INFO] 
[INFO] --- quarkus-maven-plugin:2.0.0.CR3:generate-code (default) @ log-sink ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.724 s (Wall Clock)
[INFO] Finished at: 2021-06-23T10:33:49+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:2.0.0.CR3:generate-code (default) on project log-sink: Quarkus code generation phase has failed: Error while reading file as JAR: /Users/gnodet/work/git/cos-fleet-catalog-camel/cos-fleet-catalog-connectors-images/log-sink/target/classes -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
➜  log-sink git:(main) ✗ 
```



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

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 88a10542bc5..1ce97e18e35 100644
--- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java
+++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java
@@ -290,6 +290,7 @@ public void close() {
                 curatedApp.close();
                 curatedApp = null;
             }
+            appArtifact = null;
             quarkusBootstrap = null;
         }
     }