how to generate jar and war both in project
22,907
The default solution for such thing is to have two separate modules one for the war and one for the controller module. Don't start fighting with Maven.
Author by
Zuned Ahmed
Updated on June 16, 2020Comments
-
Zuned Ahmed almost 4 years
we have two different project . And and the controller is almost same in two project.
project A has controller inside it. So generating war for it is not problem.
But project B is requiring Controller's jar of project A controller.
Can any body tell me how can i generate the jar file from the controller of project A which i can use in project B?
-
Zuned Ahmed about 12 yearsyou mean to say should i write two pom file one for generating jar file and other for war file?
-
khmarbaise about 12 yearsThe best thing is to create a multi-module build which contains the two modules (war, controller) and a parent.
-
khmarbaise about 12 yearsBut you can also use the solution i described here: stackoverflow.com/a/10189767/296328
-
Adam Gent about 12 yearsArguably if you need the jar you should have the war and business logic code separated anyway. That is I assume you want to reuse the code outside of the war... hence the jar.
-
Zuned Ahmed about 12 yearsthe problem its not the business logic the UI really complex and for that we have done good amount of coding on controller and web model object and that model object is used on different portal so here we have to port complete controllers from one portal to other.
-
ingyhere over 2 yearsOMG! Just use Maven
profiles
and change the packaging toJAR
and build both profiles!