Maven Builds for different platforms

Hello! What is the current recommended way to build and package a game in JME? I remember there was a tool where platforms could be selected. Does this still exist?

I am thinking about creating a maven build for each platform I want to build for. Is this something anyone has tried?

Edit: To be more clear, I currently build a fat jar with dependencies using the maven assembly plugin, but that packs the natives for all platforms in the same jar. I am trying to figure out if there is a way to set the lwjgl properties in such a way that only the natives for the profile I am building will be included in the jar.

1 Like

It depends on how you’re writing your game. I believe the SDK has built-in options if I remember correctly. For gradle you would build a fatJar or shadowJar. Including the application plugin and setting a mainClassName would mean the jar can be double-clicked to start. I’m sure there’s a similar approach for other build tools.

I need more info on your motivation behind this. I’m unsure as to why you’d want to. There is a JmeSystem.getPlatform static method to find which OS is being run for example that may help, and you can set a specific renderer, too.

1 Like

My advice is to switch to Gradle. Just copy one of @pspeed repositories and tweak the settings to your liking.

1 Like

Same - I believe I saw in another thread that your background is with Unity, so I’m assuming that maybe you’re not as familiar with Java. Java has always treated compile-once-and-run-anywhere as sort of a holy grail - publishing for more than one platform at a time is typically seen as a benefit, not a bug. That’s a bit less true now if you’re building a modular JDK image and bundled runtime for each platform, however. Even in that case, I’d consider stripping out the natives for other platforms as unnecessary, especially since they’re typically bundled together in a single jar.

Actually, my main gig is enterprise java, so I am quite familiar with it :wink:
My experience is the main reason why I am evaluating a java based game engine. I have developed with XNA, Unity (C#), UE4 (C, C++) webgl and Python. As I am purely evaluating at this point, I am trying to understand as much as I can before jumping in head first.

As far as the build, I am looking for a clean way to build with the native dependencies cleanly. This really isn’t a big deal to me, I can distribute one fat jar for all platforms, but steam distributes for different platforms and it just seems cleaner to have the natives for specific platforms and thats it. In Maven I would normally use profiles for this purpose, but I don’t see any documentation on this for jmonkey. (I do see there is support in LWJGL libraries.

At the end of the day, it doesn’t REALLY matter if I build one all-platform jar or not, but it just seems cleaner for distribution to have separate builds, but that is more of a preference than a sticking point. Thanks everyone!

1 Like

Gotcha, glad to hear it. :smiley:

I definitely see where you’re coming from on it being a cleaner way to distribute. I can tell you that’s not a common route in jME-land, and off the top of my head I don’t see a way to do it short of doing some custom extraction and re-building specific jars with native libs in them. As I recall, jME’s bullet physics (just as an example), lump all natives into a single jar.

If you really want to go down that route, the bones are in this file.

I made my own for other reasons. But basically you would call these methods before you load the engine using the engine class loader.

Awesome! Thanks for the info! :+1:

For anyone interested, I ended up defining assemblies for use with the maven-assembly-plugin and exclude/include using filesets. This also allows me to create the jars for client/server with exactly what I want in each jar. I am pretty happy with this approach as it does exactly what I was looking for without the need for profiles. Thanks again for all the help with this!

1 Like