Project root files not included?

已回答

Hi, 

This is not easy to describe... But I'm guessing quiet typical. My root project files are not included in intelliJ (for example the search CTRL+SHIFT+N) won't find them.

The project is layered quiet typically I guess:

The way I created the project was:

- new project from sources > select this main folder (so I would assume it's known by intelliJ)

- then add 2 modules for my web (angular based) and userservice (spring boot based) 

 

But they always end up being yellowish:

Is it not how I'm supposed to do this? Could you please advise on how to get these files into the project? 

0

Hello Sébastien,

Try recreating the project from existing sources (File | New | Project from Existing Sources..), only this time choose the pom.xml file as your source as suggested in the prompt. The appropriate project structure should be created automatically based on the pom content.

You may also want to double-check if the folder with your production code was marked as a Sources Root. If it wasn't, try re-importing the project by opening the Maven tool window (View | Tool Windows | Maven) and clicking on the reload button.

0

Hello Arina, thanks for the feedback.

I checked the link but the problem here is that these "root" files are outside of the module.

The userservice (so pom based) structure is imported correctly, the angular one is also imported very well. It's the root files, accessible for both (like readme, env, gitignore, dockercompose) which are not included

I checked the Sources Root page but I can't seem to do that either:

 

I also tried defining a scope, but I have the same issue there: I can't include something "higher" than modules... :(

0

Try creating a new empty module (File | New | Module) in the same project that will serve as a parent root, and then moving (Alt+drag&drop) the existing modules and rest of the files under that new module. That way, all files and folders will belong to a single project with a defined structure (parent_root_name.iml), and will be indexable and searchable.

0

Hi Arina,

Unfortunately that will move the files effectively down in the file structure, while these need to remain at the top (for example .gitignore which is not going to be effective if moved down, or files needed by our CI/CD to build the parts of that multi-modules project... or the readme which need to remain at the root to be displayed first by the git "browser system" (github, bitbucket...))

 

 

0

Hi Sébastien,

Try the same approach via File | New | Project from Existing Sources again, but this time expand the project root directory in the 'File/Dir to Import' dialog before hitting 'OK' so that IntelliJ can refresh and process the insides of the folder correctly. See how I did it:

And then I add the modules (using alternative way to import a Maven module):

0

Hi Arina,

Unfortunately it doesn't work that way for me, I tried with different framework options but project files are never included:

This is by adding modules separately and not include them on project creation:

 

This is when including "directories that will be added to project roots":

... I can't include the GIF  (2MB is quiet restrictive by the way) but I got the same results, so this is without "unmarking all" from the previous GIF

 

And this is a simplified and clean version of my project setup:

- serviceX

- serviceY

readme.md

 

Both serviceX and serviceY are "from scratch" as well, generated from maven archetype:

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4

 

Could it be the version then? I'm using 2020.1 (Ubuntu 18.04.2 LTS)?

0

Hi Sébastien,

Sorry for keeping quiet for a while. I looked deeper into the Open Project and Import Project actions, and found out that they were merged into a single action in 2020.1 as part of a recent effort to make project opening process more transparent.

Please try opening your project via the File | Open... menu option. Choose the root directory as usual and proceed with project structure creation. The root directory should be identified and marked as a content root automatically (test_modules in my case).

A pop-up will appear in the bottom-right corner prompting you to import automatically found pom.xml's. In my case, they were imported as separate modules as expected.

Let me know if it doesn't help, I will then submit a bug report to our issue tracker.

0

That was it! 

So there seems to be a discrepancy between "open" (even from not yet created projects) and "import from existing sources".

 

If needed here are some final screens, I'm not sure how or if you want to tackle this.

Because here it seems that I should not use "new project" > "new project from existing source" but rather "open" to... create a project (if I have root files/directories)

 

Thanks for your time!

 

- open

- new project > Import from existing source

0

Good to know it worked Sébastien!

I already reported this behavior to the developers responsible for the functionality. We need to either remove the 'New project from existing sources' option if it is now fully covered by 'Open', or document the distinction between the two and list cases where '...from existing sources' will be beneficial.

Hopefully, it won't take long to get it sorted.

0

请先登录再写评论。