Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7124523
D759.id2393.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D759.id2393.diff
View Options
diff --git a/swh/indexer/metadata_dictionary.py b/swh/indexer/metadata_dictionary.py
--- a/swh/indexer/metadata_dictionary.py
+++ b/swh/indexer/metadata_dictionary.py
@@ -246,6 +246,7 @@
d = xmltodict.parse(content)['project']
metadata = self.translate_dict(d, normalize=False)
metadata[SCHEMA_URI+'codeRepository'] = self.parse_repositories(d)
+ metadata[SCHEMA_URI+'license'] = self.parse_licenses(d)
return self.normalize_translation(metadata)
_default_repository = {'url': 'https://repo.maven.apache.org/maven2/'}
@@ -278,6 +279,13 @@
def normalize_groupId(self, id_):
return {"@id": id_}
+ def parse_licenses(self, d):
+ """https://maven.apache.org/pom.html#Licenses"""
+ licenses = d.get('licenses', {}).get('license', [])
+ if isinstance(licenses, dict):
+ licenses = [licenses]
+ return [{"@id": license['url']} for license in licenses]
+
def main():
raw_content = """{"name": "test_name", "unknown_term": "ut"}"""
diff --git a/swh/indexer/tests/test_metadata.py b/swh/indexer/tests/test_metadata.py
--- a/swh/indexer/tests/test_metadata.py
+++ b/swh/indexer/tests/test_metadata.py
@@ -426,6 +426,14 @@
</snapshots>
</repository>
</repositories>
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ <comments>A business-friendly OSS license</comments>
+ </license>
+ </licenses>
</project>"""
result = MAPPINGS["MavenMapping"].translate(raw_content)
self.assertEqual(result, {
@@ -434,6 +442,7 @@
'name': 'Maven Default Project',
'identifier': 'com.mycompany.app',
'version': '1.2.3',
+ 'license': 'https://www.apache.org/licenses/LICENSE-2.0.txt',
'codeRepository':
'http://repo1.maven.org/maven2/com/mycompany/app/my-app',
})
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 21 2024, 12:52 PM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3225618
Attached To
D759: Parse Maven licenses.
Event Timeline
Log In to Comment