2

i have 3 modules in my maven project , each of the modules generate a jar file. And then i have a 4th module that generates war out of these jars

Here is my POM which is parent of all modules

<modules>
    <module>A</module>
    <module>B</module>
    <module>C</module>
    <module>DWAR</module>

 </modules>

IN DWAR's pom , I have specified dependencies on all the three modules A,B,C

 <dependency>
            <groupId>yyyy</groupId>
            <artifactId>A</artifactId>
            <version>0.0.1-SNAPSHOT</version>
</dependency>

. . And So on.

My war builds successfully, the lib folder of war contains all the jars, but classes folder is empty. But in each of the modules A,B,C classes folder is populated with compiled classes. What am I missing?

TruckDriver
  • 1,383
  • 13
  • 28

1 Answers1

0

What you describe is the expected behaviour: Your war contains the three jars. The war itself has no java source files, so its classes folder is empty.

Building a war does not unpack the included jars, but adds them into the war as a whole.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • while deploying this war into some app server like tomcat. The class loading will be first attempted from "classes" folder and then from WEB-INF/lib *.jars. So i think functionality will not be impacted. But anyway i wanted the classes of individual jars copied into the classes folder. Is there any way? – TruckDriver Mar 15 '18 at 14:13
  • Why not just put the source code into the war module? – J Fabian Meier Mar 15 '18 at 14:22
  • but that will defeat the purpose of having multiple modules, each module has its own source code. – TruckDriver Mar 15 '18 at 14:23
  • Why do you want to have different modules? Do you use one or more of the modules outside this multi-module project? All classes that are only used in the war should be part of the war. – J Fabian Meier Mar 15 '18 at 14:43
  • Yes each of the modules are developed by different teams and few may be used outside this project as separate dependency. – TruckDriver Mar 15 '18 at 15:06