IntelliJ IDEA 2021.1 Help

Work with artifacts

See also, Project Structure / Artifacts.

What is an artifact?

An artifact is an assembly of your project assets that you put together to test, deploy or distribute your software solution or its part. Examples are a collection of compiled Java classes or a Java application packaged in a Java archive, a Web application as a directory structure or a Web application archive, etc.

An artifact can be an archive file or a directory structure that includes the following structural elements:

  • Compilation output for one or more of your modules

  • Libraries included in module dependencies

  • Collections of resources (web pages, images, descriptor files, etc.)

  • Other artifacts

  • Individual files, directories and archives.

Work with artifact configurations

Artifacts are generated according to artifact configurations. The artifact configurations are managed in the Project Structure dialog (File | Project Structure | Artifacts ).

The key part of configuring an artifact is specifying the artifact structure and contents on the Output Layout tab.

Build artifacts

You can initiate building an artifact yourself: Build | Build Artifacts.

You can as well build an artifact by executing a run/debug configuration:

In the corresponding run/debug configuration, add the Build <ArtifactName> artifact task to the Before launch task list. The artifact will be built automatically when you execute the run/debug configuration (Run | Run or Run | Debug ).

Including the Build artifact task in a run/debug configuration makes sense when the run/debug configuration somehow uses the corresponding artifact, e.g. starts the application packaged in a JAR artifact or deploys a WAR or EAR artifact to an application server.

By default, an artifact, when built, is placed into the out/artifacts/<artifact_dir> folder.

Build options (Build, Rebuild, etc.)

When building an artifact (Build | Build Artifacts ), you have the following options:

  • Build. When used for the first time, the whole artifact is built. Each next time you use this option, only the part of the artifact affected by the changes you have made since the last build is built and added to the output folder.

  • Rebuild. Build the whole artifact as if for the first time. Technically, this is Clean followed by Build.

  • Clean. Delete all the contents of the artifact output directory.

  • Edit. Edit the artifact configuration.

Run JAR artifacts

To run Java applications packaged in Java archives (JARs), IntelliJ IDEA provides the JAR Application run configurations. To create such a run configuration:

  1. Open the Run/Debug Configurations dialog (e.g. Run | Edit Configurations ).

  2. Click Icons general add and select JAR Application.

Deploy artifacts to application servers and cloud platforms

Many of the artifact formats (for example, WAR, Exploded WAR, EAR, Exploded EAR) are suitable for deployment to application servers and cloud platforms. Here is how you deploy such artifacts:

  1. In a server or cloud run/debug configuration, specify the artifact to be deployed. (Use the Deployment tab or field.)

  2. Execute the run/debug configuration or use the Deploy command (Deployment console deploy all) in the Application Servers, Run or Debug tool window.

Examples

Examples of the procedures discussed on this page can be found in the following tutorials:

Last modified: 08 March 2021