use of com.google.devtools.intellij.model.ProjectData.LocalFile in project intellij by bazelbuild.
the class ArtifactMetadata method forArtifact.
/**
* Returns the relevant metadata for an {@code artifact} that needs to be persisted.
*
* @throws ArtifactNotFoundException if the artifact is not present.
*/
public static ArtifactMetadata forArtifact(OutputArtifact artifact) throws ArtifactNotFoundException {
ArtifactState artifactState = artifact.toArtifactState();
if (artifactState == null) {
throw new ArtifactNotFoundException(artifact);
}
// Serialize to proto to make grabbing the fields easier
LocalFileOrOutputArtifact serializedArtifact = artifactState.serializeToProto();
if (serializedArtifact.hasArtifact()) {
ProjectData.OutputArtifact o = serializedArtifact.getArtifact();
return new ArtifactMetadata(o.getRelativePath(), o.getId());
} else {
LocalFile o = serializedArtifact.getLocalFile();
String relativePath = o.getRelativePath().isEmpty() ? o.getPath() : o.getRelativePath();
return new ArtifactMetadata(relativePath, Long.toString(o.getTimestamp()));
}
}
Aggregations