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

Load scriptFile from filesystem first #13

Merged
merged 2 commits into from
Apr 20, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/org/skife/waffles/ReallyExecutableJarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,15 @@ private void makeExecutable(File file)

if (scriptFile == null) {
out.write(("#!/bin/sh\n\nexec java " + flags + " -jar \"$0\" \"$@\"\n\n").getBytes("ASCII"));
} else {
}
else if (Files.exists(Paths.get((scriptFile)))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have an extra pair of () here.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just pushed the removal of said parens!

getLog().debug(String.format("Loading file[%s] from filesystem", scriptFile));

byte[] script = Files.readAllBytes(Paths.get(scriptFile));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is different from the code below for the file in the classpath, is that intentional ? Specifically, the code below requires the file to be ASCII.

out.write(script);
out.write(new byte[]{'\n', '\n'});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also use this below (and make the byte array a constant) ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about that, went for the minimal change at first pass as I do not grok why the force into String and then back to bytes in the below code. Leaving intact to minimize scope of this bugfix, will then g o clean up.

}
else {
getLog().debug(String.format("Loading file[%s] from jar[%s]", scriptFile, original));

try (final URLClassLoader loader = new URLClassLoader(new URL[]{original.toUri().toURL()}, null);
Expand Down