Hello Guest

Include linux sources on Windows

  • 8 Replies
  • 6628 Views
Include linux sources on Windows
« on: December 05, 2017, 21:51:24 »
Hi All,

maybe this is just my lack of understanding of how Maven works, but when exporting my LWJGL game as a runnable jar (from within Eclipse), it only contains the windows-native jar files.

Everything works fine on Windows (game runs) and I can package everything together with Packr; game works fine.

The POM file I am using is the standard one from the LWJGL download page: including in the profiles section both windows and Linux.
Within Eclipse I have tried enabling the windows profile only, Linux profile only, both, and all permutations of project clean, mvn clean, package, install -and removing all packages from my .m2 folder to force a redownload.

I noticed that the 'maven dependencies in the Package-Explorer only (see attachment) Furthermore, it seems my maven .m2 repositories folder is also missing the Linux natives.

I guess I am just missing a flag somewhere, can anybody help me?

Thanks all

*

Offline KaiHH

  • ****
  • 334
Re: Include linux sources on Windows
« Reply #1 on: December 05, 2017, 22:22:35 »
Using the pom.xml file it is not possible to have all OS'es natives included in your build path, since the individual profiles will overwrite the single lwjgl.natives property and the last one wins (you'll notice this when you just change the order of the profiles while having all profiles activated - i.e. in Eclipse's Maven project settings).
If you want to have all OS'es native jars in your build path using Maven, you must include them explicitly as dependencies three times.

I guess a better way for LWJGL to allow multi-OS-capable pom.xml files would be to use dependency elements in each profile with the respective natives-windows/linux/macos natives generated per profile/OS and not set a single property evaluated in the root dependencies. OS-enabled profile activation can still be used for the OS Maven is running on, but explicit -P overrides in Maven would allow for multiple profiles/platforms to be active and have their native jars included.
« Last Edit: December 05, 2017, 22:32:39 by KaiHH »

Re: Include linux sources on Windows
« Reply #2 on: December 06, 2017, 17:34:18 »
Hi KaiHH,

Thanks a lot, shuffling the profiles around within the POM works.

Cheers

*

Offline KaiHH

  • ****
  • 334
Re: Include linux sources on Windows
« Reply #3 on: December 06, 2017, 20:11:37 »
This was obviously not my point at all, and is also not a "solution". Sure, if you _only_ want it to work on Linux you can simply delete/remove the windows and macos profile elements.
A general solution would be to use <dependency> elements inside each profile with the correct platform natives declared in them for that respective platform.

Re: Include linux sources on Windows
« Reply #4 on: December 07, 2017, 11:22:51 »
Yes ok, but surely this solution would be better off added to the maven script on the LWJGL download page? After all, if you select to download multiple natives/platforms, then presumably you'd want to also export those natives at some point.

I don't know enough about maven to make any elegant solution, and as shuffling the profiles around in the POM enables me to at least get a working version out, this will do for now.

Do you happen to have an example on-hand of how a profile might look for say Windows (then I could adapt it for the other platforms)?
« Last Edit: December 07, 2017, 11:25:21 by Lintfordpickle »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Include linux sources on Windows
« Reply #5 on: December 07, 2017, 12:06:42 »
The Maven/Gradle scripts are not meant to be used when creating a production build or installer for an application. There is no standard way to support that, so it's not supported. It is recommended to use a ZIP bundle or download the files directly from the LWJGL server (a file browser is available).

*

Offline KaiHH

  • ****
  • 334
Re: Include linux sources on Windows
« Reply #6 on: December 07, 2017, 18:35:20 »
If you must build a standalone jar file for all platforms using Maven, please read this: https://maven.apache.org/pom.html
As I said, you need to declare all platform-specific dependencies (the native jar files) as dependencies inside each profile. The Maven documentation tells, how. This is really not at all rocket science. Then you probably also want the Maven Shade Plugin to produce a single standalone jar file with everything in it.

If you don't have knowledge about Maven and also do not want to learn it (i.e. figure it our yourself), then the question arises why you want to use Maven for it in the first place.

Re: Include linux sources on Windows
« Reply #7 on: December 09, 2017, 12:26:50 »
The Maven/Gradle scripts are not meant to be used when creating a production build or installer for an application. There is no standard way to support that, so it's not supported. It is recommended to use a ZIP bundle or download the files directly from the LWJGL server (a file browser is available).

Thanks for the link.

It is a recommended practice to download the LWJGL libs once and develop/ship always against the same version (i.e. freeze LWJGL while developing now to 3.1.5 and finally release a game with 3.1.5), or would it be possible/recommended to have the installer download the latest LWJGL packages when a user installs the game?

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Include linux sources on Windows
« Reply #8 on: December 09, 2017, 12:40:03 »
My recommendation: develop against the latest official release, or latest snapshot if you don't mind minor disruptions. When it's time to deploy your application, freeze to the latest build that has been verified to work. Repeat for each update of your application.

Do not depend on Maven or the LWJGL servers for downloading LWJGL. There is no guarantee that they'll be fast enough or even available when the application is installed. Always bundle LWJGL in the application.