Well, this is basically a case of "Should have read the manual more thoroughly" but as this issue does not seem very obvious to me even after reading the documentation and I found several people asking something similar on the web I guess this is worth sharing.
In my current project I had an issue that at first seemed like a problem with the maven configuration. When deploying a new release artifact to the project nexus the generated javadoc and source jars were always uploaded twice to the repository (both artifacts were configured via the corresponding plugins). So in order for the release process to complete successfully we had to allow artifact redeployment for the repository.
This was a major issue for me in matters of build stability and especially reproducibility as it gave the option to overwrite an already released version of an artifact but for a long time the project's budget and deadlines did not allow for a proper analysis. Luckily we were able to handle this problem by being extra cautious during releasing.
Lately I was able to prioritize this issue properly and could spend some time on it. At first I suspected an issue with our maven configuration as the project consists of a lot of modules organized in a complex hierarchy. So I spent a few hours dissecting the POMs to find a working setup but to my surprise I was able to reproduce the problem even with a single dummy POM and the plugins were configured properly according to their documentation.
So I decided to hit the web for a search about this problem but after reading through a lot of forum and mailing list posts I just got the idea that for some reason the plugin executions got attached twice.
Then I took a closer look at the maven documentation and tried to understand how attaching plugin execution to goals and build phases works. And this let my suspicion grow stronger but the final solution was given by another post to the maven mailing list by Stephen Connolly (unfortunately I didn't save the link to the post).
The problem was simply a wrong invocation of our maven build. We were invoking "mvn clean install deploy" as we were not aware the jar goal is not only bound to the install phase (or rather the packaging phase) but also to the deploy phase. Again, I don't consider this as obvious and if anyone has a link to a page were this is described properly is very welcome to share it here.
Anyhow this means the solution is rather trivial, just use "mvn clean deploy" if you want to build an artifact and deploy it to the remote repository in one step ;-)
Keine Kommentare:
Kommentar veröffentlichen