Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ dev_maven.install(
name = "jvm_import_test",
artifacts = [
"com.google.code.findbugs:jsr305:3.0.2",
"com.android.support:appcompat-v7:aar:28.0.0",
"com.android.support:appcompat-v7:28.0.0@aar",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! Yes!

],
repositories = [
"https://repo1.maven.org/maven2",
Expand Down Expand Up @@ -605,7 +605,7 @@ dev_maven.install(
"com.github.fommil.netlib:all:1.1.2",
"nz.ac.waikato.cms.weka:weka-stable:3.8.1",
# https://github.com/bazelbuild/rules_jvm_external/issues/111
"com.android.support:appcompat-v7:aar:28.0.0",
"com.android.support:appcompat-v7:28.0.0@aar",
"com.google.android.gms:play-services-base:16.1.0",
# https://github.com/bazelbuild/rules_jvm_external/issues/119#issuecomment-484278260
"org.apache.flink:flink-test-utils_2.12:1.8.0",
Expand Down Expand Up @@ -638,14 +638,14 @@ dev_maven.install(
# https://github.com/bazelbuild/rules_jvm_external/issues/917
# androidx core-testing POM has "exclusion" for "byte-buddy" but it should be downloaded as mockito-core
# dependency when the usually omitted "jar" packaging type is specified.
"org.mockito:mockito-core:jar:3.3.3",
"androidx.arch.core:core-testing:aar:2.1.0",
"org.mockito:mockito-core:3.3.3@jar",
"androidx.arch.core:core-testing:2.1.0@aar",
# https://github.com/bazelbuild/rules_jvm_external/issues/1028
"build.buf:protovalidate:0.1.9",
# https://github.com/bazelbuild/rules_jvm_external/issues/1250
"com.github.spotbugs:spotbugs:4.7.0",
# https://github.com/bazelbuild/rules_jvm_external/issues/1267
"org.mockito:mockito-core:pom:3.3.3",
"org.mockito:mockito-core:3.3.3@pom",
],
generate_compat_repositories = True,
lock_file = "//tests/custom_maven_install:regression_testing_coursier_install.json",
Expand Down
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ maven_install(
"com.github.fommil.netlib:all:1.1.2",
"nz.ac.waikato.cms.weka:weka-stable:3.8.1",
# https://github.com/bazelbuild/rules_jvm_external/issues/111
"com.android.support:appcompat-v7:aar:28.0.0",
"com.android.support:appcompat-v7:28.0.0@aar",
"com.google.android.gms:play-services-base:16.1.0",
# https://github.com/bazelbuild/rules_jvm_external/issues/119#issuecomment-484278260
"org.apache.flink:flink-test-utils_2.12:1.8.0",
Expand Down Expand Up @@ -269,14 +269,14 @@ maven_install(
# https://github.com/bazelbuild/rules_jvm_external/issues/917
# androidx core-testing POM has "exclusion" for "byte-buddy" but it should be downloaded as mockito-core
# dependency when the usually omitted "jar" packaging type is specified.
"org.mockito:mockito-core:jar:3.3.3",
"androidx.arch.core:core-testing:aar:2.1.0",
"org.mockito:mockito-core:3.3.3@jar",
"androidx.arch.core:core-testing:2.1.0@aar",
# https://github.com/bazelbuild/rules_jvm_external/issues/1028
"build.buf:protovalidate:0.1.9",
# https://github.com/bazelbuild/rules_jvm_external/issues/1250
"com.github.spotbugs:spotbugs:4.7.0",
# https://github.com/bazelbuild/rules_jvm_external/issues/1267
"org.mockito:mockito-core:pom:3.3.3",
"org.mockito:mockito-core:3.3.3@pom",
# https://github.com/bazelbuild/rules_jvm_external/issues/1345
maven.artifact(
artifact = "jffi",
Expand Down
12 changes: 6 additions & 6 deletions private/coursier_utilities.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def to_repository_name(coords):

return escape(to_return)

def _to_legacy_format(coord, include_version):
unpacked = unpack_coordinates(coord)
def _to_legacy_format(coord, include_version, is_test = False):
unpacked = unpack_coordinates(coord, is_test = is_test)

to_return = "%s:%s" % (unpacked.group, unpacked.artifact)

Expand All @@ -77,7 +77,7 @@ def _to_legacy_format(coord, include_version):

return to_return

def strip_packaging_and_classifier(coord):
def strip_packaging_and_classifier(coord, is_test = False):
# Strip some packaging and classifier values.
#
# We are expected to return one of:
Expand All @@ -86,10 +86,10 @@ def strip_packaging_and_classifier(coord):
# groupId:artifactId:packaging:version
# groupId:artifactId:packaging:classifier:version

return _to_legacy_format(coord, True)
return _to_legacy_format(coord, True, is_test = is_test)

def strip_packaging_and_classifier_and_version(coord):
return _to_legacy_format(coord, False)
def strip_packaging_and_classifier_and_version(coord, is_test = False):
return _to_legacy_format(coord, False, is_test = is_test)

def match_group_and_artifact(source, target):
source_coord = unpack_coordinates(source)
Expand Down
5 changes: 3 additions & 2 deletions private/lib/coordinates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SUPPORTED_PACKAGING_TYPES = [
"test-jar",
]

def unpack_coordinates(coords):
def unpack_coordinates(coords, is_test = False):
"""Takes a maven coordinate and unpacks it into a struct with fields
`group`, `artifact`, `version`, `packaging`, `classifier`
where `version,` `packaging` and `classifier` may be `None`
Expand Down Expand Up @@ -82,7 +82,8 @@ def unpack_coordinates(coords):
packaging = pieces[2]
version = pieces[3]
rewritten = "%s:%s:%s@%s" % (group, artifact, version, packaging)
print("Assuming %s should be interpreted as %s" % (coords, rewritten))
if not is_test:
print("Assuming %s should be interpreted as %s" % (coords, rewritten))
return struct(group = group, artifact = artifact, packaging = packaging, version = version, classifier = None)

# We could still be in one of `g:a:p:v` or `g:a:v:c`, but it's likely the latter. I do not
Expand Down
2 changes: 1 addition & 1 deletion private/rules/maven_bom.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _maven_dependencies_bom_impl(ctx):
ctx,
coordinates = ctx.attr.maven_coordinates,
is_bom = True,
versioned_dep_coordinates = combined_deps + ["%s:%s:pom:%s" % (unpacked.group, unpacked.artifact, unpacked.version)],
versioned_dep_coordinates = combined_deps + ["%s:%s:%s@pom" % (unpacked.group, unpacked.artifact, unpacked.version)],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make this change regardless of what we do with the rest or the PR

pom_template = ctx.file.pom_template,
out_name = "%s.xml" % ctx.label.name,
indent = 12,
Expand Down
2 changes: 2 additions & 0 deletions private/rules/maven_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def generate_pom(
substitutions.update({"{parent}": "".join(parts)})

deps = []
# print("versioned_dep_coordinates = {}".format(versioned_dep_coordinates))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be deleted

# print("unversioned_dep_coordinates = {}".format(unversioned_dep_coordinates))
for dep in sorted(versioned_dep_coordinates) + sorted(unversioned_dep_coordinates):
include_version = dep in versioned_dep_coordinates
unpacked = _unpack_coordinates(dep)
Expand Down
14 changes: 8 additions & 6 deletions private/rules/v1_lock_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _get_artifacts(lock_file_contents):

return to_return

def add_netrc_entries_from_mirror_urls(netrc_entries, mirror_urls):
def add_netrc_entries_from_mirror_urls(netrc_entries, mirror_urls, is_test = False):
"""Add a url's auth credentials into a netrc dict of form return[machine][login] = password."""
for url in mirror_urls:
entry = extract_netrc_from_auth_url(url)
Expand All @@ -113,14 +113,16 @@ def add_netrc_entries_from_mirror_urls(netrc_entries, mirror_urls):
netrc_entries[machine] = {}
if login not in netrc_entries[machine]:
if netrc_entries[machine]:
print("Received multiple logins for machine '{}'! Only using '{}'".format(
machine,
netrc_entries[machine].keys()[0],
))
if not is_test:
print("Received multiple logins for machine '{}'! Only using '{}'".format(
machine,
netrc_entries[machine].keys()[0],
))
continue
netrc_entries[machine][login] = password
elif netrc_entries[machine][login] != password:
print("Received different passwords for {}@{}! Only using the first".format(login, machine))
if not is_test:
print("Received different passwords for {}@{}! Only using the first".format(login, machine))
return netrc_entries

def _get_netrc_entries(lock_file_contents):
Expand Down
4 changes: 2 additions & 2 deletions specs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def _parse_exclusion_spec_list(exclusion_specs):
exclusions.append(exclusion_spec)
return exclusions

def _parse_maven_coordinate_string(mvn_coord):
def _parse_maven_coordinate_string(mvn_coord, is_test = False):
"""
Given a string containing a standard Maven coordinate (g:a:[p:[c:]]v) or gradle external dependency (g:a:v:c@p), returns a maven artifact map (see above).
"""
unpacked = unpack_coordinates(mvn_coord)
unpacked = unpack_coordinates(mvn_coord, is_test = is_test)

# It would be nice to use `bazel_skylib//lib:structs.bzl` for this, but this file is
# included from the `repositories.bzl` file, so skylib has not been loaded yet.
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/coordinates_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ complete_original_format_test = unittest.make(_complete_original_format_impl)
def _original_format_omitting_scope_impl(ctx):
env = unittest.begin(ctx)

unpacked = unpack_coordinates("group:artifact:test-jar:1.2.3")
unpacked = unpack_coordinates("group:artifact:test-jar:1.2.3", is_test = True)
asserts.equals(env, "group", unpacked.group)
asserts.equals(env, "artifact", unpacked.artifact)
asserts.equals(env, "1.2.3", unpacked.version)
Expand Down Expand Up @@ -108,7 +108,7 @@ def _multiple_formats_impl(ctx):
}

for (coords, expected) in coords_to_structs.items():
unpacked = unpack_coordinates(coords)
unpacked = unpack_coordinates(coords, is_test = True)
asserts.equals(env, expected, unpacked)

return unittest.end(env)
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/coursier_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _add_netrc_entries_from_mirror_urls_noop_test_impl(ctx):
asserts.equals(
env,
{},
add_netrc_entries_from_mirror_urls({}, ["https://c1", "https://c1/something@there"]),
add_netrc_entries_from_mirror_urls({}, ["https://c1", "https://c1/something@there"], is_test = True),
)
return unittest.end(env)

Expand All @@ -247,14 +247,15 @@ def _add_netrc_entries_from_mirror_urls_basic_test_impl(ctx):
asserts.equals(
env,
{"c1": {"a": "b"}},
add_netrc_entries_from_mirror_urls({}, ["https://a:b@c1"]),
add_netrc_entries_from_mirror_urls({}, ["https://a:b@c1"], is_test = True),
)
asserts.equals(
env,
{"c1": {"a": "b"}},
add_netrc_entries_from_mirror_urls(
{"c1": {"a": "b"}},
["https://a:b@c1"],
is_test = True,
),
)
return unittest.end(env)
Expand All @@ -266,14 +267,15 @@ def _add_netrc_entries_from_mirror_urls_multi_login_ignored_test_impl(ctx):
asserts.equals(
env,
{"c1": {"a": "b"}},
add_netrc_entries_from_mirror_urls({}, ["https://a:b@c1", "https://a:b2@c1", "https://a2:b3@c1"]),
add_netrc_entries_from_mirror_urls({}, ["https://a:b@c1", "https://a:b2@c1", "https://a2:b3@c1"], is_test = True),
)
asserts.equals(
env,
{"c1": {"a": "b"}},
add_netrc_entries_from_mirror_urls(
{"c1": {"a": "b"}},
["https://a:b@c1", "https://a:b2@c1", "https://a2:b3@c1"],
is_test = True,
),
)
return unittest.end(env)
Expand All @@ -292,6 +294,7 @@ def _add_netrc_entries_from_mirror_urls_multi_case_test_impl(ctx):
add_netrc_entries_from_mirror_urls(
{"foo": {"bar": "baz"}},
["https://a1:b1@c1", "https://a2:b2@c2", "https://a:b@c1", "https://a:b2@c1", "https://a2:b3@c1"],
is_test = True,
),
)
return unittest.end(env)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/coursier_utilities_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _strip_packaging_and_classifier_test_impl(ctx):
asserts.equals(
env,
"groupId:artifactId:1.2.3",
strip_packaging_and_classifier("groupId:artifactId:bundle:1.2.3"),
strip_packaging_and_classifier("groupId:artifactId:bundle:1.2.3", is_test = True),
)
asserts.equals(
env,
Expand All @@ -75,7 +75,7 @@ def _strip_packaging_and_classifier_and_version_test_impl(ctx):
asserts.equals(
env,
"groupId:artifactId",
strip_packaging_and_classifier_and_version("groupId:artifactId:bundle:1.2.3"),
strip_packaging_and_classifier_and_version("groupId:artifactId:bundle:1.2.3", is_test = True),
)
asserts.equals(
env,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/specs_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _parse_coordinate_test_impl(ctx):
asserts.equals(
env,
{"group": "org.eclipse.aether", "artifact": "aether-api", "version": "1.1.0", "packaging": "jar", "classifier": None},
parse.parse_maven_coordinate("org.eclipse.aether:aether-api:jar:1.1.0"),
parse.parse_maven_coordinate("org.eclipse.aether:aether-api:jar:1.1.0", is_test = True),
)
asserts.equals(
env,
Expand Down