@@ -24,85 +24,82 @@ dependencies {
2424}
2525
2626// Test JAR for downstream modules
27- val testJar by tasks.registering(Jar ::class ) {
28- archiveClassifier = " tests"
29- from(sourceSets.test.get().output)
30- }
31-
32- configurations {
33- create(" testArtifacts" ) {
34- extendsFrom(configurations.testImplementation.get())
27+ val testJar by
28+ tasks.registering(Jar ::class ) {
29+ archiveClassifier = " tests"
30+ from(sourceSets.test.get().output)
3531 }
36- }
3732
38- artifacts {
39- add( " testArtifacts " , testJar)
40- }
33+ configurations { create( " testArtifacts " ) { extendsFrom(configurations.testImplementation.get()) } }
34+
35+ artifacts { add( " testArtifacts " , testJar) }
4136
4237// Add test JAR to publishing
4338afterEvaluate {
44- publishing {
45- publications {
46- named<MavenPublication >(" maven" ) {
47- artifact(testJar)
48- }
49- }
50- }
39+ publishing { publications { named<MavenPublication >(" maven" ) { artifact(testJar) } } }
5140}
5241
5342// Generate build properties
54- val generateBuildProperties by tasks.registering {
55- val outputDir = layout.buildDirectory.dir(" generated-sources/properties" )
56- val propsFile = outputDir.map { it.file(" org/opencds/cqf/fhir/cqf-fhir-cr-build.properties" ) }
57- val projectVersion = project.version.toString()
58-
59- outputs.dir(outputDir)
60-
61- doLast {
62- val gitCommit = try {
63- providers.exec {
64- commandLine(" git" , " rev-parse" , " HEAD" )
65- }.standardOutput.asText.get().trim()
66- } catch (_: Exception ) {
67- " UNKNOWN"
68- }
69-
70- val gitBranch = try {
71- providers.exec {
72- commandLine(" git" , " rev-parse" , " --abbrev-ref" , " HEAD" )
73- }.standardOutput.asText.get().trim()
74- } catch (_: Exception ) {
75- " UNKNOWN"
76- }
77-
78- val timestamp = OffsetDateTime .now().format(
79- DateTimeFormatter .ofPattern(" yyyy-MM-dd'T'HH:mm:ss.SXXX" )
80- )
81-
82- val timestampRegex = Regex (" clinicalreasoning\\ .timestamp=.*\\ n" )
83- val content = buildString {
84- appendLine(" clinicalreasoning.buildnumber=$gitCommit " )
85- appendLine(" clinicalreasoning.timestamp=$timestamp " )
86- appendLine(" clinicalreasoning.version=$projectVersion " )
87- appendLine(" scmBranch=$gitBranch " )
88- }
43+ val generateBuildProperties by
44+ tasks.registering {
45+ val outputDir = layout.buildDirectory.dir(" generated-sources/properties" )
46+ val propsFile =
47+ outputDir.map { it.file(" org/opencds/cqf/fhir/cqf-fhir-cr-build.properties" ) }
48+ val projectVersion = project.version.toString()
49+
50+ outputs.dir(outputDir)
51+
52+ doLast {
53+ val gitCommit =
54+ try {
55+ providers
56+ .exec { commandLine(" git" , " rev-parse" , " HEAD" ) }
57+ .standardOutput
58+ .asText
59+ .get()
60+ .trim()
61+ } catch (_: Exception ) {
62+ " UNKNOWN"
63+ }
64+
65+ val gitBranch =
66+ try {
67+ providers
68+ .exec { commandLine(" git" , " rev-parse" , " --abbrev-ref" , " HEAD" ) }
69+ .standardOutput
70+ .asText
71+ .get()
72+ .trim()
73+ } catch (_: Exception ) {
74+ " UNKNOWN"
75+ }
76+
77+ val timestamp =
78+ OffsetDateTime .now()
79+ .format(DateTimeFormatter .ofPattern(" yyyy-MM-dd'T'HH:mm:ss.SXXX" ))
80+
81+ val timestampRegex = Regex (" clinicalreasoning\\ .timestamp=.*\\ n" )
82+ val content = buildString {
83+ appendLine(" clinicalreasoning.buildnumber=$gitCommit " )
84+ appendLine(" clinicalreasoning.timestamp=$timestamp " )
85+ appendLine(" clinicalreasoning.version=$projectVersion " )
86+ appendLine(" scmBranch=$gitBranch " )
87+ }
8988
90- // Only write if meaningful content changed (ignoring the timestamp)
91- // to avoid triggering IDE file-watcher rebuild loops.
92- val file = propsFile.get().asFile
93- file.parentFile.mkdirs()
94- if (file.exists()) {
95- val existing = file.readText()
96- if (existing.replace(timestampRegex, " " ) == content.replace(timestampRegex, " " )) {
97- return @doLast
89+ // Only write if meaningful content changed (ignoring the timestamp)
90+ // to avoid triggering IDE file-watcher rebuild loops.
91+ val file = propsFile.get().asFile
92+ file.parentFile.mkdirs()
93+ if (file.exists()) {
94+ val existing = file.readText()
95+ if (existing.replace(timestampRegex, " " ) == content.replace(timestampRegex, " " )) {
96+ return @doLast
97+ }
9898 }
99+ file.writeText(content)
99100 }
100- file.writeText(content)
101101 }
102- }
103102
104103sourceSets.main { resources.srcDir(generateBuildProperties.map { it.outputs.files.singleFile }) }
105104
106- tasks.named(" processResources" ) {
107- dependsOn(generateBuildProperties)
108- }
105+ tasks.named(" processResources" ) { dependsOn(generateBuildProperties) }
0 commit comments