While developing custom modules it is important to deploy the latest versions of snapshots to Nexus on commits to the master branch and merging of pull requests. 

Prerequisites 

  1. Nexus Account - request one by creating a help desk ticket at https://help.openmrs.org/
  2. Maven setup - a sample configuration is below 
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <localRepository>${user.home}/.m2/repository</localRepository>
  <servers>
    <server>
      <username>{nexus_username}</username>
      <password>{nexus_password}</password>
      <id>openmrs-repo</id>
    </server>
    <server>
      <username>{nexus_username}</username>
      <password>{nexus_password}</password>
      <id>openmrs-repo-releases</id>
    </server>
    <server>
      <username>{nexus_username}</username>
      <password>{nexus_password}</password>
      <id>openmrs-repo-snapshots</id>
    </server>
    <server>
      <username>{nexus_username}</username>
      <password>{nexus_password}</password>
      <id>openmrs-repo-modules</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <properties>
        <archetypeRepository>http://mavenrepo.openmrs.org/nexus/content/repositories/public</archetypeRepository>
        <archetypeCatalog>http://mavenrepo.openmrs.org/nexus/content/repositories/public/archetype-catalog.xml</archetypeCatalog>
      </properties>
      <repositories>
        <repository>
          <id>openmrs-repo</id>
          <name>OpenMRS Nexus Repository</name>
          <url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
        </repository>
        <repository>
          <id>openmrs-repo-thirdparty</id>
          <name>OpenMRS Thirdparty Nexus Repository</name>
          <url>http://mavenrepo.openmrs.org/nexus/content/repositories/thirdparty</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>openmrs-repo</id>
          <name>OpenMRS Nexus Repository</name>
          <url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
        </pluginRepository>
      </pluginRepositories>
      <id>openmrs</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>openmrs</activeProfile>
  </activeProfiles>
  <pluginGroups>
    <pluginGroup>org.openmrs.maven.plugins</pluginGroup>
  </pluginGroups>
</settings>
  1. Project distribution management in the module pom.xml
<distributionManagement>
		<repository>
			<id>openmrs-repo-modules</id>
			<name>OpenMRS Modules</name>
			<url>http://mavenrepo.openmrs.org/nexus/content/repositories/modules</url>
		</repository>
		<snapshotRepository>
			<id>openmrs-repo-snapshots</id>
			<name>OpenMRS Snapshots</name>
			<url>http://mavenrepo.openmrs.org/nexus/content/repositories/snapshots</url>
		</snapshotRepository>
	</distributionManagement>

Step-by-step guide

  1. Run `mvn clean deploy` to test the configuration of the snapshots deployment
  2. Add .travis.yml and maven-settings.xml files below to the root of your project
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
   <servers>
      <server>
         <id>openmrs-repo-snapshots</id>
         <username>${env.OPENMRS_REPO_USERNAME}</username>
         <password>${env.OPENMRS_REPO_PASSWORD}</password>
      </server>
   </servers>
</settings>
before_install: "git clone -b travis `git config --get remote.origin.url` target/travis"
after_script: "mvn deploy --settings target/travis/settings.xml"
language: java
branches:
  except:
    - travis
jdk:
 - openjdk7
 - oraclejdk7
script: mvn clean install --batch-mode
matrix:
  allow_failures:
   jdk: oraclejdk7
  env:
      global:


Add encrypted versions of the nexus username and password to the .travis.yml by executing the commands below at the root of your project

travis encrypt OPENMRS_REPO_USERNAME=nexus_username --add env.global
travis encrypt OPENMRS_REPO_PASSWORD=nexus_username --add env.global

NOTE: You need to encrypt the username and password for each repository, as the encrypted values are repository specific 

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.

Related issues