Skip to content
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

ProjectAssetManager doesn't load resources from dependency Jar files in Gradle projects #373

Closed
peedeeboy opened this issue Aug 26, 2022 · 9 comments

Comments

@peedeeboy
Copy link
Contributor

peedeeboy commented Aug 26, 2022

As mentioned by @yaRnMcDonuts in #305 :

Yes I notice that as well. The drop down menu contains all my own shaders located in my projects assets folder, but none of the MatDefs from dependencies such as JME core or Terrain.

I am also noticing that the material editor begins to work again with my GradleTemplate based project when I open up a material using a MatDef from my assets folder, so I believe if this issue is resolved then it will also resolve the other issue with Gradle projects in the SDK where the visual Material Editor doesn't work for the stock Lighting.j3md and PBRLighting.3md MatDefs

This happens because the Materials Editor does two things:

  1. Scans for files in the project directory tree with a .j3m extension
  2. Defers to the ProjectAssetsManager to load dependencies from .jar files in the project

Part 1) still works, and will find .j3m files in the /assets folder/sub-project, but the ProjectAssetManager class is using NB's Java Project API to the files on the classpath, and its not returning the files for Gradle projects. ProjectAssetManager needs to be extended to be "Gradle-aware" and probably use NB's Gradle Java Projects API to locate the dependency .jars (after a priming build) in Gradle projects and load the materials from them.

This would probably fix a bunch of other things that are squiffy in Gradle projects, like the textures browser etc.

@peedeeboy peedeeboy changed the title ProjectAssetManager doesn't load resources from Jar files in Gradle projects ProjectAssetManager doesn't load resources from dependency Jar files in Gradle projects Aug 26, 2022
@tonihele
Copy link
Contributor

And then there is this, not maybe 100% related but:
WARNING [com.jme3.gde.core.assets.ExternalChangeScanner]: File is not part of a jME project but tries to find original model...

If I create a scene file to the Gradle template... It doesn't seem to understand it is a jME project or something....

@peedeeboy
Copy link
Contributor Author

If I create a scene file to the Gradle template... It doesn't seem to understand it is a jME project or something....

Yes - I noticed that. Similar, in that I think it is to do with the ProjectAssetManager, but I don't think directly related.

With SDK3.4, if I create a new Gradle project, the Asset node gets created in the Project view. This appears to be when the ProjectAssetManager then gets initialised. Opening Scenes etc. works in this new project.

But when Opening an existing project (or restarting SDK), the Asset node doesn't get created, and assets can't be viewed in the SDK.

My hunch was that if it were possible to fix the detection of the assets folder and creation of the Assets node, then opening Scenes / Models would start working again. I only had chance to have a cursory look through the code, and it seemed like it is simply looking for a folder called assets, so I'm not sure why it would be failing. Needs a proper look at some point...

@peedeeboy
Copy link
Contributor Author

I also did some experimentation at trying to get the classpaths out of NB's Gradle API, so that compiled jars could be classloaded to load assets from dependencies. No joy so far, every when trying to mimic NB's Gradle classpath tests 🤷

@neph1
Copy link
Contributor

neph1 commented Sep 11, 2022

I'm acquiring some knowledge around this when figuring out how and which icons are loaded. I'll keep a look out, too, and report back.

@tonihele
Copy link
Contributor

It would be super cool to get the kinks ironed out from the Gradle template to the SDK 3.5 release (slated for next month).

@peedeeboy
Copy link
Contributor Author

Progress!

Gradle_Texture_Browser

Very hacky progress though - and the Material editor, whilst listing out all the .j3md files, doesn't then load their parameters correctly 😢 Still a ways to go to fix this properly 👎

@neph1
Copy link
Contributor

neph1 commented Dec 30, 2022

Hmm, is this issue totally unrelated? #266
Because the fix works both on ant and gradle projects. Could we somehow do a similar fix for this issue?

@peedeeboy
Copy link
Contributor Author

Got the MatDef properties loading in the Materials Editor 👍 :
image

@neph1
Copy link
Contributor

neph1 commented Apr 4, 2023

Close?

@neph1 neph1 closed this as completed May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants