Mercurial > public > gradleplugins
changeset 27:68b1ec64996b
Merge
author | Christopher Springer <springer@nwoca.org> |
---|---|
date | Wed, 21 Dec 2016 13:16:05 +0000 |
parents | cfbdbeba877f (current diff) 428c92e0ae10 (diff) |
children | 204c063c93d3 |
files | |
diffstat | 2 files changed, 45 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/gradle.properties Thu Aug 04 03:29:38 2016 +0100 +++ b/gradle.properties Wed Dec 21 13:16:05 2016 +0000 @@ -1,2 +1,2 @@ -version=0.4.3.SNAPSHOT +version=0.4.3 group=org.ssdt_ohio
--- a/src/main/groovy/org/ssdt_ohio/gradle/plugins/VersionClassPlugin.groovy Thu Aug 04 03:29:38 2016 +0100 +++ b/src/main/groovy/org/ssdt_ohio/gradle/plugins/VersionClassPlugin.groovy Wed Dec 21 13:16:05 2016 +0000 @@ -12,58 +12,59 @@ def genSrc = 'generated-src/version' def generatedSrcDir = new File(project.buildDir, genSrc) - def makeVersionClassTask = project.task('makeVersionClass') << { - - def now = new Date().format('yyyy-MM-dd hh:mm:ss') + def makeVersionClassTask = project.task('makeVersionClass') { + doLast { + def now = new Date().format('yyyy-MM-dd hh:mm:ss') - def buildNumber = -1 - if (project.rootProject?.file('build-number.txt').exists()) { - def props = new Properties() - project.rootProject?.file('build-number.txt').withInputStream {stream -> - props.load(stream) - } - buildNumber = props['build.number'] - } + def buildNumber = -1 + if (project.rootProject?.file('build-number.txt').exists()) { + def props = new Properties() + project.rootProject?.file('build-number.txt').withInputStream {stream -> + props.load(stream) + } + buildNumber = props['build.number'] + } - def targetPackage = getTargetClass(project) + def targetPackage = getTargetClass(project) - if (!targetPackage) { - return - } + if (!targetPackage) { + return + } - def outFile = new File(generatedSrcDir, "groovy/" + targetPackage.replaceAll('\\.', "/") + "/ProjectVersion.groovy") + def outFile = new File(generatedSrcDir, "groovy/" + targetPackage.replaceAll('\\.', "/") + "/ProjectVersion.groovy") - outFile.getParentFile().mkdirs() - logger.info("creating $targetPackage in $outFile") - def f = new FileWriter(outFile) - f.write(""" -package $targetPackage -/** - * Generated by gradle build. $now ($buildNumber) - * @version ${project.version} - */ -public class ProjectVersion { + outFile.getParentFile().mkdirs() + logger.info("creating $targetPackage in $outFile") + def f = new FileWriter(outFile) + f.write(""" + package $targetPackage + /** + * Generated by gradle build. $now ($buildNumber) + * @version ${project.version} + */ + public class ProjectVersion { - final String name = "${project.name}" - final String group = "${project.group}" - final String version = "${project.version}" - final String buildDate = "$now" - final int buildNumber = $buildNumber + final String name = "${project.name}" + final String group = "${project.group}" + final String version = "${project.version}" + final String buildDate = "$now" + final int buildNumber = $buildNumber - String getFullVersion() { - "\$version \$buildDate (#\$buildNumber)" - } + String getFullVersion() { + "\$version \$buildDate (#\$buildNumber)" + } - String getId() { - "\$group:\$name:\$version" - } + String getId() { + "\$group:\$name:\$version" + } - String toString() { - "\$id \$buildDate (#\$buildNumber)" - } -} -""") - f.close() + String toString() { + "\$id \$buildDate (#\$buildNumber)" + } + } + """) + f.close() + } } project.sourceSets {