have images, audio, svg, maps in one directory called media #5

Open
shirishag75 opened this Issue Jan 27, 2017 · 1 comment

Projects

None yet

3 participants

@shirishag75

Instead of all being put in ~/mars-sim/mars-sim-ui/src/main/resources/ it would be nice if the different directories i.e. audio, svg, maps and images are under /media directory. It might make it more easier to keep track of things.

@mokun
Member
mokun commented Jan 27, 2017

Hi shirishag,

Do you mean simply changing the directory name from /resources/ to /media/ ?

In Java, /resources/ is the default directory for media. We often call getResourceAsStream() or getResource() in loading media files.

e.g.

stage.getIcons().add(new Image(this.getClass().getResource("/icons/lander_hab64.png").toExternalForm()));

In mars-sim, we pretty much adopt the default hierarchy for a mavenized Java project in Eclipse

When you check out the codes in svn, you will find 5 modules (mars-sim-*) that are active and 1 module that are inactive (mars-sim-android).

Inside each module, we have the following 3 major sub directories :

  • src/main/java
  • src/main/resources
  • src/test/java

Inside src/main/resources is where we store the media files for each module.

Another thing I'd like to point out is that, after running maven packaging, somehow, the resources/ folder no longer exists by default inside the compiled jar file.

At a result, all the media files directly under the /resources/ directory end up moving to the root directory level of the jar file (If you unzip the jar, you'll see that.).

I don't know how to prevent this from happening yet. May be someone can figure out how to change the behavior of some maven plug-in so that it will be packaged in such a way that the /resource/ folder will be retained (or even rename it to /media/) while the mapping of all media files are kept valid.

-Manny

@mokun mokun added the enhancement label Feb 16, 2017
@mokun mokun added this to the 3.10 milestone Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment