简体   繁体   中英

Viewing non-project file(s) in Maven-based IntelliJ projects

We use Maven and IntelliJ for a number of multi-module projects. We're set up so that the root pom.xml file IS the project file. Developers, after importing a root pom.xml , may customize their project's environment, but we do not put IntelliJ projects under source control or otherwise save them. When a developer starts working on a new project for the first time, she imports the root pom.xml and is off and running.

There's a problem with this practice. We have other files in our source trees that aren't directly related to Maven and building our Java artifacts, but that we'd like to view and modify in IntelliJ. These unrelated files don't show up in the IntelliJ project explorer. In the cases where we have whole unrelated directories, we do this by adding extra "Content Root" definitions to the project on a ad-hoc basis. But if an individual file exists in the root of the source tree, or some other project directory, and is not used by the Maven build process, it doesn't show up in IntelliJ, and you can't add the root of the source tree as a new "Content Root". For example, we have a Jenkinsfile at the root of our tree that Maven doesn't care about, but we as developers certainly do. We currently have to edit this file in another code editor.

Is there a good way to cause these sorts of files to show up in the IntelliJ project view(s)? Ideally, we'd like there to be some way to add something to a pom.xml file to cause these to show up and otherwise be ignored by our builds. If we have to though, a way to add these files ad-hoc would be ok. We can't find any consistent way to do this. Can anyone tell us how to solve this problem?

UPDATE: I am not storing the IntelliJ project files at the root of my source tree. The root pom.xml file is an aggregate pom that does not produce anything. Here is what my "Project" view looks like:

我的IntelliJ项目视图

The root of the source tree is inletfetch_if2, which you can see has no representation here. The if2_all node is where my IntelliJ project files live.

IntelliJ IDEA Project view will display the files located in the project root next to the parent pom.xml :

多模块

You can get this sample project here .

As you can see, the parent Maven aggregate project is located in the root of the hello-world-ear directory, there are 2 sub-projects located in the packaging and hello-world-war directories.

If you add Jenkinsfile in the project root, it will be displayed in the Project View.

Do you use some other configuration that has a different structure? If so, please share the Minimal, Complete, and Verifiable example to get help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM