How to configure resources root for web project in IntelliJ IDEA - intellij-idea

I am working with a project with a single "Static Web" module in IntelliJ IDEA 13.1.4 with the PHP plugin (NOT PHPStorm).
Given the following directory structure:
-ProjectX
--application
--www
I marked the "www" folder as "resources root". The "ProjectX" folder is the "content root".
HTML references to resources are correctly resolved only in files from within the "www" folder, not when the "application" folder. Annotated screenshots:
This works in PHPStorm, but not IntelliJ IDEA. How do I get the desired behavior in IntelliJ so references will resolve from all project folders?

After playing with it for a while, I may have a solution.
It appears that BOTH "ProjectX" and "www" have to be marked in order for this to work. If you first mark "www" as a resources root, and THEN mark the parent/content-root folder as a resources root, the reference will resolve.
If this was obvious to anyone out there, please explain. Or is there a more appropriate solution?
SCREENSHOT:

Related

How to make IntelliJ understand the Next.js `public` directory structure?

I am using IntelliJ to edit a Next.js website.
IntelliJ IDEA 2020.2.1
Next.js 9.5.3-canary.23
Next.js static file serving uses a /public directory as a container for static assets, but when publishing a Next.js site, the contents of the public directory are hosted at the root of the site.
So, as shown in the linked doco, an image that exists in the codebase at /public/my-image.png is addressed by an URL path of src="/my-image.png".
This confuses IntelliJ and it shows a warning that it can't resolve the directory of the img src:
I tried marking the /public directory as a "Source root" or a "Resources root" - but that didn't make the warning go away.
I also tried adding the /public directory as a "Content root", but IntelliJ doesn't want to do that because it overlaps with the root directory of the module, which is already a content root.
Is there any way to tell idea to look in the /public directory for statically referenced assets like this?
I've had the same problem. In my case, "Mark Directory as > Resource Root" worked well.
Before...
Right click ./public. Then Mark Directory as > Resource Root
After...
Image loads.

IntelliJ IDEA - Directories appearing in Project Files but not in Project

So I created an empty project, but when I create a new directory in the Project window, it does not show up. The directory is actually created, and if I navigate to the Project Files list I can see it there, but as far as I can tell there is no way to make even my src folder part of the actual project. This creates all kinds of problems when I have to move/refactor files, and I'm amazed that something so common and simple is so difficult.
You've created a folder, not a package. If ur using maven or grade, can I suggest u use them to generate an intelij project for you. The command escapes me but a quick Google should tell you
You can manually mark your directory as a sources root:

resource not found when using IntelliJ

I have a resource abc/xyz.json under src/test/resources. I'm using IntelliJ IDE.
While running a Test for my project, I get the following exception.
Exception
com.google.common.io.Resources.getResource("abc/xyz.json")
fails with java.lang.IllegalArgumentException: resource abc/xyz.json not found.
The Test runs fine with gradle clean build and eclipse
Try marking your src/test/resources folder as Test Resource Root. Attach is the image on how to do it.
Let me know if you need any other information.
Make your resource folder a Test Resource folder, if this does not fix the issue then, close your project, delete target folder and open the project. Hope this helps.
Had the same issue not that long ago, since Intellij outputs the class files into out/production/{project_name}, that path will not start in the src directory but will start in the out/production/{project_name} directory.
It will however see files that are in the project root directory, I'd recommend moving your resource directory into the main project directory then accessing the file with "resources\${FILE_NAME}".
Sometimes I have the same problem, though the folder is marked as resource root. So what I do: I just Unmark it and then mark it as resource root again. Sometimes I need to do it several times and it works. But anyway I think it is Intellij IDEA bug.

Show directories Intellij Idea

All at once directories became invisible. What is wrong with my project?
How to get IntelliJ IDEA to display directories?
That didn`t help. I need to change something in settings, but I don`t know what exactly.
It will happen, when .idea folder is deleted or conflicted.
The best way is create new project, so .idea folder will create & all will work fine.
I have also faced same probel, when .idea folder is conflicted or deleted.
To easily create a module for your project and therefore show the folder structure -
Go to File menu -> New -> Project...
Select Static Web. Note: it does not matter if your project is "web" or not!
Hit next, then fill in the same Project Name: and Project location: as you have already.
IntelliJ will say "File Already Exists" - "Would you like to overwrite it?" - answer Yes.

How to force IntelliJ to use a different home folder

I have a computer with two hard drives. In the first one, an SSD disk, I have Windows partition (C) and on the second one (D), a raid volume, I install all the programs. I also moved my user folders (desktop, documents, downloads, pictures and videos) to D:/Users/David.
After installing IntelliJ Idea on D:/Program Filles(x86) a .IntelliJIdea13 directory appeared on D:/Users/David. No problem with this as all was working nice. Then I installed Scala plugin, created a new SBT project and build it. After this, the .sbt directory used by SBT was in C:/Users/David/.sbt but the references to the libraries in my project are pointing to D:/Users/David/.sbt. The question is, how can I force IntelliJ Idea or Scala plugin to download the libraries to D:/Users/David.sbt?
Not 100% sure if this can be a solution, you can change the HOME folder of Intellij IDEA. Look for the folder where the idea executable is. In Linux I have on
~/applications/idea13/bin
On Windows you can check the properties of the menu item. There should be file idea.properties that contains the home folder location of the idea files.
You can find more information here that describe more details:
Locations can be changed by editing the following file:
IDE_HOME\bin\idea.properties
Follow the comments in idea.properties file to change the defaults,
make sure to un-comment the lines defining these properties:
idea.config.path
idea.system.path
idea.plugins.path
idea.log.path
On the other hand you can change the location of your project to D:/Users/David. you should also have a look inside the project folder, there should be a .idea folder with has a library directory. They contains the location of the libs used in the project with their paths.
As dawez allready answered, you should edit idea.properties to set config, system, plugins and log paths.
But if you want to change the user.home path, then you must edit idea.exe.vmoptions file. Just add the following at the end of the file:
-Duser.home=your_new_user_home_path
If you use idea64.exe then you should edit idea64.exe.vmoptions file.
JetBrains had added complete set of features to support such a case and this is described here:
Changing IDE default directories used for config, plugins, and caches storage