实际上,我自己找到了解决方案并创建了一个目标,在运行更新我的 pom.xml 文件的目标之前运行该目标:这是更新所有存储库的元数据的方法。如果您需要整个目标,请告诉我:
public void updateMetadata(Artifact artifact){
getLog().info("Updating metadata for: " + artifact.getGroupId()+":"+artifact.getArtifactId());
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact);
for ( Iterator<ArtifactRepository> repo = remoteArtifactRepositories.iterator(); repo.hasNext(); ){
ArtifactRepository repository = repo.next();
ArtifactRepositoryPolicy policy =
metadata.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
File file = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( metadata, repository ) );
getLog().info("Updating " + repository.getBasedir());
try {
wagonManager.getArtifactMetadata( metadata, repository, file, policy.getChecksumPolicy());
getLog().info("Updated...");
} catch (TransferFailedException e) {
getLog().info("Couldn't find " + metadata + " from repository: " + repository.getId() +
"\n Reason\n: " + e.getMessage() );
e.printStackTrace();
} catch (ResourceDoesNotExistException e) {
getLog().info("Cannot find " + metadata + " in repository: " + repository.getId() );
if ( file.exists() ){
file.delete();
}
e.printStackTrace();
}
}
}