Why Deployment ?

Whenever you make any changes in any of the components/artefacts which are part of the repository (Maven build) then you need to publish it, otherwise changes might not be visible. You need to publish these changes because subversion (or any SCM) repositories and maven repositories are different. When we commit our changes, we make changes in the SCM repository but maven build uses maven internal repository location. There is no way for the maven repository to know that something has changed in the SCM repository unless you 'publish' the changes or deploy the changes to the repository. Maven uses a simple command to publish these changes
mvn deploy
This will deploy the entire project to the repository mentioned in the settings.xml file but if you want to deploy specific files you could use this command.

mvn deploy:deploy-file


While using mvn deploy, you need to be aware that it should always be called from the directory where pom.xml for project is present. This command will read the repository location and name from your POM file as well as from the settings.xml file.

During deployement, if you get 401 error this means your user name is not part of the artifactory users group.Get your self added to the correct users group. Make sure you correct the username and password is in the settings.xml file. Also even after the user is added and you get 'Authorization failed' error this could mean that you can actually log into the repository but do not have rights/permissions to view/deploy files.
What should I do to mantain different versions:

Sometimes you might want to mantain different versions of your artefacts then you could follow this process.

1. Check that there are no uncommitted changes in the sources
2. Change the version in the poms from x-SNAPSHOT to a new version.
3. Do mvn deploy
4. Run the tests to make sure everything is correct and the changes are getting pulled down as expected.
5. Then commit the new POM files
6. Make sure this new snapshot version is changed in all the other Pom file of the project as well.

No comments: