Populate Your Maven Repo With Mule ESB Libraries
Join the DZone community and get the full member experience.
Join For Free
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> <server> <id>artifactory</id> <username>admin</username> <password>password</password> </server> </servers>
mvn(["install:install-file", "-dgroupid=${project.groupid}", "-dartifactid=${project.artifactid}", "-dversion=${version}", "-dpackaging=pom", "-dfile=${localpom.canonicalpath}"])with
mvn(["deploy:deploy-file", "-dgroupid=${project.groupid}", "-dartifactid=${project.artifactid}", "-dversion=${version}", "-dpackaging=pom", "-dfile=${localpom.canonicalpath}", "-drepositoryid=arti", "-durl=http://localhost:8080/artifactory/libs-release-local" ])and do the same for the line:
def args = ["install:install-file", "-dgroupid=${pomprops.groupid}", "-dartifactid=${pomprops.artifactid}", "-dversion=${pomprops.version}", "-dpackaging=jar", "-dfile=${f.canonicalpath}", "-dpomfile=${localpom.canonicalpath}"]by replacing it with:
def args = ["deploy:deploy-file", "-dgroupid=${pomprops.groupid}", "-dartifactid=${pomprops.artifactid}", "-dversion=${pomprops.version}", "-dpackaging=jar", "-dfile=${f.canonicalpath}", "-dpomfile=${localpom.canonicalpath}", "-drepositoryid=arti", "-durl=http://localhost:8080/artifactory/libs-release-local" ]now you can run the script with:
./populate_m2_repo blaas 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
Published at DZone with permission of $$anonymous$$. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments