blob: 32cc732241b99d8ab55908775cd37fa29406e8c9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package com.yahoo.container.plugin.util;
import org.apache.maven.artifact.Artifact;
/**
* Helper class to work with artifacts.
*
* @author gjoranv
*/
public record ArtifactInfo(String groupId, String artifactId, String version) {
public ArtifactInfo(Artifact artifact) {
this(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
}
public static ArtifactInfo fromStringValue(String stringValue) {
var parts = stringValue.split(":");
if (parts.length != 3) {
throw new IllegalArgumentException("Invalid artifact string: " + stringValue);
}
return new ArtifactInfo(parts[0], parts[1], parts[2]);
}
public String stringValue() {
return groupId + ":" + artifactId + ":" + version;
}
}
|