While working on Package Drone, I stumbled over an interesting issue.
Deploying to Package Drone using Maven requires a deploy key. A random token, generated by the server which has to be used as either username or password on the basic authentication process of HTTP.
This worked fine as long as I started “maven deploy” from inside the Eclipse IDE. Starting “maven deploy” using the external maven installation or from the command line caused:
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://localhost:8080/maven/m2test/de/dentrassi/test/felixtest1/0.0.1-SNAPSHOT/felixtest1-0.0.1-20150217.162541-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
Although I did configure Maven to use the correct credentials in the
<server> <username></username> <password>abc123</password> <id>pdrone.test</id> </server>
After several hours of googling, source code reading and debugging maven it was actually pretty easy.
First of all, the embedded Maven instance in Eclipse uses
AetherRepositoryConnector instead of
BasicRepositoryConnector for accessing repositories. “Aether” simply takes the username and password values, as provided, and uses them.
The “BasicRepositoryConnector” however decided that an empty username (or an empty password) is not good at all and simply dropped the whole configuration without warning.
So in the end, introducing a dummy user name did the trick.