Skip to content

Conversation

@suztomo
Copy link
Contributor

@suztomo suztomo commented Aug 28, 2019

Fixes #853

Linkage Monitor to run 2-phase model building. It swaps BOM version between the phases.

As per https://maven.apache.org/ref/3.6.1/maven-model-builder/

  • Phase 1 Interpolates variables
  • Phase 2 resolves dependency management imports

This change updates the content of the BOM after Phase 1.

RepositoryUtility.newRepositorySystem(),
new Bom(
"com.google.cloud.tools:test-bom:0.0.1",
"com.google.guava:guava-bom:27.1-android",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because this change involves Maven's model building, we cannot use dummy artifact here.

Version highestGuava = versionScheme.parseVersion(guavaHighestVersion);
Version guava28 = versionScheme.parseVersion("28.0");
// The logic should work for both jar and pom artifacts
for (String artifactId : ImmutableList.of("guava", "guava-bom")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test is to ensure findHighestVersion works for BOM (extension: pom) too.

Copy link
Contributor

Choose a reason for hiding this comment

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

make that a comment in the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

ArtifactResult googleCloudBomResult =
system.resolveArtifact(
session, new ArtifactRequest(googleCloudBom0_106, ImmutableList.of(CENTRAL), null));
doReturn(googleCloudBomResult)
Copy link
Contributor Author

@suztomo suztomo Aug 28, 2019

Choose a reason for hiding this comment

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

doReturn for spy object
https://static.javadoc.io/org.mockito/mockito-core/3.0.0/org/mockito/Mockito.html#spy-T-
(If possible, spy object should be avoided. but Maven is tightly coupled with RepositorySystem and thus normal mock object would make the test even complicated. )

@suztomo suztomo requested a review from elharo August 28, 2019 19:58
RepositorySystem repositorySystem, RepositorySystemSession session, String bomCoordinates)
throws ModelBuildingException, ArtifactResolutionException, MavenRepositoryException {

// BOM Coordinates may not have extension.
Copy link
Contributor

Choose a reason for hiding this comment

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

may --> might

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Version highestGuava = versionScheme.parseVersion(guavaHighestVersion);
Version guava28 = versionScheme.parseVersion("28.0");
// The logic should work for both jar and pom artifacts
for (String artifactId : ImmutableList.of("guava", "guava-bom")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

make that a comment in the code

@suztomo suztomo merged commit 0977918 into master Aug 29, 2019
@suztomo suztomo deleted the model_building_phases branch August 29, 2019 14:14
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 to run check with BOMs update not individual libraries

3 participants