diff --git a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/SerializedApplication.java b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/SerializedApplication.java index a1f6c2201fa58..97c29b116a536 100644 --- a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/SerializedApplication.java +++ b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/SerializedApplication.java @@ -57,7 +57,7 @@ public static void write(OutputStream outputStream, String mainClass, Path appli data.writeUTF(mainClass); data.writeInt(classPath.size()); for (Path jar : classPath) { - String relativePath = relativize(applicationRoot, jar).replace("\\", "/"); + String relativePath = applicationRoot.relativize(jar).toString().replace("\\", "/"); data.writeUTF(relativePath); writeJar(data, jar); } @@ -226,12 +226,4 @@ private static void writeNullableString(DataOutputStream out, String string) thr } } - private static String relativize(Path applicationRoot, Path jar) { - Path relative = applicationRoot.relativize(jar); - if (relative.getName(0).toString().equals("..")) { - throw new RuntimeException(jar + " was not present in application " + applicationRoot); - } - return relative.toString(); - } - } diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/JarRunnerIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/JarRunnerIT.java index fb762ac153ec2..e7d02ccfb60ae 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/JarRunnerIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/JarRunnerIT.java @@ -93,12 +93,22 @@ public void testThatFastJarCustomOutputDirFormatWorks() throws Exception { @Test public void testThatMutableFastJarWorks() throws Exception { - File testDir = initProject("projects/classic", "projects/project-classic-console-output-mutable-fast-jar"); + assertThatMutableFastJarWorks("providers", "providers"); + } + + @Test + public void testThatMutableFastJarWorksProvidersDirOutsideOutputDir() throws Exception { + assertThatMutableFastJarWorks("outsidedir", ".." + File.separator + "providers"); + } + + private void assertThatMutableFastJarWorks(String targetDirSuffix, String providersDir) throws Exception { + File testDir = initProject("projects/classic", + "projects/project-classic-console-output-mutable-fast-jar" + targetDirSuffix); RunningInvoker running = new RunningInvoker(testDir, false); MavenProcessInvocationResult result = running .execute(Arrays.asList("package", "-DskipTests", "-Dquarkus.package.type=mutable-jar", - "-Dquarkus.package.user-providers-directory=providers"), Collections.emptyMap()); + "-Dquarkus.package.user-providers-directory=" + providersDir), Collections.emptyMap()); await().atMost(1, TimeUnit.MINUTES).until(() -> result.getProcess() != null && !result.getProcess().isAlive()); assertThat(running.log()).containsIgnoringCase("BUILD SUCCESS"); @@ -113,7 +123,7 @@ public void testThatMutableFastJarWorks() throws Exception { Assertions.assertTrue(Files.exists(jar)); Path providers = testDir.toPath().toAbsolutePath() - .resolve(Paths.get("target/quarkus-app/providers")); + .resolve(Paths.get("target/quarkus-app/" + providersDir)); Assertions.assertTrue(Files.exists(providers)); File output = new File(testDir, "target/output.log");