|
2 | 2 | title: Project
|
3 | 3 | ---
|
4 | 4 |
|
5 |
| -In IntelliJ IDEA, a project encapsulates all your source code, libraries, build instructions into a single organizational unit. |
6 |
| -Everything you do in IntelliJ IDEA, is done within the context of a project. |
7 |
| -A project defines some collections referred to as modules and libraries. |
8 |
| -Depending on the logical and functional requirements to the project, you can create a single-module or a multi-module project. |
| 5 | +In *IntelliJ IDEA*, a project encapsulates all your source code, libraries, build instructions into a single organizational unit. Everything you do in *IntelliJ IDEA*, is done within the context of a project. A project defines some collections referred to as modules and libraries. Depending on the logical and functional requirements to the project, you can create a single-module or a multi-module project. |
9 | 6 |
|
10 |
| -## Working with Projects |
| 7 | +## Working with projects |
11 | 8 |
|
12 |
| -*IntelliJ Platform* stores the project configuration data in XML files. |
13 |
| -The list of those files depends on the plugin |
14 |
| -[project](http://www.jetbrains.com/idea/help/project.html) |
15 |
| -format. |
16 |
| -For file-based format projects, the information core to the project itself (e.g. location of the component modules, compiler settings, etc.) is stored in the <%project name%>.IPR file. |
17 |
| -The information about modules the project includes is stored in <%module name%>.IML files. |
18 |
| -Module files are created for each module. |
| 9 | +The *IntelliJ Platform* stores the project configuration data in XML files. The list of those files depends on the plugin [project](http://www.jetbrains.com/idea/help/project.html) format. |
19 | 10 |
|
20 |
| -For directory-based format projects, the project and workspace settings are stored in a number of XML files under the <%Project home directory%>/.idea directory. |
21 |
| -Each XML file is responsible for its own set of settings and can be recognized by its name: projectCodeStyle.xml, encodings.xml, vcs.xml etc. |
22 |
| -As for the file-based format projects, .IML files describe modules. |
| 11 | +For file based format projects, the information core to the project itself (e.g. location of the component modules, compiler settings, etc.) is stored in the `%project_name%.ipr` file. The information about modules the project includes is stored in `%module_name%.iml` files. Module files are created for each module. |
23 | 12 |
|
24 |
| -Main classes providing work with the project model are located in the package |
25 |
| -[projectModel-api.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-api/src/com/intellij/openapi). |
26 |
| -Basic API classes and interfaces for the concepts of |
27 |
| -[project](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/project/Project.java), |
28 |
| -[module](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/module/Module.java), |
29 |
| -[application](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/application/Application.java), |
30 |
| -and |
31 |
| -[component](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/components/ProjectComponent.java) |
32 |
| -are placed in the |
33 |
| -[core-api.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/core-api/src/com/intellij/openapi) |
34 |
| -package. |
| 13 | +For directory based format projects, the project and workspace settings are stored in a number of XML files under the `%project_home_directory%/.idea` directory. Each XML file is responsible for its own set of settings and can be recognized by its name: `projectCodeStyle.xml`, `encodings.xml`, `vcs.xml` etc. As for the file-based format projects, `.iml` files describe modules. |
35 | 14 |
|
| 15 | +Main classes providing work with the project model are located in the package [projectModel-api.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-api/src/com/intellij/openapi). Basic API classes and interfaces for the concepts of [project](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/project/Project.java), [module](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/module/Module.java), [application](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/application/Application.java), and [component](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/core-api/src/com/intellij/openapi/components/ProjectComponent.java) are placed in the [core-api.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/core-api/src/com/intellij/openapi) package. |
36 | 16 |
|
37 |
| -### Finding Source Roots |
38 |
| - |
39 |
| -To get an array of all the source roots for a project use |
40 |
| -`ProjectRootManager.getContentSourceRoots()` |
41 |
| -method like this code snippet shows: |
| 17 | +### Finding source roots |
42 | 18 |
|
| 19 | +To get an array of all the source roots for a project use `ProjectRootManager.getContentSourceRoots()` method like this code snippet shows: |
43 | 20 |
|
44 | 21 | ```java
|
45 | 22 | VirtualFile[] vFiles = ProjectRootManager.getInstance(project).getContentSourceRoots();
|
46 | 23 | ```
|
47 | 24 |
|
| 25 | +### Checking if a file belongs to a project |
48 | 26 |
|
49 |
| -### Checking if File Belongs to a Project |
50 |
| - |
51 |
| -Use |
52 |
| -[ProjectFileIndex.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) |
53 |
| -to get this information. |
| 27 | +Use [ProjectFileIndex.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) to get this information. |
54 | 28 |
|
55 | 29 | ### Getting an Instance of the ProjectFileIndex Interface
|
56 | 30 |
|
57 |
| -Use the ProjectRootManager.getFileIndex() method. For example: |
| 31 | +Use the `ProjectRootManager.getFileIndex()` method. For example: |
58 | 32 |
|
59 | 33 | ```java
|
60 | 34 | ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
61 | 35 | ```
|
62 | 36 |
|
63 |
| -Note that this method returns `null` if the file does not belong to any module. |
64 |
| -You can also use the `ProjectFileIndex.getContentRootForFile()` method to get the module content root to which the specified file or directory belongs: |
| 37 | +Note that this method returns `null` if the file does not belong to any module. You can also use the `ProjectFileIndex.getContentRootForFile()` method to get the module content root to which the specified file or directory belongs: |
65 | 38 |
|
66 | 39 | ```java
|
67 | 40 | VirtualFile moduleContentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(virtualFileOrDirectory);
|
68 |
| -``` |
| 41 | +``` |
69 | 42 |
|
70 | 43 | ## Changing the project structure
|
71 | 44 |
|
72 |
| -Utility classes which can be used for modifying a project structure can be found in the package |
73 |
| -[projectModel-impl.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-impl/src/com/intellij/openapi). |
74 |
| -It's |
75 |
| -[roots](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-impl/src/com/intellij/openapi/roots/) |
76 |
| -subpackage contains instances and utilities meant to work with project and module source roots, including |
77 |
| -[ModuleRootModificationUtil.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java) |
78 |
| -and |
79 |
| -[ProjectRootUtil.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java) |
80 |
| - |
81 |
| -Refer to the |
82 |
| -[basic example](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/com/intellij/tutorials/project/model/ModificationAction.java) |
83 |
| -of on-the-fly project structure modification to learn how it can be implemented. |
| 45 | +Utility classes which can be used for modifying a project structure can be found in the package [projectModel-impl.openapi](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-impl/src/com/intellij/openapi). It's [roots](https://github.com/JetBrains/intellij-community/tree/master/platform/projectModel-impl/src/com/intellij/openapi/roots/) subpackage contains instances and utilities meant to work with project and module source roots, including [ModuleRootModificationUtil.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java) and [ProjectRootUtil.java](https://upsource.jetbrains.com/idea-community/file/1731d054af4ca27aa827c03929e27eeb0e6a8366/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java). |
| 46 | + |
| 47 | +Refer to the [basic example](https://github.com/JetBrains/intellij-sdk-docs/blob/master/code_samples/project_model/src/com/intellij/tutorials/project/model/ModificationAction.java) of on-the-fly project structure modification to learn how it can be implemented. |
0 commit comments