How to resolve matrix parameters in Maven build.

When you are using Maven to resolve dependencies through Artifactory, you might want to add a restriction/directive that will allow you to retrieve content which has a specific property/ies. This can be achieved by using Matrix Params.

Let’s say you have released a new version of a module (junit-3.7 for example) but you do not want it to be retrievable (by Maven) before it is approved in some way. In this case, you can add properties to the artifact/module that signify that it is permitted for resolution. However, you will also need some way for Maven to reject the download.


This is how it can be achieved:

1. Let’s say you have an artifact with the following property and value in Artifactory (see the screenshot)


        2. Let’s say our POM file contains this dependency:


3.  When we execute our POM file, we get the following error:       

4.  Now, we are going to change our dependency to this: 


       5. Once the dependency is changed and saved, we are going to execute our POM file again. In this case, the message will show that the dependencies are found and downloaded successfully due to matrix parameter in the resolution URL and the matching property: