michele
michele

Reputation: 26598

Java Project with modules in one Jar

I have a project called BigProject.

The structure is:

BigProject
-firstModule
 --pom.xml
-secondModule
 --pom.xml
-thirdModule
 --pom.xml
-pom.xml

I want to create a unique jar called BigProject.jar At the moment, if I do a clean install, I have returned a jar for each module.

Can you explain me how to do? thanks

Upvotes: 3

Views: 1173

Answers (2)

ImGroot
ImGroot

Reputation: 836

Well you'd need a custom class loader for that. Thankfully folks have already contributed some plugins to ease up your life. You can have a look over Ant's create jar task or spring-boot's repackage goal, whatever stays convenient for you. Example below:

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <version>2.0.1.RELEASE</version>
  <executions>
    <execution>
      <goals>
        <goal>repackage</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Upvotes: 1

howlger
howlger

Reputation: 34135

Each module-info.java which lives in the default package will be compiled to module-info.class.

Therefore, one JAR cannot contain multiple modules.

Upvotes: 0

Related Questions