0

I am writing a rudimentary blockchain for illustrative/teaching purposes in Java and have decided to use websockets for block/tx transport. The problem I am having is that in order to start the websocket server, I have to deploy the project into an Apache tomcat cargo container and thus package it as a war. The rest of the applications functionality however, has been packaged into a jar since the first day I started this project. I am new to Java, and even newer to web applications, so maybe there is something I am missing, but my solution has been to change the packaging of the project from war to jar or vice versa in the pom.xml depending on whether I am making changes to the websocket server or any other part of the project, then I launch the cargo container and the jar separately. Is there a more elegant way to achieve this? I have the war plugin archiving the classes into a jar, but it is obviously not executable since there's no main manifest attribute. Any thoughts would be appreciated!

apt-getschwifty
  • 199
  • 2
  • 12
  • 1
    see: https://stackoverflow.com/questions/8247720/changing-packaging-based-on-active-profile-in-pom – linski May 04 '19 at 19:09
  • 1
    This looks like exactly what I need! How would I specify which profile I want maven to build? Is it an additional flag in the mvn install command? So using the profiles in the post you cited as an example, mvn install webapp for the war, and mvn install batch for the jar? – apt-getschwifty May 04 '19 at 19:15
  • Yes, exactly like that. Great! – linski May 04 '19 at 19:16

0 Answers0