0

I have read this: maven: multi-module project assembly into single jar

For the accepted answer of that question, my maven version is 2.2.1 and shade need maven 3.

My parent pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>myGroup</groupId>
    <artifactId>x-all</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0</version>

    <modules>
        <module>x-framework</module>
        <module>x-adaptor</module>
        <module>x-plugin</module>
        <module>x-utils</module>
        <module>x-offline</module>
        <module>x-protocols</module>
    </modules>
...

I just want to build a x-all-1.0.0-jar-with-dependencies.jar that includes

  1. every sub-module class
  2. every sub-module dependency class (need resolve dependency conflict automatically)
  3. some resource file(in x-all/src/main/resources)

How do I build that?

Community
  • 1
  • 1
Sayakiss
  • 6,878
  • 8
  • 61
  • 107

1 Answers1

1

Add another module, for example, call it x-package. let x-package depends every module in that project. And we just run mvn package with a simple assembly plugin configuration(jar-with-dependence), we will get the wanted jar in x-package's target directory.

Sayakiss
  • 6,878
  • 8
  • 61
  • 107