Build tools importing process
As a developer, you often use build tools to manage and organize your builds. The bigger the project is the more important build tools become for your work.
IntelliJ IDEA has its own native build system, or you can use an external build tool such as Maven, Gradle, Ant, Gant, or sbt (for the Scala plugin) to build and deploy your project.
The integration for the majority of the build tools that IntelliJ IDEA supports is bundled and enabled by default. The most popular and widely used build tools are Maven and Gradle with which IntelliJ IDEA provides full integration.
Project import
A common scenario of working with a build tools project is that you already have an existing project stored somewhere and want to work with such project inside the IDE.
First, you need to ensure that you trust the source from which you open your project. If you don't trust the source, IntelliJ IDEA opens the project in the preview mode that contains limited information about your project. For more information about project security, refer to Project security.
If you open that project from a trusted source inside the IDE, IntelliJ IDEA "imports" it. It means that IntelliJ IDEA not only opens your project, but also performs actions that integrate that project into the IDE.
Let's see what actually happens during the importing process:
IntelliJ IDEA executes code from build scripts in a separate Java process which is created with the selected Maven or Gradle JVM
Based on the build tool configuration files, IntelliJ IDEA configures the project structure. For example, it sets the source/resource/test source/test resource directories, and for each module it sets the Java compiler source and target levels
IntelliJ IDEA adds libraries to module dependencies based on dependencies configured in the build configuration files, resolves dependencies between project modules, and synchronizes dependencies across the project;
IntelliJ IDEA sets the language level for the project;
For Gradle projects, IntelliJ IDEA also creates the IDE module for each Gradle source set
For Java Web modules, IntelliJ IDEA enables Web Application Support and creates the Web Application artifacts
What triggers project import
IntelliJ IDEA performs a lot of actions during the import, and it is done not only when you open a project.
Check the following cases in which the importing process is triggered:
Open a project from VCS – the import process gets started when you clone your project from one of the version control systems such as Git, Mercurial, and so on.
Open a project from an external model – when you are not sure which build tool is used in a project or when there are more than one tool used, you can select from which model you want to import your project.
Open a project from a local directory – this is a simple case when your project resides on your machine.
Open a project from the WSL file system – this is the case when your project is stored in WSL but IntelliJ IDEA lets you open it in the same way as you would from a local file system.
Add a project to an already opened project – this is the case when you are adding or, in the case of Gradle, linking a project to an already opened one in the IDE using one of the build tools' tool windows.
Load changes when build script changes – in this case you trigger the import process when you click the load changes icon in the editor or select the reload action on a project in one of the build tools windows such as Gradle or Maven.
Reload all projects – in this case you trigger the import process when you click the Reload icon in one of the build tool's tool windows.
For more information on working with build tools, refer to the following sections: