use of com.github.zafarkhaja.semver.Version in project morphia by mongodb.
the class MorphiaVersionTest method testVersion.
@Test
public void testVersion() throws Exception {
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(new FileReader("../pom.xml"));
Version version = Version.valueOf(model.getVersion());
String minorVersion = format("%s%s", version.getMajorVersion(), version.getMinorVersion());
// noinspection MisorderedAssertEqualsArguments
assertEquals(MorphiaVersion23.class.getSimpleName().replaceAll("\\D", ""), minorVersion);
}
use of com.github.zafarkhaja.semver.Version in project zaproxy by zaproxy.
the class PrepareNextDevIter method updateBuildFile.
private Path updateBuildFile() throws IOException {
Path buildFilePath = getBuildFile().getAsFile().get().toPath();
String contents = new String(Files.readAllBytes(buildFilePath), StandardCharsets.UTF_8);
Matcher version = getVersionPattern().get().matcher(contents);
if (!version.find()) {
throw new BuildException("Version pattern not found.");
}
String currentVersion = version.group(1);
Version newVersion = Version.valueOf(currentVersion).incrementMinorVersion().setPreReleaseVersion("SNAPSHOT");
contents = replace(contents, version, newVersion.toString());
Matcher versionBc = getVersionBcPattern().get().matcher(contents);
if (!versionBc.find()) {
throw new BuildException("Version BC pattern not found.");
}
contents = replace(contents, versionBc, currentVersion);
for (Pattern clearDataPattern : getClearDataPatterns().get()) {
Matcher clearData = clearDataPattern.matcher(contents);
if (!clearData.find()) {
throw new BuildException("Clear data pattern not found: " + clearDataPattern);
}
contents = replace(contents, clearData, "");
}
Path updatedBuildFile = getTemporaryDir().toPath().resolve("updated-" + buildFilePath.getFileName());
Files.write(updatedBuildFile, contents.getBytes(StandardCharsets.UTF_8));
return updatedBuildFile;
}
Aggregations