Skip to content

Commit

Permalink
Merge pull request quarkusio#10538 from pedroigor/fastjar-work
Browse files Browse the repository at this point in the history
Allow user-providers-directory outside the output dir
  • Loading branch information
pedroigor authored Jul 8, 2020
2 parents 3bcc8d9 + a4ba151 commit 601aa53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit 601aa53

Please sign in to comment.