-
Notifications
You must be signed in to change notification settings - Fork 6
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
Java 8 Compatibility #18
base: master
Are you sure you want to change the base?
Conversation
Oh, that might be a problem. Hmmm. |
Okay, it works now, I think |
@@ -220,16 +225,29 @@ public static void compileMmcZip(Path outPutDir, String gameVersion, LoaderType | |||
Path zipFile = outPutDir.resolve("Ornithe-" + gameVersion + ".zip"); | |||
Files.deleteIfExists(zipFile); | |||
|
|||
try (FileSystem fs = FileSystems.newFileSystem(zipFile, Map.of("create", "true"))) { | |||
// This is a god awful workaround, because paths can't be cleanly converted to URIs in j8, and for some reason, you can't pass parameters into newFileSystem with a path argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they can be converted, it's just
URI.create("jar:" + path.toUri())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work on windows, cause:
- Windows uses
\
, which is an illegal char. - Windows also has the drive name, which itself is illegal to have in a URI.
- I can't replace
\
with/
and then urlencode it, because it then encodes/
, which then breaks the path. - I can't just manually escape space and colon (the two main offenders of breaking path), cause the path component is still somehow undefined.
I love J8 path API on windows :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, path.toUri
on windows looks like file:///C:/path/to/file
on windows. and is a valid uri
and adding jar:
on the front makes FileSystems recognize it as a zip properly on java 8 as the scheme becomes jar:file:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still ends up at the exact same "path component is undefined" error.
So, massive disclaimer: I did this in like 30 minutes flat, and I took a bunch of shortcuts (static initializer spam go brrrr), so be aware that the code probably isn't as clean as it should be.
A few major(ish) notes to take into account:
MmcPackCreator.class
)tasks.compileJava.source/targetCompatiblity
for all versions of java, also sets the IDE java compat for you as well, which is nice.)I have tested the mmc pack and server and can confirm they're fully working.
I'm able to install the vanilla launcher one, but the crappy minecraft launcher doesn't work for me, so I can't test it.
If explanations are needed for anything I did, feel free to ask.