Library for handling licenses in APIs from Global Digital Library.
Add dependency to this library: "gdl" %% "license" % "<version>",
The main way of using this library is with the case class License
.
It accepts a string as an identifier for the license
Use SPDX License identifiers. See https://spdx.org/licenses/
A LicenseNotSupportedException
will be thrown if the string given as input is not a valid license.
Example:
class MyClass {
def doSomeLicenseHandling = {
val license1 = License("CC-BY-4.0")
val license2 = License("Apache-2.0")
println(license1)
println(license1.description)
println(license2)
println(license2.description)
}
}
Output from the above println
CC-BY-4.0
Creative Commons Attribution 4.0 International
Apache-2.0
Apache License 2.0
We have two scripts to generate licenses in this library
-
./generator/generate.py is a script to update the licenses library in the Scala module
-
./generator/generate_py_license.py is a script to generate licenses as a python dict to use in python applications
To update this library, run ./generator/generate.py
This will regenerate the content of LicenseList.scala based on the url https://spdx.org/licenses/licenses.json
sbt compile
sbt test
./build.sh
./release.sh