Mercurial > public > gradleplugins
comparison src/main/groovy/org/ssdt_ohio/gradle/plugins/VersionClassPlugin.groovy @ 3:1756755e4e71
improve up-to-date check so version does not cause recompile
author | smith@nwoca.org |
---|---|
date | Fri, 18 May 2012 21:50:36 +0100 |
parents | 4db19f1c5ad0 |
children | c32864e7d65b |
comparison
equal
deleted
inserted
replaced
2:4db19f1c5ad0 | 3:1756755e4e71 |
---|---|
24 buildNumber = props['build.number'] | 24 buildNumber = props['build.number'] |
25 } | 25 } |
26 | 26 |
27 def targetPackage = getTargetClass(project) | 27 def targetPackage = getTargetClass(project) |
28 | 28 |
29 def outFile = new File(generatedSrcDir, targetPackage.replaceAll('\\.', "/") + "/ProjectVersion.groovy") | 29 def outFile = new File(generatedSrcDir, "groovy/" + targetPackage.replaceAll('\\.', "/") + "/ProjectVersion.groovy") |
30 | 30 |
31 outFile.getParentFile().mkdirs() | 31 outFile.getParentFile().mkdirs() |
32 logger.info("creating $targetPackage in $outFile") | 32 logger.info("creating $targetPackage in $outFile") |
33 def f = new FileWriter(outFile) | 33 def f = new FileWriter(outFile) |
34 f.write(""" | 34 f.write(""" |
62 } | 62 } |
63 | 63 |
64 project.sourceSets { | 64 project.sourceSets { |
65 main { | 65 main { |
66 groovy { | 66 groovy { |
67 srcDir project.buildDir.name + '/' + genSrc | 67 srcDir project.buildDir.name + '/' + genSrc + '/groovy' |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 makeVersionClassTask.getInputs().files(project.sourceSets.main.getAllSource()) | 72 makeVersionClassTask.getInputs().files(project.sourceSets.main.getAllSource().findAll{ !it.name.startsWith('ProjectVersion')} |
73 makeVersionClassTask.getOutputs().files(generatedSrcDir) | 73 ) |
74 makeVersionClassTask.getOutputs().file( project.buildDir.name + '/' + genSrc) | |
75 | |
74 if (project.getBuildFile() != null && project.getBuildFile().exists()) { | 76 if (project.getBuildFile() != null && project.getBuildFile().exists()) { |
75 makeVersionClassTask.getInputs().files(project.getBuildFile()) | 77 makeVersionClassTask.getInputs().files(project.getBuildFile()) |
76 } | 78 } |
79 | |
77 project.getTasks().getByName('compileGroovy').dependsOn('makeVersionClass') | 80 project.getTasks().getByName('compileGroovy').dependsOn('makeVersionClass') |
78 | 81 |
79 project.getTasks().getByName('jar').manifest.attributes( | 82 project.getTasks().getByName('jar').manifest.attributes( |
80 [ | 83 [ |
81 "Specification-Title": project.name, | 84 "Specification-Title": project.name, |
84 "Implementation-Title": project.name, | 87 "Implementation-Title": project.name, |
85 "Implementation-Version": project.version, | 88 "Implementation-Version": project.version, |
86 "Implementation-Vendor": project.group, | 89 "Implementation-Vendor": project.group, |
87 "Built-By": System.properties['user.name'], | 90 "Built-By": System.properties['user.name'], |
88 "Build-Jdk": System.properties['java.version'], | 91 "Build-Jdk": System.properties['java.version'], |
89 "Build-Time": new Date().format('yyyy-MM-dd hh:mm:ss'), | |
90 | |
91 ] | 92 ] |
92 ) | 93 ) |
93 | 94 |
94 | 95 |
95 } | 96 } |