Repository: quarkusio/quarkus
Issue: java.nio.file.NoSuchFileException when quarkus.native.debug.enabled

**Describe the bug**
With `quarkus.native.debug.enabled=true`, building a native image fails with

```
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Unable to copy from C:\\Users\\moritz\\.m2\\repository\\org\\jboss\\resteasy\\resteasy-core\\4.5.8.Final\\resteasy-core-4.5.8.Final-sources.jar to C:\\Users\\moritz\\GitHub\\blaze-persistence\\examples\\quarkus\\testsuite\\native\\postgresql\\target\\postgresql-test-app-native-image-source-jar\\lib\\org.jboss.resteasy.resteasy-core-4.5.8.Final-sources.jar
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copyJarSourcesToLib(NativeImageBuildStep.java:420)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:93)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: java.nio.file.NoSuchFileException: C:\\Users\\moritz\\.m2\\repository\\org\\jboss\\resteasy\\resteasy-core\\4.5.8.Final\\resteasy-core-4.5.8.Final-sources.jar -> C:\\Users\\moritz\\GitHub\\blaze-persistence\\examples\\quarkus\\testsuite\\native\\postgresql\\target\\postgresql-test-app-native-image-source-jar\\lib\\org.jboss.resteasy.resteasy-core-4.5.8.Final-sources.jar
[ERROR]         at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
[ERROR]         at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
[ERROR]         at java.base/sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:202)
[ERROR]         at java.base/sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:279)
[ERROR]         at java.base/java.nio.file.Files.copy(Files.java:1294)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copyJarSourcesToLib(NativeImageBuildStep.java:418)
[ERROR]         ... 13 more
```

The reason is that the `lib` directory inside `postgresql-test-app-native-image-source-jar` is not created by the quarkus-maven-plugin.

Once this is fixed, the next problem is

```
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.io.UncheckedIOException: Unable to walk path C:\\Users\\moritz\\GitHub\\blaze-persistence\\examples\\quarkus\\testsuite\\native\\postgresql\\target\\..\\src\\main\\java
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copySourcesToSourceCache(NativeImageBuildStep.java:476)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:94)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: java.nio.file.NoSuchFileException: C:\\Users\\moritz\\GitHub\\blaze-persistence\\examples\\quarkus\\testsuite\\native\\postgresql\\target\\..\\src\\main\\java
[ERROR]         at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
[ERROR]         at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
[ERROR]         at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
[ERROR]         at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
[ERROR]         at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
[ERROR]         at java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:194)
[ERROR]         at java.base/java.nio.file.Files.readAttributes(Files.java:1763)
[ERROR]         at java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
[ERROR]         at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
[ERROR]         at java.base/java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
[ERROR]         at java.base/java.nio.file.FileTreeIterator.<init>(FileTreeIterator.java:71)
[ERROR]         at java.base/java.nio.file.Files.walk(Files.java:3820)
[ERROR]         at java.base/java.nio.file.Files.walk(Files.java:3874)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copySourcesToSourceCache(NativeImageBuildStep.java:466)
[ERROR]         ... 13 more
```

if `src/main/java` does not exist.

**Expected behavior**
The build does not fail with above exceptions.

**Actual behavior**
The build fails.

**Configuration**
```properties
quarkus.native.debug.enabled=true
```

**Environment (please complete the following information):**
 - Quarkus version or git rev: 1.9.2.Final



Changed files:
core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java

diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java
index 0715da4104e..6b1b33f3eba 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java
@@ -503,18 +503,20 @@ private static void copySourcesToSourceCache(OutputTargetBuildItem outputTargetB
         final Path javaSourcesPath = outputTargetBuildItem.getOutputDirectory().resolve(
                 Paths.get("..", "src", "main", "java"));
 
-        try (Stream<Path> paths = Files.walk(javaSourcesPath)) {
-            paths.forEach(path -> {
-                Path targetPath = Paths.get(targetSrc.toString(),
-                        path.toString().substring(javaSourcesPath.toString().length()));
-                try {
-                    Files.copy(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
-                } catch (IOException e) {
-                    throw new UncheckedIOException("Unable to copy from " + path + " to " + targetPath, e);
-                }
-            });
-        } catch (IOException e) {
-            throw new UncheckedIOException("Unable to walk path " + javaSourcesPath, e);
+        if (Files.exists(javaSourcesPath)) {
+            try (Stream<Path> paths = Files.walk(javaSourcesPath)) {
+                paths.forEach(path -> {
+                    Path targetPath = Paths.get(targetSrc.toString(),
+                            path.toString().substring(javaSourcesPath.toString().length()));
+                    try {
+                        Files.copy(path, targetPath, StandardCopyOption.REPLACE_EXISTING);
+                    } catch (IOException e) {
+                        throw new UncheckedIOException("Unable to copy from " + path + " to " + targetPath, e);
+                    }
+                });
+            } catch (IOException e) {
+                throw new UncheckedIOException("Unable to walk path " + javaSourcesPath, e);
+            }
         }
     }