How do I get artifact timestamp (inside a task or plugin)?
Can get the pom and the artifact, but not the publish timestamp.
ArtifactResolutionResult resolutionResult = project.dependencies.createArtifactResolutionQuery()
.forComponents(DefaultModuleComponentIdentifier.newId(id))
.withArtifacts(MavenModule, MavenPomArtifact)
.execute()
// size is 0 for gradle plugins, 1 for normal dependencies
for (ComponentArtifactsResult result : resolutionResult.resolvedComponents) {
Set<ArtifactResult> artifacts = result.getArtifacts(MavenPomArtifact)
// size should always be 1
for (ArtifactResult artifact : result.getArtifacts(MavenPomArtifact)) {
if (artifact instanceof ResolvedArtifactResult) {
File file = ((ResolvedArtifactResult) artifact).file
project.logger.info("Pom file for ${id} is ${file}")
String url = getUrlFromPom(file)