1
0
forked from xjboss/KCauldronX
KCauldronX/buildSrc/src/main/groovy/kcauldron/VersionParser.groovy

27 lines
901 B
Groovy
Raw Normal View History

2015-06-27 12:47:27 +00:00
package kcauldron
import java.util.regex.Matcher
class VersionParser {
2015-06-27 21:35:19 +00:00
public static String parseForgeVersion(File forgeFile, File propsFile) {
2015-06-27 12:47:27 +00:00
def forgeVersion = forgeFile.text
def int majorVersion = v(forgeVersion =~ /.+int majorVersion\s+=\s+(\d+);/)
def int minorVersion = v(forgeVersion =~ /.+int minorVersion\s+=\s+(\d+);/)
def int revisionVersion = v(forgeVersion =~ /.+int revisionVersion\s+=\s+(\d+);/)
2015-06-27 21:35:19 +00:00
def int buildVersion = parseForgeRevision propsFile
return "${majorVersion}.${minorVersion}.${revisionVersion}.${buildVersion}"
}
def static int parseForgeRevision(File propsFile) {
2015-06-27 12:47:27 +00:00
def props = new Properties();
propsFile.withInputStream { props.load(it) }
2015-06-27 21:35:19 +00:00
props['fmlbuild.build.number'] as int
2015-06-27 12:47:27 +00:00
}
2015-06-27 21:35:19 +00:00
2015-06-27 12:47:27 +00:00
static int v(Matcher matcher) {
matcher.find()
matcher.group(1) as int
}
}