Skip to content

Commit

Permalink
DP-14758 - add classifier to generated pom (#17)
Browse files Browse the repository at this point in the history
* add classifier to generated pom

* fix typo
  • Loading branch information
vinnybod authored Jul 30, 2024
1 parent 6e0d9e0 commit e144c49
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions private/rules/maven_utils.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def unpack_coordinates(coords):
"""Takes a maven coordinate and unpacks it into a struct with fields
`groupId`, `artifactId`, `version`, `type`, `scope`
`groupId`, `artifactId`, `version`, `type`, `classifier`
where type and scope are optional.
Assumes following maven coordinate syntax:
groupId:artifactId[:type[:scope]]:version
groupId:artifactId[:type[:classifer]]:version
"""
if not coords:
return None
Expand All @@ -18,6 +18,7 @@ def unpack_coordinates(coords):
artifactId = parts[1],
type = None,
scope = None,
classifier = None,
version = None,
)

Expand All @@ -30,7 +31,8 @@ def unpack_coordinates(coords):
groupId = parts.get(0),
artifactId = parts.get(1),
type = parts.get(2),
scope = parts.get(3),
scope = None,
classifier = parts.get(3),
version = version,
)

Expand Down Expand Up @@ -70,6 +72,12 @@ def format_dep(unpacked, indent = 8, include_version = True, exclusions = {}):
" <scope>%s</scope>\n" % unpacked.scope,
])

if unpacked.classifier:
dependency.extend([
whitespace,
" <classifier>%s</classifier>\n" % unpacked.classifier,
])

if exclusions:
dependency.extend([
whitespace,
Expand Down Expand Up @@ -115,6 +123,7 @@ def generate_pom(
"{artifactId}": unpacked_coordinates.artifactId,
"{version}": unpacked_coordinates.version,
"{type}": unpacked_coordinates.type or "jar",
"{classifier}": unpacked_coordinates.classifier or "",
"{scope}": unpacked_coordinates.scope or "compile",
}

Expand Down Expand Up @@ -147,6 +156,7 @@ def generate_pom(
artifactId = unpacked.artifactId,
type = unpacked.type,
scope = new_scope,
classifier = unpacked.classifier,
version = unpacked.version,
)
deps.append(format_dep(unpacked, indent = indent, exclusions = exclusions.get(dep, {}), include_version = include_version))
Expand Down

0 comments on commit e144c49

Please sign in to comment.