IntelliJ IDEA 2017.3 Help

Working with Artifacts

On this page:

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.

Working 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.

Building 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.

Running 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 /help/img/idea/2017.3/new.png and select JAR Application.

Deploying artifacts to application servers and cloud platforms

Many of the artifact formats (e.g. 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 (/help/img/idea/2017.3/deploymentConsoleDeployAll.png) 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: 11 October 2017

See Also