ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

How to Create Shaded and Non-Shaded Jars in Maven within the Same Module

Create shaded and non shaded jars in Maven in same module?

maven

Автор: vlogize

Загружено: 2025-07-25

Просмотров: 15

Описание: Learn how to configure Maven to generate both `shaded` (uber) and `non-shaded` JAR files in a single module and publish them to your local Maven repository.
---
This video is based on the question https://stackoverflow.com/q/67905892/ asked by the user 'Brandon Kalashian' ( https://stackoverflow.com/u/12305101/ ) and on the answer https://stackoverflow.com/a/67906446/ provided by the user 'khmarbaise' ( https://stackoverflow.com/u/296328/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.

Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Create shaded and non shaded jars in Maven in same module?

Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.

If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
How to Create Shaded and Non-Shaded Jars in Maven within the Same Module

Maven is a powerful tool widely used in Java projects for project management and build automation. One common requirement for developers is the ability to package their applications into JAR files for deployment and distribution. Sometimes, you may want to create two different types of JAR files from the same Maven module:

A shaded JAR (also known as an uber JAR) that packages all dependencies into a single JAR file.

A non-shaded JAR that contains only your project's compiled classes without external dependencies.

In this guide, we'll walk through how you can achieve this configuration to create both types of JAR files in a single module and publish them to your local Maven repository.

Setting Up Maven for Multiple JAR Outputs

To create both a shaded and non-shaded JAR during your Maven build process, you will need to modify your pom.xml file. Here's how to do it step by step:

Step 1: Define the Build Plugins

Maven allows you to specify different plugins for the build process. For creating a shaded JAR, you'll use the maven-shade-plugin. Here’s how you can configure it:

[[See Video to Reveal this Text or Code Snippet]]

Step 2: Understanding the Configuration

<phase>: The <phase> element specifies when the plugin should run in the Maven build lifecycle. We set it to package, so the plugin executes as part of the standard packaging phase.

<goals>: The <goal> element defines what the plugin should actually do. Here, the shade goal is used to create the shaded JAR.

<shadedArtifactAttached>: This configuration option specifies whether the shaded JAR should be attached to the Maven build outputs. When set to true, Maven will create a JAR file named xyz-1.0-shaded.jar along with the regular JAR file.

Step 3: Build the Project

Once you've updated your pom.xml, you can build your project by running the following command in your terminal:

[[See Video to Reveal this Text or Code Snippet]]

This command will compile your project, run tests, and create both the shaded and non-shaded JAR files, making them available in your local Maven repository.

Final Thoughts

Being able to generate both a shaded and non-shaded JAR file from the same Maven module can greatly enhance your deployment flexibility. By following the steps outlined above, you'll have both artifacts ready for your application needs.

Whether you prefer to distribute a single convenient package (shaded JAR) or adhere to modular dependency management (non-shaded JAR), Maven provides a straightforward way to make that happen.

Now, go ahead and try configuring this in your Maven project to enjoy the benefits of both JAR types!

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
How to Create Shaded and Non-Shaded Jars in Maven within the Same Module

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]