Deploying Maven modules
My most recent consulting gig brought me back into contact again with Maven. I have this love-hate relationship with Maven. I love using Maven for simple projects, that generally have only a development environment, and I hate using Maven for more complex projects where you have to create profiles for multiple testing environments. Maven is just too restrictive for the latter case.
If you have your own internal Maven repository setup and you want to deploy reusable modules to it then follow these instructions. It took me a while to figure them out as there is something wrong with Wagon’s internal ssh implementation. Using an external scp tool will save you a lot of grief.
1. Setup your local .m2/settings.xml as follows:
internal.maven.repos maven location of your ssh private key
You’ll need to create an ssh key. And provide a reference to your private key using the
2. Log into your server hosting your maven repository and add the contents of your public key (id_rsa.pub) at the bottom of the authorized_keys2 file. You should create a generic maven user that everyone on your team can log into, this is because when you deploy your module it will be written to the filesystem with read/write permissions only for that user. Exit your server.
3. Go to your project and add the following to your project’s pom.
... internal.maven.repos Internal Maven Repository scpexe://maven@hostname.com/home/maven/.m2/repository org.apache.maven.wagon wagon-ssh-external 1.0-beta-2
4. Run mvn deploy.
5. You should now see your project deployed to the maven repository on your server.