Skip to content

Linkage Monitor to read artifact list file that contains Maven coordinates with versions#1962

Merged
suztomo merged 5 commits intomasterfrom
linkage_monitor_read_file2
Feb 26, 2021
Merged

Linkage Monitor to read artifact list file that contains Maven coordinates with versions#1962
suztomo merged 5 commits intomasterfrom
linkage_monitor_read_file2

Conversation

@suztomo
Copy link
Copy Markdown
Contributor

@suztomo suztomo commented Feb 26, 2021

Fixes #1958

Another approach for the problem. Compared with #1961, this PR expects the artifact list file to have Maven coordinates with versions. In gax-java repository, Gradle's build.gradle will create such file.

What is the file will look like?


com.google.api:gax:1.60.0-SNAPSHOT
com.google.api:gax-grpc:1.60.0-SNAPSHOT
com.google.api:gax-httpjson:1.60.0-SNAPSHOT

A simple Gradle task can generate this file using $version. In gax-java's build.gradle. I'll add

task createLinkageMonitorArtifactList {
  doLast {
    new File(projectDir, "linkage-monitor-artifacts.txt").text = """
com.google.api:gax:$version
com.google.api:gax-grpc:$version
com.google.api:gax-httpjson:$version
"""
  }
}

CC: @chingor13 who owns gax-java

@google-cla google-cla bot added the cla: yes label Feb 26, 2021
@suztomo suztomo changed the title Linkage monitor read file2 Linkage Monitor to read artifact list file that contains Maven coordinates with versions Feb 26, 2021
Comment on lines -196 to -206
DependencyManagement dependencyManagement = model.getDependencyManagement();
if ("pom".equals(model.getPackaging()) && dependencyManagement != null) {
// Read the content of a BOM.
for (org.apache.maven.model.Dependency dependency :
dependencyManagement.getDependencies()) {
String managedDependencyVersionlessCoordinates =
dependency.getGroupId() + ":" + dependency.getArtifactId();
artifactToVersion.put(managedDependencyVersionlessCoordinates, dependency.getVersion());
logger.fine("Found local artifact in the BOM: " + dependency);
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This reverts #1920, which causes the problem of mixing BOMs and parent POMs.

@suztomo
Copy link
Copy Markdown
Contributor Author

suztomo commented Feb 26, 2021

Confirmed it works with gax-java (I renamed ClientSettings to ClientSettingsFoo and Linkage Monitor detected it successfully)

https://gist.github.com/suztomo/79304de2a0953ffe12e8a37c4a0879bc

Confirmed that this fix does not raise exception for java-asset.

@suztomo suztomo merged commit f9412a2 into master Feb 26, 2021
@suztomo suztomo deleted the linkage_monitor_read_file2 branch February 26, 2021 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linkage Monitor unexpectedly recognizes the root parent pom as a BOM

2 participants