Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user-providers-directory outside the output dir #10538

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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