Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies liquibase to 4.29.1 and liquibase-mongodb to 4.28.0 #42308

Merged
merged 3 commits into from
Aug 8, 2024

Conversation

gcw-it
Copy link
Contributor

@gcw-it gcw-it commented Aug 4, 2024

The liquibase dependencies are upgraded to their latest versions.

To create an easier upgrade path for future version upgrades, a utility class to define resources limited to a single dependency is introduced. The functionality added in PR #41928 is extracted to a helper class, to be used in selected build steps. An option is added to NativeImageResourceBuildItem and ServiceProviderBuildItem to make use of this new capability.

There is some possible overlap with NativeImageResourceDirectoryBuildItem and NativeImageResourcePatternsBuildItem, but the new feature offers to reduce the scope to a single dependency instead of the whole classpath.

This is desirable in view of Liquibases's decision to put .property files in the root of their .jar. This could lead to possible conflicts, when using e.g. NativeImageResourcePatternsBuildItem to include those resources., should other dependency providers choose to go down a similar road, and put their resources in the same namespace.

Furthermore it enables an extension to include all SPIs defined in META-INF/services of a specific dependency.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

This looks really good thanks. I added a minor nitpick for the future but it's no biggie, we can merge as is.
If you end up fixing it, please amend the commit in which this thing was introduced (for instance using git commit --fixup <sha> and then git rebase -i <sha before the first commit> --autosquash).

@@ -19,6 +20,8 @@
/**
*/
public final class ServiceUtil {
private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not going to block the PR for this but this is not really an improvement. It's already a constant and now to figure out the charset you have to look out for the constant.

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

@gcw-it gcw-it force-pushed the pr_lbupg branch 2 times, most recently from 4507e7c to 8da35f6 Compare August 7, 2024 10:32
@gcw-it
Copy link
Contributor Author

gcw-it commented Aug 7, 2024

I fixed a small error, I've overlooked.

}
} catch (Exception ex) {
// close() really shouldn't declare that exception, see also https://github.com/liquibase/liquibase/pull/2576
throw new AssertionError(ex);
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I missed this but I think we need something better here.

Because the exception is caught globally not only for the close() now and it could happen in the code that is in the try. So I would rather have an IllegalStateException with a proper message and the cause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the exception accordingly

@quarkus-bot

This comment has been minimized.

@gastaldi
Copy link
Contributor

gastaldi commented Aug 7, 2024

/cc @aloubyansky for the core improvements

return pathStream
.map(p -> p.subpath(0, p.getNameCount()))
.filter(p -> p.toString().endsWith(resourceCoordinates.extension()))
.toList();
Copy link
Member

Choose a reason for hiding this comment

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

These paths, theoretically, might not be usable outside the method they are collected in.
They will work as long as the path tree is backed by a regular directory or an archive who's FileSystem remains open.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced with filtered pathTree.walk

.toList();
}

public record ArtifactCoordinates(String groupId, String artifactId) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid introducing this API. We already have a few variations around and this record does not represent complete coordinates. Consider https://github.com/quarkusio/quarkus/blob/main/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ArtifactCoordsPattern.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointer. Done.

}
}

public record ResourceCoordinates(String basePath, String extension) {
Copy link
Member

Choose a reason for hiding this comment

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

This also looks questionable to me. It seems to be an attempt to introduce a generic way of locating content but the way it works remains pretty specific. Have you considered https://github.com/quarkusio/quarkus/blob/main/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/PathFilter.java?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointer. Done.

Copy link
Member

@aloubyansky aloubyansky left a comment

Choose a reason for hiding this comment

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

Looks better to me, thanks @gcw-it

"www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd",
"www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd",
"liquibase.build.properties"));
var dependencies = curateOutcome.getApplicationModel().getDependencies();
Copy link
Member

Choose a reason for hiding this comment

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

AFAICS, there are two places where the new ofDependencyResources method is used.

Just to clarify, are all dependencies instead of only the runtime ones scanned on purpose in both cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, we could reduce the scope to the runtime dependencies. I'll take care of that.

resource.produce(NativeImageResourceBuildItem.ofDependencyResources(
dependencies, LIQUIBASE_MONGODB_ARTIFACT, LIQUIBASE_MONGODB_CHANGELOG_FILTER));
resource.produce(NativeImageResourceBuildItem.ofDependencyResources(
dependencies, LIQUIBASE_MONGODB_ARTIFACT, LIQUIBASE_MONGODB_PARSER_FILTER));
Copy link
Member

Choose a reason for hiding this comment

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

It seems like it could have been somewhat simplified by combining all the filters applied to the same set of of artifacts into one. I mean PathFilter.forIncludes(List.of(...)) could have been used instead, which would result in two calls to resource.produce(NativeImageResourceBuildItem.ofDependencyResources( here and one in the other place.

Then, personally, it doesn't seem like the new NativeImageResourceBuildItem.ofDependencyResources() offers a lot of benefit, since essentially, it wraps a one-liner ArtifactResourceResolver.of(dependencies, artifactCoordinates).resourceList(resourceFilter) and by that, from the caller's perspective, it takes the responsibility of filtering resources off of the ArtifactResourceResolver. I'll leave that decision to you though.

Copy link
Contributor Author

@gcw-it gcw-it Aug 8, 2024

Choose a reason for hiding this comment

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

I'll combine the resource filters. That was something I thought about during the modification and then promptly forgot about it. Thanks for the reminder.

I introduced the NativeImageResourceBuildItem.ofDependencyResources convenience method, to be on the same abstraction level as ServiceProviderBuildItem allProvidersOfDependency. It's where I would look first, to determine which capabilities are offered. In my opinion using the ArtifactResourceResolver is a bit more obscure.

I would keep the method, but since you have the better domain knowledge, I will remove it, if you think it's cleaner to use the ArtifactResourceResolver directly. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Sure, feel free to keep the method. Thanks.

*/
public static Collection<ServiceProviderBuildItem> allProvidersOfDependency(
Collection<ResolvedDependency> dependencies,
ArtifactCoords artifactCoordinates) {
Copy link
Member

Choose a reason for hiding this comment

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

BTW, you could take a similar approach here by adding a method that takes ArtifactCoordsPattern and have a single call when it's called one per coords. That could be more efficient.

Copy link
Member

Choose a reason for hiding this comment

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

Or accept a List of ArtifactCoords, I think patterns would make more sense though, since that's how they are treated anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean using a wildcard pattern, or rather a list of ArtifactCoordsPattern to include multiple dependencies?

Copy link
Member

Choose a reason for hiding this comment

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

Not a list of ArtifactCoordsPatterns. It should be either a single ArtifactCoordsPattern or a Collection<ArtifactCoords> from which a pattern instance will be created.

Copy link
Member

Choose a reason for hiding this comment

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

If you go with the Collection<ArtifactCoords> then I suppose you could keep the current method, in case there are callers that pass in a single coords.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, if I don't follow you completely, but how would I build an ArtifactCoordsPattern for multiple artifacts?
Using a wildcard pattern for the group- and/or artifact-id could lead to including unwanted resources. Am I misunderstanding anything here?

Copy link
Member

Choose a reason for hiding this comment

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

I thought of ArtifactCoordsPattern. toPatterns(Collection coords)

Copy link
Contributor Author

@gcw-it gcw-it Aug 8, 2024

Choose a reason for hiding this comment

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

I see. I misunderstood your earlier comment

Not a list of ArtifactCoordsPatterns

That's why I disregarded this method.
Thanks for the support. I'll have a go at it.

@gcw-it
Copy link
Contributor Author

gcw-it commented Aug 8, 2024

  • artifact scope îs reduced to runtime artifacts
  • the resource filters are combined
  • the ServiceProviderBuildItem provides now a method to get the service providers for a collection of artifacts

@quarkus-bot
Copy link

quarkus-bot bot commented Aug 8, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit a9fcc8d.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.


Flaky tests - Develocity

⚙️ JVM Tests - JDK 21

📦 extensions/smallrye-reactive-messaging/deployment

io.quarkus.smallrye.reactivemessaging.hotreload.ConnectorChangeTest.testUpdatingConnector - History

  • Expecting actual: ["-4","-5","-6","-7","-8","-9","-10","-11"] to start with: ["-3", "-4", "-5", "-6"] - java.lang.AssertionError
java.lang.AssertionError: 

Expecting actual:
  ["-4","-5","-6","-7","-8","-9","-10","-11"]
to start with:
  ["-3", "-4", "-5", "-6"]

	at io.quarkus.smallrye.reactivemessaging.hotreload.ConnectorChangeTest.testUpdatingConnector(ConnectorChangeTest.java:36)

Copy link
Member

@aloubyansky aloubyansky left a comment

Choose a reason for hiding this comment

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

Thanks for your efforts @gcw-it

@gsmet gsmet merged commit 4ad4bba into quarkusio:main Aug 8, 2024
52 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.14 - main milestone Aug 8, 2024
@gsmet
Copy link
Member

gsmet commented Aug 8, 2024

And merged, thanks a lot!

@gcw-it
Copy link
Contributor Author

gcw-it commented Aug 8, 2024

@aloubyansky @gsmet Happy to help.

@gcw-it gcw-it deleted the pr_lbupg branch August 8, 2024 21:10
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.

4 participants