From 552ca56f4eb8779e493d48d2c5a670d8a9ad7201 Mon Sep 17 00:00:00 2001 From: Pedro Igor Date: Tue, 7 Jul 2020 10:10:40 -0300 Subject: [PATCH] Allow user-providers-directory outside the output dir --- .../bootstrap/runner/SerializedApplication.java | 6 +----- .../test/java/io/quarkus/maven/it/JarRunnerIT.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) 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 a1f6c2201fa589..9b9d61a74be612 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 @@ -227,11 +227,7 @@ 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(); + return applicationRoot.relativize(jar).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 fb762ac153ec28..0ab59d53385f41 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,21 @@ public void testThatFastJarCustomOutputDirFormatWorks() throws Exception { @Test public void testThatMutableFastJarWorks() throws Exception { + assertThatMutableFastJarWorks("providers"); + } + + @Test + public void testThatMutableFastJarWorksProvidersDirOutsideOutputDir() throws Exception { + assertThatMutableFastJarWorks("../providers"); + } + + private void assertThatMutableFastJarWorks(String providersDir) throws Exception { File testDir = initProject("projects/classic", "projects/project-classic-console-output-mutable-fast-jar"); 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 +122,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");