Referencing a file from multiple locations without getting multiple copies?

Hi friends,

This is ultimately a question on how to organize an IDEA project where multiple modules access the same JavaScript file while also avoiding having IDEA think that there are multiple copies of the file.

I'm working on an open-source JavaScript library. I have a directory with its .js files and a second directory that contains the source for a demo webapp: HTML, CSS, JavaScript, images, etc. This demo directory is standalone, in the sense that it contains .js files that are part of the demo and the open-source .js files. My problem is that I don't want to duplicate the open-source .js files--the originals in their own directory and a copy in the ./js subdirectory of the webapp. But, in my demo.html I want the <script> tag's src attribute to be "js/os/hibiscus.js"--just like you'd see in a webapp. I don't want the tag to be an absolute path to the open-source .js nor have a long redirection--../../../, etc.--which wouldn't work in a webapp anyway.

So, my first thought was to put a soft link in the demo's js directory that points to the "master" directory of my files. This lets my src attributes look like "js/os/hibiscus.js" or "js/os/hibiscus-views.js", etc. (FYI, Hibiscus is a thin MVC layer that sits on top of jQuery.) The problem is now that I have the softlinked js/os directory IDEA thinks there are two copies of the open-source files, even though both copies are actually the same file. Here's what my directory structure looks like. Each of the first-level children corresponds to a module in my project, the open-source files and the demo files.

     root
          demo
               css
               js
                    os --> a soft link to root/open-source
               other

          open-source

I tried saying that the link is not source--still had two copies. I even tried setting the link directory to "Excluded". This solved the duplicate file problem but now IDEA doesn't recognize the paths in the <script> tags' "src" attributes. I tried making a global JavaScript library for the open-source .js files but they then became "invisible" to <shift><cmd>+N file open and still could not be resolved in the <script> tab. I also tried configuring an external resource for each file. Same problem for the script tag.

For now I'm excluding the os directory from the demo module. IDEA only sees one copy of the .js files but my HTML files have multiple warnings for unresolved src attributes (of the form src="js/os/hibiscus.js", etc.). Any other ideas on how to structure project like this so I don't get duplicate files and IDEA can follow relative file paths?

Thanks,
Kevin

IdeaX-IU-103.59
OS X Snow Leopard

Please sign in to leave a comment.