package org.jtrim2.build;

import java.io.IOException;
import org.gradle.api.Project;

import static org.jtrim2.build.BuildFileUtils.*;

public final class Versions {
    private static final String GROUP_NAME = "org.jtrim2";

    private static final String VERSION_BASE_PROPERTY = "versionBase";

    public static void setVersion(Project project) throws IOException {
        String suffix = ReleaseUtils.isRelease(project) ? "" : "-SNAPSHOT";

        String versionBase = readTextFile(rootPath(project, "version.txt")).trim();
        project.getExtensions().add(VERSION_BASE_PROPERTY, versionBase);

        project.setGroup(GROUP_NAME);
        project.setVersion(versionBase + suffix);
    }

    public static String getVersion(Project project) {
        Object version = project.getVersion();
        return version != null ? version.toString() : null;
    }

    public static String getVersionBase(Project project) {
        return ProjectUtils.getStringProperty(project, VERSION_BASE_PROPERTY, "");
    }

    private Versions() {
        throw new AssertionError();
    }
}

@@ -295,157 +295,155 @@
 e%22;%0A
-%0A    public static void setVersion(Project project) throws IOException %7B%0A        String suffix = ReleaseUtils.isRelease(project) ? %22%22 : %22-SNAPSHOT%22;%0A
+    private static final String VERSION_SUFFIX_PROPERTY = %22versionSuffix%22;%0A%0A    public static void setVersion(Project project) throws IOException %7B
 %0A   
@@ -679,16 +679,412 @@
 se +
+ getVersionSuffix(project));%0A    %7D%0A%0A    private static String getVersionSuffix(Project project) %7B%0A        boolean release = ReleaseUtils.isRelease(project);%0A%0A        String defaultSuffix = release ? %22%22 : %22SNAPSHOT%22;%0A        String suffix = ProjectUtils.getStringProperty(project, VERSION_SUFFIX_PROPERTY, defaultSuffix);%0A        return suffix.isEmpty()%0A                ? %22%22%0A                : %22-%22 +
  suffix
-)
 ;%0A  

Build now allows to specify custom version suffix.