private String deriveMavenVersionQualifier(BundleDescription bundle, Version version) { if (isSnapshotVersion(bundle, version)) { return "SNAPSHOT"; } if (!trimQualifiers && version.getQualifier().length() > 0) { return version.getQualifier(); } return null; }
private void appendToRange(final StringBuilder sb, final Version version) { final boolean hasMicro = version.getMicro() > 0; final boolean hasMinorOrMicro = version.getMinor() > 0 || hasMicro; sb.append(version.getMajor()); if (hasMinorOrMicro) { sb.append('.'); sb.append(version.getMinor()); if (hasMicro) { sb.append('.'); sb.append(version.getMicro()); } } }
private String deriveMavenVersion(BundleDescription bundle, final Version version) { final StringBuilder sb = new StringBuilder(); sb.append(version.getMajor()); sb.append('.'); sb.append(version.getMinor()); sb.append('.'); sb.append(version.getMicro()); final String qualifier = deriveMavenVersionQualifier(bundle, version); if (qualifier != null) { sb.append('-'); sb.append(qualifier); } return sb.toString(); }
private String deriveMavenVersionRange( @NotNull BundleDescription bundle, @NotNull Version recommendedVersion) { final String qualifier = deriveMavenVersionQualifier(bundle, recommendedVersion); final StringBuilder sb = new StringBuilder(); if (qualifier == null) { sb.append('['); appendToRange(sb, recommendedVersion); sb.append(",)"); } else { sb.append(recommendedVersion.getMajor()); sb.append('.'); sb.append(recommendedVersion.getMinor()); sb.append('.'); sb.append(recommendedVersion.getMicro()); sb.append('-'); sb.append(qualifier); } return sb.toString(); }
private static void resolveAndAssert(String origin, String expected, PropertiesMap options) { BundleManifest manifest = BundleManifestFactory.eINSTANCE.createBundleManifest(); manifest.setBundleVersion(origin); JavaArchive jArchive = JavaModelFactory.eINSTANCE.createJavaArchive(); BundleCandidate bundleCandidate = ContextModelFactory.eINSTANCE.createBundleCandidate(); bundleCandidate.setContent(jArchive); File file = jArchive.getFile(JarFile.MANIFEST_NAME, true); file.addExtension(manifest); BundleCandidate bundle = ContextModelFactory.eINSTANCE.createBundleCandidate(); bundle.setContent(jArchive); Version result = new ExistingBundleManifestVersion().resolveVersion(bundle, options); assertEquals(Version.parse(expected), result); }
public String deriveMavenVersion(@NotNull BundleDescription bundle) { final Version version = Version.parse(bundle.getVersion().toString()); return deriveMavenVersion(bundle, version); }