Home > Java > javaTutorial > How to Package External Libraries with Artifacts in IntelliJ IDEA?

How to Package External Libraries with Artifacts in IntelliJ IDEA?

Mary-Kate Olsen
Release: 2024-12-28 16:58:15
Original
618 people have browsed it

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:

  1. Navigate to Project Structure (File > Project Structure).
  2. Click the Artifacts tab and select your artifact.
  3. Under Output Layout, expand Included Directories.
  4. 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:

  1. Add the external JARs to Library: In Project Structure, add the JARs under Libraries for the relevant module(s).
  2. Configure Manifest.MF: Under Artifacts for the artifact, navigate to Libraries.
  3. Check the box for Extract to output root directory.
  4. Copy Libraries: Manually copy the dependent JARs to the same directory as the main artifact jar.

Configuration Examples

Embedding External Libraries:

How to Package External Libraries with Artifacts in IntelliJ IDEA?

Linking External Libraries:

How to Package External Libraries with Artifacts in IntelliJ IDEA?

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template