in scripts/build_deps.py [0:0]
def format_dependency(line):
"""
This attempts to extract Maven dependencies and versions from a line of output from mvn dependency:tree
An example line without specifiers:
``[INFO] +- software.amazon.kinesis:amazon-kinesis-client:jar:2.1.2:compile``
This fields in the line in order are:
1. Group Id: software.amazon.kinesis
2. Artifact Id: amazon-kinesis-client
3. Packaging: jar (not used)
4. Version: 2.1.2
5. Dependency type: compile (this will be runtime or compile)
An example line with specifiers:
``[INFO] | | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.32.Final:compile``
The fields in order are:
1. Group Id: io.netty
2. Artifact Id: netty-transport-native-epoll
3. Packaging: jar (not used)
4. Specifier: linux-x86_64 (not used)
5. Version: 4.1.32.Final
6. Dependency type: compile (this will be runtime or compile)
:param str line: the line to extract version information from
:return: the version information needed to retrieve the jars from Maven Central
"""
match = re.match(r'^[\\\s+|-]*(?P<dep_line>[^\s]+)', line)
assert match is not None
items = match.groupdict()['dep_line'].split(":")
version_idx = 3
if len(items) > 5:
version_idx = 4
return "('{group_id}', '{artifact_id}', '{version}')".format(group_id=items[0],
artifact_id=items[1],
version=items[version_idx])