Migrated to the Gradle build system#126
Migrated to the Gradle build system#126itdelatrisu merged 3 commits intoitdelatrisu:masterfrom Lemmmy:lemmmyfixes
Conversation
|
I'll try this when I get home -- thanks for the thorough explanations! The build file really does look a lot simpler than the current pom.xml... Do you mind reverting 3a751a2 and squashing, or making a new pull request? You deleted and re-added a bunch of files there (not sure if you noticed). Also, I appreciate the cursor animations, but could you put that in a different PR too? xD |
|
Sure, give me a minute
|
|
I may have caused a few issues, such as your commit now appearing as mine, can you let me know if that's what you wanted? Also I'm not sure how to remove the cursor animations without making another commit in this branch, let me know. |
|
Okay, finally got a chance to try this out; it mostly looks good. Comments:
Less important things:
Questions:
|
|
Something is weird about those, but I'll get to work eh
i'll do
|
|
Let me know if there's anything you'd like me to help with! |
|
Yeah, that's the right place. I can't find anything in the pom.xml that creates a version. Can you tell me where it fetches the properties from, especially the |
|
The raw file is res/version. There are two relevant sections in the pom: |
|
Ah, this is something I can fix then. Give me a second |
|
Also, let me know if resources work on this new commit |
|
It still isn't. I'll also look into why it isn't working on my end... |
|
I cleaned my build directory and now I'm getting the same result, so it's reproducible. Looking into this now. Edit: Fixed it locally, just adding version now. |
|
Let me know if the gradle works now, I have everything working on my end. |
|
Okay, will try it in a moment. Alternatively, I got it working by adding this line under |
|
I've removed the |
|
Yeah, I see. I'm getting this when I try to run the jar: |
|
I got a completely different error: Just gonna quickly try a clean then re-run edit: I think I know the problem. The resources are in edit2: This is not the case. (and yes, there is no ! in the directory name) edit3: okay, I have a feeling that @Version@ is being replaced in the icon png somewhere, so I'm gonna try changing their names |
|
Unrelated, but to fill in the remaining parts of pom, a few last changes:
Looking into my exception now... |
|
Right, that should hopefully fix both of our exceptions, give me a min to test |
|
Okay, odd, the jar executes fine now (without applying any other changes). The temporary natives folder isn't deleted when I close the program, though. |
|
Hmm, seems that |
|
I'll look into it in a moment. I noticed that when running a jar generated by JarSplice, only the natives for the current OS are extracted to the temporary folder; your native loader extracts all of them. |
|
Yeah, that was part of my "I give up" debugging, let me quickly fix that |
|
Yeah, probably (backup and) squash everything at the end, not now. Honestly, if we just take the native loader from the JarSplicePlus project I've been working from, everything should be fine: https://github.com/itdelatrisu/JarSplicePlus/blob/master/src/org/ninjacave/jarsplice/JarSpliceLauncher.java |
|
Yeah, that's what I've been referencing (except I had to change the first method, like we don't need to run a new jar, just setting the classpath works) |
|
You aren't calling |
|
Got it. I'll add a shutdown hook that calls |
|
Okay, it almost worked... seems like |
|
What exception was thrown? |
|
None, the files were probably locked. |
|
Okay, is that a change I need to make in this last commit? |
|
You should merge my last commit from |
|
No, you don't need to make the change; I can do it later. |
|
Okay, let me just finish up here, merge and rebase. My JDK just disappeared so I can't test the native loader, but it's identical to yours so it should be okay. |
|
There, knocked out the billion commits. Does that look good? |
|
Yup, and everything seems to be working. Is this ready to be merged? |
|
Go ahead! If you want me to update the readme prior to that, I can. |
|
Sure, if you want (though I might edit it later as well). |
|
Right, should I squash that commit too? |
|
No, don't bother. |
|
Got it, give me a min then |
|
Go ahead and merge! |
|
Great, thanks! One last thing from that commit, the |
|
Oh yep, sorry, I have less memory than my nokia phone |
|
No problem. :P Thanks so much for working on this with me and making this relatively painless. I'll try to get any follow-ups with this done later today (only fixing XDG, I think...). (I'm glad we don't need JarSplice anymore, too. XD) |
|
Awesome! And yeah, I've had endless problems with jarsplice in my lifetime, this native loader should be reusable in other projects too, which is nice. |
Added Gradle build system, removed JarSplice from build cycle.
|
By the way, please make another PR for your cursor animations when you're free. xD |
|
LOL |
|
Oh yeah, I forgot to PR that, I finished those earlier |
|
I'll also make another PR for my hi-res textures when I have a decent set of them. I'll continue working on those now. Check #127. |
|
I'm not sure how I feel about adding HD images since it'll really increase the loading time/memory usage/file size. Maybe just as a separate download... |
- Fix the XDG directory flag that got removed with JarSplice. To enable XDG directories, set the 'Use-XDG' property in either build file to 'true'. - Always re-build jars in the Gradle script (disable "up to date" for the task). - Delete JarSplicePlus.jar since it's no longer being used. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
It took a while, but I've migrated the project to Gradle. IntelliJ has built in support for gradle, I'm not sure about Eclipse but it probably does.
IntelliJ Usage
To use this in IntelliJ, you first need to reopen the project.
File -> Open, then navigate to thebuild.gradlefile and simply open that. Next, make sure that you have selected a validJAVA_HOMElocation and you can optionally enableAuto importif you don't want to have to rungradle buildevery time the build file changes. Click Next or Finish or whatever.The project will sync for a few minutes, and the structure will change a few times during this process. Don't panic, it should work when the import is over. Next, go into
Run -> Edit Configurationsand click the green +, chooseGradle. Name the configurationrun, set the Gradle Project to thebuild.gradlefile, and set the task torun.Next, you need to unpack the LWJGL natives. You will only ever have to do this once, unless you clean the project or delete the target folder. In the gradle panel on the right of the screen, double click
opsu -> Tasks -> other -> unpackNatives. It should take a few seconds to unpack the natives, and that is all. You can now run the project.Finally, to compile a fat jar, you can run the
build -> buildtask. It will build totarget/libs/opsu-(version).jar.Eclipse usage
I'm not too sure about Eclipse usage, but it should be as simple as importing the
build.gradlesimilar to above, and running the tasks.Gradle tasks
unpackNativesUnpacks the LWJGL natives from the jar and places them in
target/nativesrunBuilds and runs the project
buildBuilds the project and produces a fat jar containing the libraries and natives.
NativeLoaderis a class that works similar to the JarSplice launcher - it looks for top leveldll,so,jnilibanddylibfiles inside the jar and extracts them to a temporary directory, which is finally set as the classpath.You can run a gradle task in the CLI by running
gradle <task>.build.gradle explanation
The gradle file is initially a bit complicated, but it's actually pretty simple.