3

I want to version my WAR to make DevOps lives easier, i.e.: foo-3.2.0.war. In pom.xml, I have:

<build>
  <finalName>foo</finalName>

but also

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>${maven-war-plugin.version}</version>
  <configuration>
    <warName>${project.artifactId}-${project.version}</warName>

that imparts the current version in pom.xml to the WAR filename. So far, so good.

The problem becomes that the version is required in the URL when deployed to Tomcat. I want my application accessed thus: http://hostname:port/foo and not http://hostname:port/foo-3.2.0 (etc.) because I'd have to annoy my consumer with the version change.

Is it possible to work around this problem without just going back to an unversioned WAR file?

Russ Bateman
  • 18,333
  • 14
  • 49
  • 65

1 Answers1

3

You can use ${project.artifactId}##${project.version} as naming scheme.

The part after ## will not be part of the context name (cf. parallel deployment).

Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43
  • Okay, resulting WAR-filename not handsome, but very workable. I think I can sell it. Thank you. – Russ Bateman Jul 26 '21 at 22:13
  • 1
    @rus-bateman keep in mind that multiple version could be deployed and users will access old versions until their session expires. Then the new one will be served for those. – LMC Jul 26 '21 at 22:35