IntelliJ IDEA does not recognize JAVA source directory - intellij-idea

Recently I imported the source code of Flink, but IDEA did not recognize the JAVA source directory, resulting in the failure of normal compilation and reading. I found that the generated .Iml file does not contain the JAVA source directory, I can manually mark the source directory. Flink's module has 188+, manual mark is too difficult, what should I do? Thank you
Pictures are as follows

You can try to do:
Close the project File | Close Project
Close the IDE.
Open the project directory in File Explorer and delete all .iml files and the .idea directory.
Re-import the project into IntelliJ from Existing sources.

Related

How to fix a broken Intellij Idea?

When I open an existing Maven project, the IDE shows only those files on the root directory, but not any directories in the project. After a while, the IDE will show the project as what it is in the file structure, but not the directory types such as source code, test when I reopen the project. I reinstall the community edition, but the problem still resists. I have experienced the same issue for a few Java projects lately.
How to resolve this issue?
1, Please ask another teammate to check if that project really works. Sometimes the application structure already broken, then it is not your local problem.
2, There is a .idea folder in the application, delete it. Or simply, you git clone a new place Important: Please notice if you have edited / created some new files in the original directory, otherwise you would lost them if you delete the application.
3, Open intellij, and File -> Invalite caches
Personally, the second point is recommendated.
Try to click on Reload All Maven Projects in Maven tool window:
If it doesn't help you can try to perform the following actions:
Close the project with File | Close Project.
Close the IDE.
Open your project in OS file manager and remove all .iml files and the .idea directory.
Reimport the project.
If the problem remains contact JetBrains support and attach a compressed log folder along with the project structure tree.

open a directory with intellij without creating a project

I want to be able to open a directory with intellij without creating a project.
how to do it?
every time I open a folder, a project is automatically created with an .idea folder
When you use the Intellij IDE to open a directory,
It assumes that you are going to open a project (as it is the main reason to use IDEs). By default all of jetbrains's IDEs put the project specific settings for project in the .idea folder.
It is also safe to delete it if you are just opened a directory. There would be no problem in deleting this.
You can also use Terminal tab to change or open a directory (Alt+F12)
and use terminal commands to traverse between directories without creating any .idea folder.

IntelliJ Open module from desktop

I have been using IntelliJ sparingly for the last six months and one thing always puzzles/annoys me.
Each module of IntelliJ has a .iml folder in it's root. This .iml file is clearly recognized by IntelliJ it the file extension is associated with it during install.
Clicking on this .iml file I would expect the module to open up in IntellJ in the most recent project space. However, IntelleJ does not seem to want to do this, it has a popup saying the following.
Cannot open file:
No project to open file in.
So why can't intelliJ just open the module in the most recently used project space. Instead I have to go to great lengths to open a project space and then import the project which is so unproductive. Often I have to look open and inspect several projects an hour and as is, the process is onerous.
Am I missing something, or is there really no way to open projects directly from the desktop/file explorer?
Click the file which has .ipr extension to open it in intellij, and you can see it in the most recent project space after it is opened.
The *.iml file describes modules. It includes module paths, dependencies, order settings, etc. A project may contain multiple *.iml files.
The *.ipr file stores settings related to a project in general, for example, paths to modules and module libraries, compiler and configurations, entry points, etc.
You can find more detail in IntelliJ IDEA Web Help

How can I clone a whole project in IntelliJ Idea?

I want to run some tests in my project but I do not want to affect the
original code, and I wanto to clone the project so I can run tests there
Does anyone know how to clone a project on IntelliJ Idea 11?
Using your operating system File Explorer tool, just copy and paste the entire project directory somewhere new. All of the configuration should use relative paths by default.
If your IDEA project is .ipr based, then delete the new .iws file before opening the project.
If your IDEA project is .idea directory based, then delete the workspace.xml file before opening the project.
If you want to copy and rename the project too, like I wanted to clone a project in order to use it with a newer version of IntelliJ.
Copy the whole directory to a new location, for example on Linux:
cp -r myproject new/location/
To rename the project:
2.1. rename the project folder (e.g. mv myproject newproject)
2.2. get into the new project folder (e.g. cd newproject) and edit the .name file with a text editor.
Open the new project now in IntelliJ (you may want to remove the workspace.xml if you don't want to keep the open file history - I kept it) and enjoy your new project!
For copy with rename I had to do one more step to get it to stop referencing the old module name. That was to right click on the module in the project pane and do Refactor > Rename ( or do Shift + F6 ) to rename the module.
This was for IntelliJ IDEA 2016.3.3
I had a gradle project and the provided answers did not work. The project did not have a structure in IntelliJ and I did not see the source files.
The following worked:
Export project (Export to zip file)
Move the zip file somewhere new
Unzip
With IntelliJ, import as a new project with "open".
Better Solution of course:
Have it in a git directory, make a "test-branch" and try whatever you want to try.
Apparently the accepted answer doesn't work anymore with current versions of Idea and the many derived IDEs (I tried this with PHPStorm). The problem: most of the config files are located in the .idea subdirectory of your project, but the file .idea/workspace.xml also contains the ProjectId, and that should of course be unique. So, if you copied the project directory manually, the easiest fix is to change the ProjectId - from what I have seen you can enter any alphanumeric string, e.g. "ProjectId123".
As far as I can see the main settings that are stored under the ProjectId are the workspace settings, under ~/.config/JetBrains/[IDENameAndVersion]/workspace/[ProjectId].xml. This file mostly contains the open editor tabs (with paths relative to the project directory) and the tool windows, so if you copy the project directory, you will always have the same editor tabs open in both projects (containing the "same" files, but from the respective project). If you want to avoid opening all files and setting up the tool windows, you can copy the old [ProjectId].xml file to e.g. ProjectId123.xml (using the ProjectId that you entered earlier).
After Copying your existing Project to a new folder don't forget to mark your src directory as Source directory. You can do this under Project Structure | Modules.
To duplicate and rename a CLion cmake project I followed the info in the other answers with some tweaks.
What seems to be the stepless way to eliminate all references to the old project name in the new one (tested with CLion 2019.1.2):
Copy folder
rename the new folder
On the new project folder:
delete the project info folder (CLion will recreate it):
<new project name>/.idea
On a text editor, open:
<new project name>/CMakeLists.txt
change every reference to the old project name with the new name and save it.
This will assure CLion will not use Project and Target info in "CMakeLists.txt" file to recreate project files and data in ".idea" folder with the old name.
Note that other info in this file referencing the old project folder, or files stored there, such as INCLUDE, SOURCE directories, and files, should also be changed to point to the new folder.
delete old compile data. Delete folders like:
<new project name>/cmake-*
Open project in CLion
It should have the new name and no reference to the old name anywhere.
If using CSV, you may also wish to delete old CSV data
EDIT: If project requires CUDA, CUDACXX environment variable must be reassigned to full path of nvcc compiler:
File->settings->Build, Execution, Deployment->CMake->Environment
IF CLion CUDA Run Patcher is installed it maybe needed to restart CLion.

IntelliJ Idea - resource SQL files not being copied to target

I have some problems with IntelliJ Idea not copying SQL resource files into target directory, so I have to copy them there manualy.
I have SQL reosurce pattern in project's compiler settings.
I have standart structure maven project - with /etc/ folder holding property files which gets copied without problem. /etc/ folder holds /sql/ folder which i need to be copied as well, but it gets not copied at all. /etc/ folder is set as source folder.
My folder structure:
-etc
-conf
-sql
-src
-main
-test
This should work fine, but could be a bug specific to your configuration. Could you please submit an issue with a sample project and pom.xml?