Repository: quarkusio/quarkus
Issue: Caching of hardcoded paths can cause issues

**Describe the bug**
recently something changed in caching so if you have a change in your ~/.m2 settings/location between builds the build fails with errors like:

```
ava.lang.RuntimeException: java.lang.RuntimeException: java.io.UncheckedIOException: Error while reading file as JAR: C:\\Users\\max\\.m2\\repository\\commons-io\\commons-io\\2.6\\commons-io-2.6.jar
Caused by: java.lang.RuntimeException: java.io.UncheckedIOException: Error while reading file as JAR: C:\\Users\\max\\.m2\\repository\\commons-io\\commons-io\\2.6\\commons-io-2.6.jar
Caused by: java.io.UncheckedIOException: Error while reading file as JAR: C:\\Users\\max\\.m2\\repository\\commons-io\\commons-io\\2.6\\commons-io-2.6.jar
Caused by: java.nio.file.NoSuchFileException: C:\\Users\\max\\.m2\\repository\\commons-io\\commons-io\\2.6\\commons-io-2.6.jar
```

**Expected behavior**
in this case its due to doing a build on windows and then afterwards on linux - both have a functioning ~/.m2 folder but since we now store absolute paths things goes wrong.

similar could happen if you cleaned your ~/.m2 repo or changed your .settings.xml or similar


Changed files:
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 ad764ffd007..9ed42945e02 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
@@ -257,14 +257,27 @@ public CurationResult resolveAppModel() throws BootstrapException {
 
         try {
             Path cachedCpPath = null;
+
             if (workspace != null && enableClasspathCache) {
                 cachedCpPath = resolveCachedCpPath(localProject);
-                if (Files.exists(cachedCpPath)) {
+                if (Files.exists(cachedCpPath)
+                        && workspace.getLastModified() < Files.getLastModifiedTime(cachedCpPath).toMillis()) {
                     try (DataInputStream reader = new DataInputStream(Files.newInputStream(cachedCpPath))) {
                         if (reader.readInt() == CP_CACHE_FORMAT_ID) {
                             if (reader.readInt() == workspace.getId()) {
                                 ObjectInputStream in = new ObjectInputStream(reader);
-                                return new CurationResult((AppModel) in.readObject());
+                                AppModel appModel = (AppModel) in.readObject();
+                                for (AppDependency i : appModel.getFullDeploymentDeps()) {
+                                    if (!Files.exists(i.getArtifact().getPath())) {
+                                        throw new IOException("Cached artifact does not exist: " + i.getArtifact().getPath());
+                                    }
+                                }
+                                for (AppDependency i : appModel.getUserDependencies()) {
+                                    if (!Files.exists(i.getArtifact().getPath())) {
+                                        throw new IOException("Cached artifact does not exist: " + i.getArtifact().getPath());
+                                    }
+                                }
+                                return new CurationResult(appModel);
                             } else {
                                 debug("Cached deployment classpath has expired for %s", appArtifact);
                             }