mirror of
https://github.com/rehlds/metamod-r.git
synced 2024-12-27 07:05:34 +03:00
eaf6f1ae41
Refactoring
55 lines
1.5 KiB
Groovy
55 lines
1.5 KiB
Groovy
import versioning.GitVersioner
|
|
import versioning.MetamodVersionInfo
|
|
import org.joda.time.DateTime
|
|
|
|
apply from: 'shared.gradle'
|
|
group = 'metamod'
|
|
|
|
apply plugin: 'idea'
|
|
|
|
idea {
|
|
project {
|
|
languageLevel = 'JDK_1_7'
|
|
}
|
|
}
|
|
|
|
def gitInfo = GitVersioner.versionForDir(project.rootDir)
|
|
MetamodVersionInfo versionInfo
|
|
if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') {
|
|
def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/
|
|
if (!m.find()) {
|
|
throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}")
|
|
}
|
|
|
|
versionInfo = new MetamodVersionInfo(
|
|
majorVersion: m.group(1) as int,
|
|
minorVersion: m.group(2) as int,
|
|
maintenanceVersion: m.group(4) ? (m.group(4) as int) : null,
|
|
countCommit: gitInfo.countCommit,
|
|
lastCommitDate: gitInfo.lastCommitDate,
|
|
commitID: gitInfo.commitID,
|
|
authorCommit: gitInfo.authorCommit,
|
|
urlCommits: gitInfo.urlCommits
|
|
)
|
|
} else {
|
|
versionInfo = new MetamodVersionInfo(
|
|
majorVersion: project.majorVersion as int,
|
|
minorVersion: project.minorVersion as int,
|
|
specialVersion: gitInfo ? project.specialVersion : "SNAPSHOT",
|
|
countCommit: gitInfo ? gitInfo.countCommit : 0,
|
|
lastCommitDate: gitInfo ? gitInfo.lastCommitDate : new DateTime(),
|
|
commitID: gitInfo ? gitInfo.commitID : "",
|
|
authorCommit: gitInfo ? gitInfo.authorCommit : "",
|
|
urlCommits: gitInfo ? gitInfo.urlCommits : ""
|
|
)
|
|
}
|
|
|
|
project.ext.metamodVersionInfo = versionInfo
|
|
project.version = versionInfo.asVersion()
|
|
|
|
apply from: 'publish.gradle'
|
|
|
|
task wrapper(type: Wrapper) {
|
|
gradleVersion = '2.4'
|
|
}
|