Search in sources :

Example 26 with Version

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);
}
Also used : Version(com.github.zafarkhaja.semver.Version) Model(org.apache.maven.model.Model) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) FileReader(java.io.FileReader) Test(org.testng.annotations.Test)

Example 27 with Version

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;
}
Also used : Path(java.nio.file.Path) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Version(com.github.zafarkhaja.semver.Version)

Aggregations

Version (com.github.zafarkhaja.semver.Version)27 Test (org.junit.Test)6 File (java.io.File)4 IOException (java.io.IOException)4 BrokerFilterBadVersionException (org.apache.pulsar.broker.loadbalance.BrokerFilterBadVersionException)3 JsonWriter (com.serotonin.json.JsonWriter)2 JsonObject (com.serotonin.json.type.JsonObject)2 JsonString (com.serotonin.json.type.JsonString)2 JsonTypeReader (com.serotonin.json.type.JsonTypeReader)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)2 HttpPost (org.apache.http.client.methods.HttpPost)2 StringEntity (org.apache.http.entity.StringEntity)2 BrokerData (org.apache.pulsar.broker.BrokerData)2 Plugin (org.syncany.plugins.Plugin)2 UpgradeServerVersion (org.talend.dataprep.api.service.upgrade.UpgradeServerVersion)2 NonNull (android.support.annotation.NonNull)1 MongoCluster (com.antwerkz.bottlerocket.clusters.MongoCluster)1