Packaging External Libraries with Artifacts in IntelliJ IDEA
Although project dependencies are automatically imported into module runtimes in IntelliJ IDEA, this default behavior may not extend to artifact builds. To ensure external libraries are accessible within artifact jars:
Approach 1: Embedding Dependencies
For complete encapsulation of dependencies within the artifact jar:
- Navigate to Project Structure (File > Project Structure).
- Click the Artifacts tab and select your artifact.
- Under Output Layout, expand Included Directories.
- Add the node_modules directory or specific paths where your external libraries reside.
Approach 2: Linking Dependencies via Manifest
To avoid bloating the artifact jar:
-
Add the external JARs to Library: In Project Structure, add the JARs under Libraries for the relevant module(s).
-
Configure Manifest.MF: Under Artifacts for the artifact, navigate to Libraries.
- Check the box for Extract to output root directory.
-
Copy Libraries: Manually copy the dependent JARs to the same directory as the main artifact jar.
Configuration Examples
Embedding External Libraries:
Linking External Libraries:
The above is the detailed content of How to Package External Libraries with Artifacts in IntelliJ IDEA?. For more information, please follow other related articles on the PHP Chinese website!