Work with artifacts
On this page:
- What is an artifact?
- Work with artifact configurations
- Build artifacts
- Build options (Build, Rebuild, etc.)
- Run JAR artifacts
- Deploy artifacts to application servers and cloud platforms
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.)
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 ( ).
The key part of configuring an artifact is specifying the artifact structure and contents on the Output Layout tab.
You can initiate building an artifact yourself:.
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 (), 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.
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:
Open the Run/Debug Configurations dialog (e.g. Run | Edit Configurations).
Click 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:
In a server or cloud run/debug configuration, specify the artifact to be deployed. (Use the Deployment tab or field.)
Execute the run/debug configuration or use the Deploy command () in the Application Servers, Run or Debug tool window.
Examples of the procedures discussed on this page can be found in the following tutorials: