Java源码示例:org.apache.maven.artifact.repository.metadata.Versioning
示例1
private Metadata a(final String groupId,
final String artifactId,
final String lastUpdated,
final String latest,
final String release,
final String... versions)
{
final Metadata m = new Metadata();
m.setGroupId(groupId);
m.setArtifactId(artifactId);
m.setVersioning(new Versioning());
final Versioning mv = m.getVersioning();
if (!Strings.isNullOrEmpty(lastUpdated)) {
mv.setLastUpdated(lastUpdated);
}
if (!Strings.isNullOrEmpty(latest)) {
mv.setLatest(latest);
}
if (!Strings.isNullOrEmpty(release)) {
mv.setRelease(release);
}
mv.getVersions().addAll(Arrays.asList(versions));
return m;
}
示例2
private void givenAvailableVersions(final String... availableVersions) {
try {
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
RepositoryMetadata repositoryMetadata = (RepositoryMetadata) invocation.getArguments()[0];
Versioning versioning = new Versioning();
versioning.setVersions(Arrays.asList(availableVersions));
repositoryMetadata.getMetadata().setVersioning(versioning);
return null;
}
}).when(repositoryMetadataManager).resolve(any(RepositoryMetadata.class),
anyListOf(ArtifactRepository.class), any(ArtifactRepository.class));
} catch (RepositoryMetadataResolutionException e) {
throw new RuntimeException(e);
}
}
示例3
private void writeMetadata(File folder, List<MavenCoordinates> coordinates, boolean generateChecksums) {
List<SnapshotVersion> snapshotVersions = getSnapshotVersionMetadata(coordinates);
if (!snapshotVersions.isEmpty()) {
Metadata metadata = new Metadata();
Versioning versioning = new Versioning();
versioning.setSnapshotVersions(snapshotVersions);
metadata.setVersioning(versioning);
metadata.setGroupId(coordinates.get(0).getGroupId());
metadata.setArtifactId(coordinates.get(0).getArtifactId());
metadata.setVersion(coordinates.get(0).getVersion());
writeMetadataFile(metadata, new File(folder, "maven-metadata.xml"), generateChecksums);
}
}
示例4
private boolean versioningEquals(@Nullable final Versioning v1,
@Nullable final Versioning v2) { // NOSONAR
if (v1 == null || v2 == null) {
return v1 == v2; // NOSONAR
}
else {
return
Objects.equals(v1.getLatest(), v2.getLatest()) && // NOSONAR
Objects.equals(v1.getRelease(), v2.getRelease()) &&
snapshotEquals(v1.getSnapshot(), v2.getSnapshot()) &&
Objects.equals(v1.getVersions(), v2.getVersions()) &&
snapshotVersionsEquals(v1.getSnapshotVersions(), v2.getSnapshotVersions());
}
}
示例5
private Metadata v(final String groupId,
final String artifactId,
final String versionPrefix,
final String timestamp,
final int buildNumber)
{
final Metadata m = new Metadata();
m.setGroupId(groupId);
m.setArtifactId(artifactId);
m.setVersion(versionPrefix + "-SNAPSHOT");
m.setVersioning(new Versioning());
final Versioning mv = m.getVersioning();
mv.setLastUpdated(timestamp.replace(".", ""));
final Snapshot snapshot = new Snapshot();
snapshot.setTimestamp(timestamp);
snapshot.setBuildNumber(buildNumber);
mv.setSnapshot(snapshot);
final SnapshotVersion pom = new SnapshotVersion();
pom.setExtension("pom");
pom.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
pom.setUpdated(timestamp);
mv.getSnapshotVersions().add(pom);
final SnapshotVersion jar = new SnapshotVersion();
jar.setExtension("jar");
jar.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
jar.setUpdated(timestamp);
mv.getSnapshotVersions().add(jar);
final SnapshotVersion sources = new SnapshotVersion();
sources.setExtension("jar");
sources.setClassifier("sources");
sources.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
sources.setUpdated(timestamp);
mv.getSnapshotVersions().add(sources);
return m;
}
示例6
private byte[] setupMetadataVersions( final String... versions )
throws IOException
{
final Metadata md = new Metadata();
final Versioning v = new Versioning();
md.setVersioning( v );
v.setVersions( Arrays.asList( versions ) );
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new MetadataXpp3Writer().write( baos, md );
return baos.toByteArray();
}
示例7
@Override
protected void executeMojo() throws MojoExecutionException {
Artifact projectArtifact = project.getArtifact();
Versioning versioning = new Versioning();
versioning.setLatest(projectArtifact.getVersion());
versioning.updateTimestamp();
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata(projectArtifact, versioning);
projectArtifact.addMetadata(metadata);
GroupRepositoryMetadata groupMetadata = new GroupRepositoryMetadata(project.getGroupId());
groupMetadata.addPluginMapping(getGoalPrefix(), project.getArtifactId(), project.getName());
projectArtifact.addMetadata(groupMetadata);
}