Quantcast
Channel: Maven – Dark Views
Viewing all articles
Browse latest Browse all 12

Better Maven Deploy

$
0
0

mvn deploy has two major issues:

  1. If the project has several modules and the build fails in the middle, you will end up with a repository that is a mix of old and new modules.
  2. The POM must have the correct values in the distributionManagement element.

The former can break builds for your colleagues, the latter means you have to edit the POM file. Not a big deal – unless the POM file comes from an external source, say, an OSS project. If you edit it, you need to maintain the changes. But it gets ugly when your changes are committed to the external project.

The following script solves both problems. In a nutshell, it copies the POM, removes any existing distributionManagement elements, adds the ones you want and then builds using the new, temporary POM. If the build succeeds, the temporary POM is deleted.

The build itself is split into two steps. The first step does a local build, the second build skips tests and only uploads the results. It does run the compilers again but since the code was already built a few seconds ago, this shouldn’t be an issue.

Shell script.


Tagged: Deploy, Maven, Script

Viewing all articles
Browse latest Browse all 12

Trending Articles