in src/python/pants/backend/jvm/tasks/coursier_resolve.py [0:0]
def _construct_cmd_args(jars, common_args, global_excludes,
pinned_coords, coursier_workdir, json_output_path):
# Make a copy, so there is no side effect or others using `common_args`
cmd_args = list(common_args)
cmd_args.extend(['--json-output-file', json_output_path])
# Dealing with intransitivity and forced versions.
for j in jars:
if not j.rev:
raise TaskError('Undefined revs for jars unsupported by Coursier. "{}"'.format(repr(j.coordinate).replace('M2Coordinate', 'jar')))
module = j.coordinate.simple_coord
if j.coordinate.classifier:
module += ',classifier={}'.format(j.coordinate.classifier)
if j.get_url():
jar_url = j.get_url()
module += ',url={}'.format(parse.quote_plus(jar_url))
if j.intransitive:
cmd_args.append('--intransitive')
cmd_args.append(module)
# Force requires specifying the coord again with -V
if j.force:
cmd_args.append('-V')
cmd_args.append(j.coordinate.simple_coord)
# Force pinned coordinates
for m2coord in pinned_coords:
cmd_args.append('-V')
cmd_args.append(m2coord.simple_coord)
# Local exclusions
local_exclude_args = []
for jar in jars:
for ex in jar.excludes:
# `--` means exclude. See --local-exclude-file in `coursier fetch --help`
# If ex.name does not exist, that means the whole org needs to be excluded.
ex_arg = "{}:{}--{}:{}".format(jar.org, jar.name, ex.org, ex.name or '*')
local_exclude_args.append(ex_arg)
if local_exclude_args:
with temporary_file(coursier_workdir, cleanup=False) as f:
exclude_file = f.name
with open(exclude_file, 'w') as ex_f:
ex_f.write('\n'.join(local_exclude_args))
cmd_args.append('--local-exclude-file')
cmd_args.append(exclude_file)
for ex in global_excludes:
cmd_args.append('-E')
cmd_args.append('{}:{}'.format(ex.org, ex.name or '*'))
return cmd_args