Skip to content

Commit 0f1b99b

Browse files
authored
Simplify one-off pom generation (#215)
1 parent a049954 commit 0f1b99b

File tree

1 file changed

+12
-32
lines changed

1 file changed

+12
-32
lines changed

misc/extdeps_pomgen.py

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
from common import maveninstallinfo
1313
from config import config
1414
from crawl import buildpom
15-
from crawl import dependency
1615
from crawl import dependencymd as dependencymdm
1716
from crawl import pom
1817
from crawl import pomcontent
1918
from crawl import workspace
2019
import argparse
21-
import os
2220
import sys
2321

2422

@@ -42,10 +40,6 @@ def _parse_arguments(args):
4240
help="optional - the artifactId to use in the generated pom")
4341
parser.add_argument("--version", type=str, required=False,
4442
help="optional - the version to use in the generated pom")
45-
parser.add_argument("--exclude_all_transitives", action="store_true",
46-
required=False,
47-
help="optional - adds a *:* <exclusion> to all dependencies in the generated pom")
48-
4943
return parser.parse_args(args)
5044

5145

@@ -110,32 +104,18 @@ def main(args):
110104
# to be nice:
111105
dependencies.sort()
112106

113-
if args.exclude_all_transitives:
114-
# since all dependencies are treated equally (no transitives),
115-
# we can dedupe them without losing anything
116-
# we use a representation that includes the version when checking
117-
# whether we have already included the dep
118-
deps_set = set()
119-
updated_dependencies = []
120-
for dep in dependencies:
121-
dedupe_key = dep.maven_coordinates_name + ":" + dep.version
122-
if dedupe_key not in deps_set:
123-
deps_set.add(dedupe_key)
124-
updated_dependencies.append(dep)
125-
dependencies = updated_dependencies
126-
127-
# ignore what was specified in the pinned dependencies files and instead
128-
# exclude all transitives: add an "exclude all dependency"
129-
# (* exclusions) for all dependencies that end up in the generated pom
130-
ws.dependency_metadata.clear()
131-
for dep in dependencies:
132-
ws.dependency_metadata.register_exclusions(
133-
dep, [dependency.EXCLUDE_ALL_PLACEHOLDER_DEP])
134-
else:
135-
# it is possible to end up with duplicate dependencies
136-
# because different labels may point to the same dependency (gav)
137-
# (for ex: @maven//:org_antlr_ST4 and @antlr//:org_antlr_ST4)
138-
pass
107+
# since all dependencies are treated equally (no transitives),
108+
# we can dedupe them without losing anything
109+
# we use a representation that includes the version when checking
110+
# whether we have already included the dep
111+
deps_set = set()
112+
updated_dependencies = []
113+
for dep in dependencies:
114+
dedupe_key = dep.maven_coordinates_name + ":" + dep.version
115+
if dedupe_key not in deps_set:
116+
deps_set.add(dedupe_key)
117+
updated_dependencies.append(dep)
118+
dependencies = updated_dependencies
139119

140120
pomgen = ThirdPartyDepsPomGen(ws, artifact_def, dependencies,
141121
cfg.pom_template)

0 commit comments

Comments
 (0)