Over a million developers have joined DZone.

Populate Your Maven Repo With Mule ESB Libraries

DZone's Guide to

Populate Your Maven Repo With Mule ESB Libraries

· Integration Zone ·
Free Resource

How to Transform Your Business in the Digital Age: Learn how organizations are re-architecting their integration strategy with data-driven app integration for true digital transformation.

When you build applications based on Mule EE (Enterprise Edition) and you are using Maven to build your projects, you will notice you have dependencies to libraries that are not available in the public Maven repos. To add these libraries to your local maven repo the Mule distribution comes with a script ‘populate_m2_repo’ which is described here how to use it.

Now that is okay if you are the only developer and you are running your continuous integration on your local machine. In my case we are using Artifactory as our company Maven repository and also our build server is using it as the Maven repo. So what I wanted was not to populate my local repository but the Artifactory instance with all Mule libraries. To do so I did two things:

  • First make sure that Maven is authorised to add libraries to Artifactory. You can do this by adding the following to your settings.xml:
  • <servers>
  • Second step is to modify the original ‘populate_m2_repo.groovy’ script. Replace the following line:
    "-Dversion=${version}", "-Dpackaging=pom", 
    "-Durl=http://localhost:8080/artifactory/libs-release-local" ])
    And do the same for the line:
    def args = ["install:install-file", 
    by replacing it with:
    def args = ["deploy:deploy-file", 
    "-Durl=http://localhost:8080/artifactory/libs-release-local" ]
    Now you can run the script with:
    ./populate_m2_repo bla
    As you can see it doesn’t really matter what you supply as M2_REPO_HOME here because the libraries are uploaded to Artifactory anyway.

    If you want you can replace the hardcoded url for Artifactory in the script with the supplied parameter but in my case this solution was sufficient :-)

Make your mark on the industry’s leading annual report. Fill out the State of API Integration 2019 Survey and receive $25 to the Cloud Elements store.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}