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.

Share:
22,907
Zuned Ahmed
Author by

Zuned Ahmed

Updated on June 16, 2020

Comments

  • Zuned Ahmed
    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
    Zuned Ahmed about 12 years
    you mean to say should i write two pom file one for generating jar file and other for war file?
  • khmarbaise
    khmarbaise about 12 years
    The best thing is to create a multi-module build which contains the two modules (war, controller) and a parent.
  • khmarbaise
    khmarbaise about 12 years
    But you can also use the solution i described here: stackoverflow.com/a/10189767/296328
  • Adam Gent
    Adam Gent about 12 years
    Arguably 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
    Zuned Ahmed about 12 years
    the 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
    ingyhere over 2 years
    OMG! Just use Maven profiles and change the packaging to JAR and build both profiles!