org.apache.maven.artifact.repository.metadata.Versioning Java Examples
The following examples show how to use
org.apache.maven.artifact.repository.metadata.Versioning.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepositoryMetadataMergerTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
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; }
Example #2
Source File: An_UpdateChecker.java From deadcode4j with Apache License 2.0 | 6 votes |
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); } }
Example #3
Source File: MavenMetadataGenerator.java From artifactory-resource with Apache License 2.0 | 5 votes |
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); } }
Example #4
Source File: RepositoryMetadataMerger.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
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()); } }
Example #5
Source File: RepositoryMetadataMergerTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
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; }
Example #6
Source File: VersioningCalculatorTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
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(); }
Example #7
Source File: AddPluginArtifactMetadataMojo.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
@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); }