private Path pickSnapshot(Path versionedPath, MavenReference reference, Metadata mavenMetadata) {
// Snapshot snapshot = mavenMetadata.getVersioning().getSnapshot();
// String timestamp = snapshot.getTimestamp();
// String buildNumber = snapshot.getBuildNumber();
SnapshotVersion found = null;
for (SnapshotVersion snapshotVersion : mavenMetadata.getVersioning().getSnapshotVersions()) {
String classifier = snapshotVersion.getClassifier();
String extension = snapshotVersion.getExtension();
if (classifier == null) {
classifier = extension;
}
if (Objects.equal(classifier, reference.classifier)) {
if (found != null) {
throw new IllegalStateException("Multiple matches found");
}
found = snapshotVersion;
}
}
if (found == null) {
throw new IllegalStateException("Cannot find artifact: " + reference);
}
String name = reference.artifactId + "-" + found.getVersion();
if (found.getClassifier() != null) {
name += "-" + found.getClassifier();
}
name += "." + found.getExtension();
Path resolvedPath = versionedPath.resolve(name);
return resolvedPath;
}