Search code examples
javamavenwardistribute

Maven redistribute existing war (no command line)


I have a complex maven project whose build artifacts are published automatically to a Nexus.

In the source code, I have Test.war: a WAR provided as-is by a third-party. Such archive is built manually by them, not available in Nexus, and does not have GAV identifier.

During my complex build, I need to "re-distribute" (or "rebuild"?) this provided war using new, defined GAV coordinates (e.g. test-group:Test-Web:1.0.0).

Note: I cannot execute a command like mvn deploy:deploy-file because we don't have direct access to the Nexus. The only way to deploy artifacts to Nexus, is to generate the artifacts during a build, and then such artifacts are automatically published.

Is there anyone who can provide me a suggestion or an example on how I can re-deploy such war during the build?


Solution

  • I assume by "re-distribute" you mean that your build needs to deploy the WAR to nexus under the different GAV.

    In this case you might consider using mvn deploy:deploy-file plugin.

    This goal of the deploy plugin installs the file into remote repository and allows specifing the GAV of the artifact file that you want to deploy.

    When WAR is created it doesn't contain any GAV, the GAV is used solely to identify the artifact in the maven repo (remote or local).

    You can find an example here