summaryrefslogtreecommitdiff
path: root/platform/android/scripts/generate-license.py
blob: 9e59cb4186b5e48c18071a9125542b740bf1007d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python

import os
import json

path = os.getcwd() + "/platform/android/"
with open(path + "LICENSE.md", 'w') as licenseFile:
    licenseFile.write("<!-- This file was generated. Use `make android-license` to update. -->  \n")
    licenseFile.write("## Additional Mapbox GL licenses  \n")
    with open(path + "MapboxGLAndroidSDK/build/reports/licenses/licenseReleaseReport.json", 'r') as dataFile:
        data = json.load(dataFile)

        gradleLicensePlugin ="""
        {
            "project": "Gradle License Plugin",
            "url": "https://github.com/jaredsburrows/gradle-license-plugin",
            "licenses": [
                {
                    "license": "The Apache Software License, Version 2.0",
                    "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt"
                }
             ]
        }
        """
        data.append(json.loads(gradleLicensePlugin))

        licenseName = ""
        licenseUrl = ""
        for entry in data:
            projectName = entry["project"]
            projectUrl = entry["url"]
            for license in entry["licenses"]:
                licenseName = license["license"]
                licenseUrl = license["license_url"]

            licenseFile.write("Mapbox GL uses portions of the %s.  \n" % projectName +
                              ("URL: [%s](%s)  \n" % (projectUrl, projectUrl) if projectUrl is not None else "") +
                              "License: [%s](%s)" % (licenseName, licenseUrl) +
                              "\n\n===========================================================================\n\n")