One Spring Boot project, deploy to both JAR or WAR

maven, spring, spring-boot

Solution

What's wrong with a WAR file that's executable? Isn't that what you really need?

P.S. like `java -jar name.war`

Problem

Is there a way to have a single Spring Boot project be packagable into both JAR and WAR without changing the `pom.xml` or the application source? I've read Converting a Spring Boot JAR Application to a WAR, but it converts the project to WAR and it loses the ability to be packaged as JAR. I don't expect `mvn package` to do both. What I want is something like `mvn i-want-a-jar` and it would package the project as JAR. Or I could run `mvn i-want-a-war` and it would package the project as WAR. Is this possible?

Original source