Repository: quarkusio/quarkus
Issue: Image generation failed. Exit code: 255 in windows 10

### Describe the bug

I can't do native build with graalvm
I'm execute ./mvnw package -Pnative 
I try to compile native using jdbc and specifying the DB credentials in the properties file but I get an error, however this only happens when I add the dependencies
```xml
<dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-hibernate-orm</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jdbc-oracle</artifactId>
    </dependency>
```
If I try to make the native compilation without these dependencies I can execute it without any problem

### Expected behavior

Run a native executable.

### Actual behavior

I'm execute ./mvnw package -Pnative and my log return this error:

```bash
C:\\Users\\andre\\IdeaProjects\\code-with-quarkus>mvnw package -Pnative
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.tmve:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ code-with-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- quarkus-maven-plugin:2.9.2.Final:generate-code (default) @ code-with-quarkus ---
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ code-with-quarkus ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- quarkus-maven-plugin:2.9.2.Final:generate-code-tests (default) @ code-with-quarkus ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ code-with-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\\Users\\andre\\IdeaProjects\\code-with-quarkus\\src\\test\\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ code-with-quarkus ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ code-with-quarkus ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.tmve.GreetingResourceTest
2022-06-03 10:15:06,888 INFO  [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final
2022-06-03 10:15:07,527 WARN  [io.qua.hib.orm.dep.HibernateOrmProcessor] (build-34) Hibernate ORM is disabled because no JPA entities were found
2022-06-03 10:15:10,435 INFO  [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.9.2.Final) started in 4.712s. Listening on: http://localhost:8081
2022-06-03 10:15:10,435 INFO  [io.quarkus] (main) Profile test activated.
2022-06-03 10:15:10,436 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, jdbc-oracle, narayana-jta, resteasy, resteasy-jackson, smallrye-context-propagation, vertx]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.616 s - in com.tmve.GreetingResourceTest
2022-06-03 10:15:12,938 INFO  [io.quarkus] (main) code-with-quarkus stopped in 0.056s
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ code-with-quarkus ---
[INFO]
[INFO] --- quarkus-maven-plugin:2.9.2.Final:build (default) @ code-with-quarkus ---
[WARNING] [io.quarkus.deployment.steps.NativeImageAllowIncompleteClasspathAggregateStep] The following extensions have required native-image to allow run-time resolution of classes: {quarkus-jdbc-oracle}. This is a global requirement which might have unexpected effects on other extensions as well, and is a hint of the library needing some additional refactoring to better support GraalVM native-image. In the case of 3rd party dependencies and/or proprietary code there is not much we can do - please ask for support to your library vendor. If you incur in any problem with other Quarkus extensions, please try reproducing the problem without these extensions first.
[WARNING] [io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor] Hibernate ORM is disabled because no JPA entities were found
[INFO] [org.hibernate.Version] HHH000412: Hibernate ORM core version 5.6.9.Final
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Uber JAR strategy is used for native image source JAR generation on Windows. This is done for the time being to work around a current GraalVM limitation on Windows concerning the maximum command length (see https://github.com/oracle/graal/issues/2387).
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building uber jar: C:\\Users\\andre\\IdeaProjects\\code-with-quarkus\\target\\code-with-quarkus-1.0.0-SNAPSHOT-native-image-source-jar\\code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from C:\\Users\\andre\\IdeaProjects\\code-with-quarkus\\target\\code-with-quarkus-1.0.0-SNAPSHOT-native-image-source-jar\\code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM 22.0.0.2 Java 17 CE (Java Version 17.0.2+8-jvmci-22.0-b05)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] C:\\Program Files (x86)\\graalvm-ce-java17-22.0.0.2\\bin\\native-image.cmd -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 -H:-ParseOnce -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -J-Djava.awt.headless=true -H:FallbackThreshold=0 --allow-incomplete-classpath -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace --exclude-config .*com\\.oracle\\.database\\.jdbc.* /META-INF/native-image/(?:native-image\\.properties|reflect-config\\.json) code-with-quarkus-1.0.0-SNAPSHOT-runner -jar code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
The system cannot find the path specified.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  37.312 s
[INFO] Finished at: 2022-06-03T10:15:29-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.9.2.Final:build (default) on project code-with-quarkus: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: io.quarkus.deployment.pkg.steps.NativeImageBuildStep$ImageGenerationFailureException: Image generation failed. Exit code: 255[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:400)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:240)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:925)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:833)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] -> [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
```
### How to Reproduce?


adding the jdbc and hibernate dependencies and then running mvnw package -Pnative

### Output of `uname -a` or `ver`

Windows 10

### Output of `java -version`

java version "11.0.13" 2021-10-19 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.13+10-LTS-370) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.13+10-LTS-370, mixed mode)

### GraalVM version (if different from Java)

GraalVM Updater 22.0.0.2

### Quarkus version or git rev

2.9.1.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\\Users\\andre\\.m2\\wrapper\\dists\\apache-maven-3.8.4-bin\\52ccbt68d252mdldqsfsn03jlf\\apache-maven-3.8.4 Java version: 17.0.2, vendor: Oracle Corporation, runtime: C:\\Program Files\\Java\\jdk-17.0.2 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

### Additional information

The project used is the base one created from https://code.quarkus.io/

Changed files:
extensions/jdbc/jdbc-oracle/deployment/src/test/java/io/quarkus/jdbc/oracle/deployment/RegexMatchTest.java
extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java

diff --git a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java
index 632df697aec..494d9ed1fec 100644
--- a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java
+++ b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java
@@ -35,7 +35,8 @@
 public final class OracleMetadataOverrides {
 
     static final String DRIVER_JAR_MATCH_REGEX = ".*com\\\\.oracle\\\\.database\\\\.jdbc.*";
-    static final String NATIVE_IMAGE_RESOURCE_MATCH_REGEX = "/META-INF/native-image/(?:native-image\\\\.properties|reflect-config\\\\.json)";
+    static final String NATIVE_IMAGE_RESOURCE_MATCH_REGEX = "/META-INF/native-image/native-image\\\\.properties";
+    static final String NATIVE_IMAGE_REFLECT_CONFIG_MATCH_REGEX = "/META-INF/native-image/reflect-config\\\\.json";
 
     /**
      * Should match the contents of {@literal reflect-config.json}
@@ -106,9 +107,13 @@ void runtimeInitializeDriver(BuildProducer<RuntimeInitializedClassBuildItem> run
     }
 
     @BuildStep
-    ExcludeConfigBuildItem excludeOracleDirectives() {
-        // Excludes both native-image.properties and reflect-config.json, which are reimplemented above
-        return new ExcludeConfigBuildItem(DRIVER_JAR_MATCH_REGEX, NATIVE_IMAGE_RESOURCE_MATCH_REGEX);
+    void excludeOracleDirectives(BuildProducer<ExcludeConfigBuildItem> nativeImageExclusions) {
+        // Excludes both native-image.properties and reflect-config.json, which are reimplemented above.
+        // N.B. this could be expressed by using a single regex to match both resources,
+        // but such a regex would include a ? char, which breaks arguments parsing on Windows.
+        nativeImageExclusions.produce(new ExcludeConfigBuildItem(DRIVER_JAR_MATCH_REGEX, NATIVE_IMAGE_RESOURCE_MATCH_REGEX));
+        nativeImageExclusions
+                .produce(new ExcludeConfigBuildItem(DRIVER_JAR_MATCH_REGEX, NATIVE_IMAGE_REFLECT_CONFIG_MATCH_REGEX));
     }
 
     @BuildStep
diff --git a/extensions/jdbc/jdbc-oracle/deployment/src/test/java/io/quarkus/jdbc/oracle/deployment/RegexMatchTest.java b/extensions/jdbc/jdbc-oracle/deployment/src/test/java/io/quarkus/jdbc/oracle/deployment/RegexMatchTest.java
index 5a66b4d51b2..8bef768890a 100644
--- a/extensions/jdbc/jdbc-oracle/deployment/src/test/java/io/quarkus/jdbc/oracle/deployment/RegexMatchTest.java
+++ b/extensions/jdbc/jdbc-oracle/deployment/src/test/java/io/quarkus/jdbc/oracle/deployment/RegexMatchTest.java
@@ -26,20 +26,33 @@ public void jarRegexIsMatching() {
     }
 
     @Test
-    public void resourceRegexIsMatching() {
-        //We need to exclude both of these:
+    public void nativeImageResourceRegexIsMatching() {
+        //We need to exclude this one:
         final String RES1 = "/META-INF/native-image/native-image.properties";
-        final String RES2 = "/META-INF/native-image/reflect-config.json";
         final Pattern pattern = Pattern.compile(OracleMetadataOverrides.NATIVE_IMAGE_RESOURCE_MATCH_REGEX);
 
         Assert.assertTrue(pattern.matcher(RES1).find());
-        Assert.assertTrue(pattern.matcher(RES2).find());
 
-        //While this one should NOT be ignored:
-        final String RES3 = "/META-INF/native-image/resource-config.json";
-        final String RES4 = "/META-INF/native-image/jni-config.json";
+        //While these should NOT be ignored:
+        final String RES2 = "/META-INF/native-image/resource-config.json";
+        final String RES3 = "/META-INF/native-image/jni-config.json";
+        Assert.assertFalse(pattern.matcher(RES2).find());
+        Assert.assertFalse(pattern.matcher(RES3).find());
+    }
+
+    @Test
+    public void nativeImageReflectConfigRegexIsMatching() {
+        //We need to exclude this one:
+        final String RES1 = "/META-INF/native-image/reflect-config.json";
+        final Pattern pattern = Pattern.compile(OracleMetadataOverrides.NATIVE_IMAGE_REFLECT_CONFIG_MATCH_REGEX);
+
+        Assert.assertTrue(pattern.matcher(RES1).find());
+
+        //While these should NOT be ignored:
+        final String RES2 = "/META-INF/native-image/resource-config.json";
+        final String RES3 = "/META-INF/native-image/jni-config.json";
+        Assert.assertFalse(pattern.matcher(RES2).find());
         Assert.assertFalse(pattern.matcher(RES3).find());
-        Assert.assertFalse(pattern.matcher(RES4).find());
     }
 
 }