Including global files that exist outside of project root

We have a global folder that holds resources used by multiple web apps. Is there a way to inlcude these in a project (for code inspection, validation, etc) without having to create a folder and copying those resources into it? For example,

webroot
     /common
          //js
          //jsp
     /project1
     /project2

Project1 and project2 both draw resources from the common folder. Currently, I'm creating a new folder in, say the project1 structure so that IntelliJ can do code inspection/hinting. But this makes it seem like a common folder exists under project1 when it really does not.

1 comment
Comment actions Permalink

The "best practices" way of doing this would be to make the global files a separate project and add that project as a dependency to your other projects. This would mean you would need to build new versions of the global/common project and then update the version for it in the other projects as needed. But it would prevent a change being made for pone project breaking the other since you can control that by way of the version of the global project being used.

The next best thing would be to create a module (File > Project Structure > modules; Click the add icon and select new module) for the shared global files. Then add the module to both projects (File > Project Structure > modules; Click the add icon and select import module). You could just create the module in one project and add it to the other. Or create a third "Global/Common" IDEA project and add the module to the other two projects. If the common/global files are under a different version control system, you can configure that in the Version Control settings.

0

Please sign in to leave a comment.