Skip to content
Closed
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
1 change: 0 additions & 1 deletion .allstar/binary_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
ignorePaths:
- private/tools/prebuilt/hasher_deploy.jar
- private/tools/prebuilt/list_packages_deploy.jar
- private/tools/prebuilt/outdated_deploy.jar
15 changes: 10 additions & 5 deletions private/rules/coursier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,28 @@ sh_binary(
)
"""

outdated_library = Label("//private/tools/java/com/github/bazelbuild/rules_jvm_external/maven:outdated-lib")

_BUILD_OUTDATED = """
sh_binary(
java_binary(
name = "outdated",
srcs = ["outdated.sh"],
main_class = "com.github.bazelbuild.rules_jvm_external.maven.Outdated",
runtime_deps = [
"%s",
],
data = [
"@rules_jvm_external//private/tools/prebuilt:outdated_deploy.jar",
"outdated.artifacts",
"outdated.repositories",
],
args = [
"$(location @rules_jvm_external//private/tools/prebuilt:outdated_deploy.jar)",
"--artifacts-file",
"$(location outdated.artifacts)",
"--repositories-file",
"$(location outdated.repositories)",
],
visibility = ["//visibility:public"],
)
"""
""" % Label("//private/tools/java/com/github/bazelbuild/rules_jvm_external/maven:outdated-lib")

EMPTY_FILE_SHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,26 @@ java_binary(
],
)

java_library(
name = "outdated-lib",
srcs = ["Outdated.java"],
visibility = ["//visibility:public"],
deps = [
artifact(
"org.apache.maven:maven-artifact",
repository_name = "rules_jvm_external_deps",
),
],
)

# Just used for testing the binary
java_binary(
name = "outdated",
srcs = ["Outdated.java"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should srcs be replaces with runtime_deps = [":outdated-lib"], ?

main_class = "com.github.bazelbuild.rules_jvm_external.maven.Outdated",
visibility = ["//visibility:public"],
visibility = [
"//tests/com/github/bazelbuild/rules_jvm_external/maven:__pkg__",
],
deps = [
artifact(
"org.apache.maven:maven-artifact",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ public static void main(String[] args) throws IOException {
String[] artifactParts = artifact.split(":");
String groupId = artifactParts[0];
String artifactId = artifactParts[1];

// If a dependency is one where the version is selected by a BOM, there
// may not be a version number. In this case, skip the artifact.
if (artifactParts.length < 3) {
continue;
}
String version = artifactParts[2];

ArtifactReleaseInfo artifactReleaseInfo = null;
Expand Down
1 change: 0 additions & 1 deletion private/tools/prebuilt/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ exports_files([
"hasher_deploy.jar", # built from //private/tools/java/com/github/bazelbuild/rules_jvm_external:hasher-tool_deploy.jar
"index_jar_deploy.jar", # built from //private/tools/java/com/github/bazelbuild/rules_jvm_external/jar:IndexJar_deploy.jar
"lock_file_converter_deploy.jar", # built from //private/tools/java/com/github/bazelbuild/rules_jvm_external/coursier:LockFileConverter_deploy.jar
"outdated_deploy.jar", # built from //private/tools/java/com/github/bazelbuild/rules_jvm_external/maven:outdated_deploy.jar
])
Binary file removed private/tools/prebuilt/outdated_deploy.jar
Binary file not shown.
3 changes: 0 additions & 3 deletions scripts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,10 @@ sh_binary(
"lock_file_converter_deploy.jar",
"$(location //private/tools/java/com/github/bazelbuild/rules_jvm_external/jar:IndexJar_deploy.jar)",
"index_jar_deploy.jar",
"$(location //private/tools/java/com/github/bazelbuild/rules_jvm_external/maven:outdated_deploy.jar)",
"outdated_deploy.jar",
],
data = [
"//private/tools/java/com/github/bazelbuild/rules_jvm_external:hasher-tool_deploy.jar",
"//private/tools/java/com/github/bazelbuild/rules_jvm_external/coursier:LockFileConverter_deploy.jar",
"//private/tools/java/com/github/bazelbuild/rules_jvm_external/jar:IndexJar_deploy.jar",
"//private/tools/java/com/github/bazelbuild/rules_jvm_external/maven:outdated_deploy.jar",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.junit.Rule;
Expand Down Expand Up @@ -438,4 +439,32 @@ public void worksWithCommonsVersions() throws IOException {
assertThat(releaseInfo.releaseVersion, equalTo("20040616"));
assertThat(releaseInfo.preReleaseVersion, is(nullValue()));
}

@Test
public void shouldSkipArtifactWhenAnArtifactLacksAVersionNumber() throws IOException {
Path artifactsFile = temp.newFile("outdated.artifacts").toPath();
Files.write(artifactsFile, List.of("com.google.guava:guava"), StandardCharsets.UTF_8);

Path repositoriesFile = temp.newFile("outdated.repositories").toPath();
Files.write(
repositoriesFile, List.of("https://repo1.maven.org/maven2"), StandardCharsets.UTF_8);

ByteArrayOutputStream outdatedOutput = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(outdatedOutput));
Outdated.main(
new String[] {
"--artifacts-file", artifactsFile.toAbsolutePath().toString(),
"--repositories-file", repositoriesFile.toAbsolutePath().toString()
});
} finally {
System.setOut(originalOut);
}

assertThat(
outdatedOutput.toString(),
containsString("Checking for updates of 1 artifacts against the following repositories"));
assertThat(outdatedOutput.toString(), containsString("https://repo1.maven.org/maven2"));
assertThat(outdatedOutput.toString(), containsString("No updates found"));
}
}
2 changes: 2 additions & 0 deletions tests/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ genquery(
"@testonly_testing//:com_google_auto_value_auto_value_annotations",
"@testonly_testing//:defs",
"@testonly_testing//:outdated",
# This seems fragile
"@testonly_testing//:outdated_deployjars_internal_rule",
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this needed?

"@testonly_testing//:pin",
],
)
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/coordinates_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def _unusual_version_format_impl(ctx):
# Unusual version formats
versions = [
"809c471bf94f09bf4699ba53eb337768d5d9882f", # A git sha
"FY21R16", # Based on year and release number
"PRERELEASE", # Just a nice name
"FY21R16", # Based on year and release number
"PRERELEASE", # Just a nice name
"VX.2.5.0.0", # Also seen in the wild
"jcef-7f53d6d+cef-100.0.14+g4e5ba66+chromium-100.0.4896.75", # Seen in the wild
"jcef-7f53d6d+cef-100.0.14+g4e5ba66+chromium-100.0.4896.75", # Seen in the wild
]

for version in versions:
Expand Down