IntelliJ: How to set default working directory?

Brasch :

I'm a migrating user from Eclipse to IntelliJ.

Most of my projects contain a resource folder in the root of the project, which now in this case is a module:

enter image description here .

The fonts folder in the above directory is used by the code to load in fonts for use by the rendering. The problem is that in IntelliJ, the compilation target is the project folder itself, so the fonts aren't detected. You can get past this by manually editing the run configuration so that the working directory is in the module root.

My question is, can I somehow change IntelliJ to have this behavior by default for every project instead of having to manually do it every time? As in, by default, the target working directory for programs is always the root folder of the module the class is from.

Thanks in advance!

Andrey :

The problem is that in IntelliJ, the compilation target is the project folder itself

When building project/module, the IDE includes into compile classpath all files/sources from the folders which are marked as source/resource/generated source/test source etc type.

Also note that for the case of a Maven (Gradle) projects IDE takes configuration, including compiler configuration, from the Maven pom.xml files. By default Maven will not process (copy) resource files from the directory with sources. You need to explicitly configure it in pom.xml or move the resource files into folder that will be of a resource type.

Now about the main question:

...manually editing the run configuration so that the working directory is in the module root.

My question is, can I somehow change IntelliJ to have this behavior by default for every project instead of having to manually do it every time?

You can change the Run/Debug Configuration template

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=105447&siteId=1