Page tree
Skip to end of metadata
Go to start of metadata

The Maven Repository used by OpenMRS is SonaType Nexus:
http://mavenrepo.openmrs.org/nexus/

All artifacts needed for building the OpenMRS application and modules using Maven are managed in this repository, including:

  • Releases
    • Maven built releases (1.8.0 and later)
    • Ant built releases (1.5.0 up to 1.7.X)
  • Snapshots
    • Maven development versions
  • Modules
    • Module releases
  • 3rd party
    • Libraries not found in other Maven repositories (HAPI)
    • Modified libraries (DWR, Hibernate, Liquibase, Simple XML)
    • Custom Maven plugins (OpenMRS omod plugin)

Deploying releases using Nexus

The Ant releases must use this method. First follow the Prepare for Ant releases steps below to create the pom files.
Maven releases can use this or the Maven method below.

  • Login to OpenMRS Nexus
  • Under View/Repositories on the left, select Repositories
  • Select Releases (or Modules if you are deploying a module) in the list 
  • Select Artifact Upload in the bottom section tabs
  • Under GAV Definition, choose From POM
  • Make sure you do not uncheck the "Auto Guess" option

Deploy each artifact separately using the steps below.
These include the parent pom, api jar, tests jar, web jar, and webapp war.
For the parent pom, there are no artifacts to choose other than the pom.

  • Click Select POM to Upload...
    • Choose the pom.xml file for the artifact
  • Click Select Artifact(s) to Upload
    • Choose the artifact file
  • Make sure the Extension is correct (jar or war)
  • Click Add Artifact

If including source code for this artifact,

  • Click Select Artifact(s) to Upload
    • Choose the source code artifact file
  • Make sure the Classifier is sources and Extension is jar
  • Click Add Artifact

If including Javadocs for this artifact,

  • Click Select Artifact(s) to Upload
    • Choose the Javadocs artifact file
  • Make sure the Classifier is javadoc and Extension is jar
  • Click Add Artifact
  • Click Upload Artifact(s)
  • Wait for the process to complete

Repeat the upload process for each artifact.
Verify the artifacts were uploaded successfully:

  • Select Browse Storage in the bottom section tabs
  • Navigate down the tree and verify the uploaded versions are available.

If there is a problem with the upload,

  • Right click the version directory in the tree
  • Select Delete to re-upload the artifacts and pom

Deploying releases using Maven

Update your Maven settings.xml to include the OpenMRS Nexus server. You will need to add valid login credentials with roles to modify the repositories. If you do not have these then submit an IT Support ticket to request them.

<settings>
  ...
  <servers>
    <server>
      <id>openmrs-repo</id>
      <username>joeuser</username>
      <password>******</password>
    </server>
 </servers>
</settings>

Checkout the release tag from Subversion.

To build and deploy the project,
Run mvn clean deploy

Specific information about deploying a OpenMRS module to the maven repo can be found here.

For this deployment strategy to work, the key is that the server id in your settings corresponds to the id in your project's distributionManagement id in your project's main pom.  So, for example in the settings above, openmrs-repo-modules corresponds to the distributionManagement id that i have in my module's main pom:

<distributionManagement>
     <repository>
          <id>openmrs-repo</id>
          <name>Modules</name>
          <url>http://mavenrepo.openmrs.org/nexus/content/repositories/modules/</url>
     </repository>
</distributionManagement>

Prepare Poms for Ant releases

Ant built artifacts should have Maven pom.xml files created (with actual dependencies) to be useful for Maven omod module projects.

Start with the pom files from the previous version (1.6.2 for 1.6.3)
These can be downloaded from Nexus (parent, api, tests, web, and webapp poms)

If no libraries have changed (added, removed, or new version), simply update the version in the poms
Otherwise if libraries have changed, the dependencies will need to also be updated

  • Parent pom
    • New project version
    • New version in all scm urls (after tags)
    • New dependency version or add/remove dependency
  • API pom
    • New parent version
    • Dependency add/remove
  • Tests pom
    • New parent version
    • Dependency add/remove
  • Web pom
    • New parent version
    • Dependency add/remove
  • Webapp pom
    • New parent version

When releasing 1.6.6 and 1.7.4 please make sure that the API pom has commons-io and commons-beanutils, which has not been included by mistake.

Prepare Artifacts for Ant releases

Run the Ant goals to build the jars and war, javadoc and sources (if possible)

For api, tests, and web jars:
ant package-all
For api Javadocs zip:
ant package-javadoc-api
For war:
ant package-web
For source:
ant assembly

A new sources target would need to be created, matching the jar includes/excludes in the package targets for api, tests, and web.
This is not required but is helpful for debugging.

Deploying Ant releases manually

You can run these at the command line in order to upload artifacts:

mvn org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file -Durl=http://mavenrepo.openmrs.org/nexus/content/repositories/releases -DrepositoryId=openmrs-repo-releases -DpomFile=openmrs-1.7.3.pom -Dfile=openmrs-1.7.3.pom

mvn org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file -Durl=http://mavenrepo.openmrs.org/nexus/content/repositories/releases -DrepositoryId=openmrs-repo-releases -Dfile=openmrs-api-1.7.3.24462.jar -DpomFile=openmrs-api-1.7.3.pom -Dclassifiers=tests -Dtypes=jar -Dfiles=openmrs-api-1.7.3.24462-tests.jar

mvn org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file -Durl=http://mavenrepo.openmrs.org/nexus/content/repositories/releases -DrepositoryId=openmrs-repo-releases -Dfile=openmrs-web-1.7.3.24462.jar -DpomFile=openmrs-web-1.7.3.pom -Dclassifiers=tests -Dtypes=jar -Dfiles=openmrs-web-1.7.3.24462-tests.jar

mvn org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file -Durl=http://mavenrepo.openmrs.org/nexus/content/repositories/releases -DrepositoryId=openmrs-repo-releases -DpomFile=openmrs-test-1.7.3.pom -Dfile=openmrs-api-1.7.3.24462-tests.jar

To see how to generate the jars and the modified poms, see previous section.

Note that when deploying openmrs-test.pom, you need to point to api tests jar. It is not correct, but we need to do it for backwards compatibility with previously deployed versions.

Adding 3rd Party Libraries to Nexus

If you cannot find a library you need to use in OpenMRS at http://mavenrepo.openmrs.org/ please create a ticket for the ITSM project in JIRA. Provide the public maven repository URL where the library can be found or only if the repository is not available attach a jar file. Specify groupId, artifactId, version and where you want to use it.

  • No labels

1 Comment

  1. Not sure where else to put this, but after deploying a module to the maven repo you can also upload to the module server with this at commandline:

    curl -F moduleFile=@mymoduleid-1.0.omod -ubwolfe https://modules.openmrs.org/modules/admin/addModule