Converting Code License to MPL 2.0 with Healthcare Disclaimer
So, you have some code (e.g., a module) that you want to convert to use the standard OpenMRS licensing (MPL 2.0 with Healthcare Disclaimer). We are using the License Maven Pluginto manage license headers within code. See the pom.xml in openmrs-corefor an example of how this plugin is configured within the main project pom.xml.
Before converting the license for a repository, be certain that you have the authority to change the license. Changing the license of your own work or changing the license for a repository owned & managed by the OpenMRS community should not be an issue, but if you are using a repository forked from a third party, you may not have the authority to simply re-license their code without their permission.
Recipe for adopting MPL 2.0 HD license
This recipe assumes
- You have a githubrepository that you wish to license under MPL 2.0 with Healthcare Disclaimer.
- You are using a unix-based system (Mac or Linux). Some steps may need to be altered to work within Windows; alternatively, a Windows user could spin up a Digital Oceandroplet with Ubuntu long enough to perform these steps.
This recipe will also convert all of your line endings to LF (line feed) to follow the OpenMRS conventions of storing LF in github and letting git convert line feeds magically based on the client.
Steps
- If you don't already have it, install dos2unix(e.g.,
sudo apt-get install dos2unix
) - Copy the LICENSEand license.txtfiles from openmrs-core to the root folder of your repository and remove any prior license or license header files if they exist.
- Copy the .gitattributesfile from openmrs-core to your repository.
Convert line endings to line feeds. You can use dos2unix on your entire repository. Alternatively, if you have Java and Groovy installed in your environment, you can use the attached scan-newlines groovy script (download & make executable with
chmod +x scan-newlines
):$ /path/to/scan-newlines | xargs dos2unix
Assuming you have Java & Groovy installed, scan files for non-OpenMRS licenses using the attached scan-licenses groovy script (download, make executable with
chmod +x scan-licenses
):$ /path/to/scan-licenses
If you don't have Groovy installed, then you should scan the files in your repository manually and/or using git to check for any code that is already separately licensed. For example, the following grep command will look for files containing any references to the old "OpenMRS Public License":
$ grep -R "OpenMRS Public" *
It is critical that these files be excluded from the licensing plugin so the proper licenses are not illegally overwritten with an OpenMRS license. You can see examples of exceptions in the openmrs-core pom.xml directive for the maven license plugin.
- Update your pom.xml file.
- Add a directive for the maven license plugin similar to the openmrs-core pom.xml.
- Update the <licenses> directive similar to the openmrs-core pom.xml.
Once you have updated your pom.xml to use the maven license plugin and have excluded any files or folders that contain separately licensed code, you can use a maven directive to apply the MPL 2.0 HD license header to your code:
$ mvn license:format
Running
mvn license:format
without excluding files under separate licenses or converting to line feed (LF) line endings could inappropriate (even illegally) overwrite existing non-OpenMRS licenses or have unpredictable results. When you are first converting a repository's license, we highly recommend first making a copy of your local copy so you can easily recover if something goes wrong.Confirm that your local copy still builds and passes all tests. If it does, then you are ready to commit changes:
$ git add --all . $ git commit -m "Convert to MPL 2.0 HD and standard line endings"
Using the Maven License Plugin
Once a repository has been converted over to using the maven license plugin, you can easily check and update licenses.
Check for missing license headers:
$ mvn license:check
Update license headers:
$ mvn license:format
Resources
- See the Maven License Plugin by myciladocumentation.