Adding jars to your OpenShift remote Maven repo

If your OpenShift app has dependencies on other Jars that are not publicly available in the usual maven repos (for example, other Jars from your own projects), you can push them to your remote Maven repo used when your app builds remotely.

Commit the jar in the root of your OpenShift project.

Edit .openshift/action_hooks/pre_build and add the following, updating Jar name etc:

mvn install:install-file --debug -Dfile=../../YourProjectName/runtime/repo/YourJarName.jar
  -DgeneratePom=true -DartifactId=YourArtifactName -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar

Commit your changes and push to OpenShift – the jar will get installed to your remote repo, and now you can add a Maven dependency against it in your project’s pom.xml.

2 Replies to “Adding jars to your OpenShift remote Maven repo”

  1. I am finding a problem in following your model: my JBossAS + mongodb project, while using maven, has no local runtime/repo folder: am I supposed to put the jar somewhere else (e.g., in the root of my local application) and let the git commit process send it into the (not local) runtime/repo folder? Thank you

    1. Yes, commit your jar to the root of your local src project, and then when you push, it will end up in runtime/repo in your OpenShift app account online, which is at a file location relative to where the action_hook runs as ../..

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.