-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42308 from gcw-it/pr_lbupg
Upgrade dependencies liquibase to 4.29.1 and liquibase-mongodb to 4.28.0
- Loading branch information
Showing
12 changed files
with
267 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
core/deployment/src/main/java/io/quarkus/deployment/util/ArtifactResourceResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package io.quarkus.deployment.util; | ||
|
||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import io.quarkus.maven.dependency.ArtifactCoords; | ||
import io.quarkus.maven.dependency.ArtifactCoordsPattern; | ||
import io.quarkus.maven.dependency.ResolvedDependency; | ||
import io.quarkus.paths.PathFilter; | ||
import io.quarkus.paths.PathVisit; | ||
import io.quarkus.util.GlobUtil; | ||
|
||
/** | ||
* Utility class to extract a list of resource paths from a given artifact and path. | ||
*/ | ||
public final class ArtifactResourceResolver { | ||
private final Collection<ResolvedDependency> artifacts; | ||
|
||
/** | ||
* Creates a {@code ArtifactResourceResolver} for the given artifact | ||
* | ||
* @param dependencies the resolved dependencies of the build | ||
* @param artifactCoordinates the coordinates of the artifact containing the resources | ||
*/ | ||
public static ArtifactResourceResolver of( | ||
Collection<ResolvedDependency> dependencies, ArtifactCoords artifactCoordinates) { | ||
|
||
return new ArtifactResourceResolver(dependencies, List.of(artifactCoordinates)); | ||
} | ||
|
||
/** | ||
* Creates a {@code ArtifactResourceResolver} for the given artifact | ||
* | ||
* @param dependencies the resolved dependencies of the build | ||
* @param artifactCoordinatesCollection a coordinates {@link Collection} for the artifacts containing the resources | ||
*/ | ||
public static ArtifactResourceResolver of( | ||
Collection<ResolvedDependency> dependencies, Collection<ArtifactCoords> artifactCoordinatesCollection) { | ||
|
||
return new ArtifactResourceResolver(dependencies, artifactCoordinatesCollection); | ||
} | ||
|
||
private ArtifactResourceResolver( | ||
Collection<ResolvedDependency> dependencies, Collection<ArtifactCoords> artifactCoordinates) { | ||
|
||
var patterns = ArtifactCoordsPattern.toPatterns(artifactCoordinates); | ||
artifacts = patterns.stream() | ||
.map(p -> findArtifact(dependencies, p)) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
private static ResolvedDependency findArtifact( | ||
Collection<ResolvedDependency> dependencies, ArtifactCoordsPattern pattern) { | ||
|
||
return dependencies.stream() | ||
.filter(pattern::matches) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalArgumentException( | ||
"%s artifact not found".formatted(pattern.toString()))); | ||
} | ||
|
||
/** | ||
* Extracts a {@link Collection} of resource paths with the given filter | ||
* | ||
* @param pathFilter the filter for the resources in glob syntax (see {@link GlobUtil}) | ||
* @return a collection of the found resource paths | ||
*/ | ||
public Collection<Path> resourcePathList(PathFilter pathFilter) { | ||
return artifacts.stream() | ||
.map(a -> pathsForArtifact(a, pathFilter)) | ||
.flatMap(Collection::stream) | ||
.toList(); | ||
} | ||
|
||
private Collection<Path> pathsForArtifact(ResolvedDependency artifact, PathFilter pathFilter) { | ||
var pathList = new ArrayList<Path>(); | ||
var pathTree = artifact.getContentTree(pathFilter); | ||
pathTree.walk(visit -> pathList.add(relativePath(visit))); | ||
return pathList; | ||
} | ||
|
||
private Path relativePath(PathVisit visit) { | ||
var path = visit.getPath(); | ||
return path.getRoot().relativize(path); | ||
} | ||
|
||
/** | ||
* Extracts a {@link List} of resource paths as strings with the given filter | ||
* | ||
* @param pathFilter the filter for the resources in glob syntax (see {@link GlobUtil}) | ||
* @return a list of the found resource paths as strings | ||
*/ | ||
public List<String> resourceList(PathFilter pathFilter) { | ||
return resourcePathList(pathFilter).stream() | ||
.map(Path::toString) | ||
.toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.