Is it possible to use symbolic links in asset paths?

Hello folks,

I have a folder of assets that I’d like to be able to include in multiple projects for prototyping purposes without copying them to each one. I’m using Linux (Ubuntu), so my immediate instinct is to create a link to the shared assets folder inside of each project’s individual assets folders. However, I’ve run into the following exception:

com.jme3.asset.AssetNotFoundException: Asset name doesn't match requirements.
"/home/NAME/Documents/Gamedev/JMonkeyProjects/PublicAssets/Suzanne.glb" doesn't match "/home/NAME/Documents/Gamedev/JMonkeyProjects/TestingGrounds/assets/PublicAssets/Suzanne.glb"

The error here is interesting, because most applications generally treat a sym-linked path on Linux as if it were the literal path of the file, but it’s clear that I can’t do anything in user-land about it. Is there a work-around for this type of thing, or should I just stick to copying my test assets into each project? (It’s fine if that’s the solution, but I’d like to look for a workaround if there is one). Thanks!

Another solution would be to add your shared assets folder to the classpath of each of your projects.

What fba says or alternatively the more “formal” solution: Create an asset-only project with a jar, and use that jar as dependency throughout the projects (or add that to the classpath).

It’s still an interesting error though, but I guess that’s due to the fact that absolute paths aren’t ever used but are relative to the Assets Roots

You can register a FileLocator that points to the shared folder

String devAssets = '/home/NAME/Documents/Gamedev/JMonkeyProjects/PublicAssets/';
assetManager.registerLocator(devAssets, FileLocator.class);    

or you can use a mount --bind

4 Likes