Closed AlanChiou closed 3 years ago
This is a python script to sort licenses YAML file by the artifact name.
# python
import re
with open('licenses.yml', 'r') as file:
data = file.read()
file.close()
licensesSplit = data.split("- artifact:")
# Remove the first empty string item
del licensesSplit[0]
licenses = []
for license in licensesSplit:
licenses.append("- artifact:" + license)
# Get the artifact name
def getArtifact(license):
return re.search(r"- artifact:\s(\b.*\n)", license).group()
# Sort licenses by the artifact name
licenses.sort(key=getArtifact)
licensesString = ""
for license in licenses:
licensesString = licensesString + license
with open('licenses.yml', 'w') as file:
file.write(licensesString)
file.close()
Released in 1.2.8
Current, the task
gradlew updateLicenses
appends missing libraries at the end of YAML file. In this case, it is hard to be reviewed and manage in source code control systems, like Git.Could the task
gradlew updateLicenses
sort all libraries alphabetically by theirartifact
if it changes the YAML file?