@@ -23,7 +23,7 @@ task packageCommonLib(type: Zip) {
23
23
def resourceDir = ' src/main/resources/'
24
24
25
25
into(' /' ) {
26
- from " $r esourceDir /manifest.yaml"
26
+ from " $b uildDir /convert /manifest.yaml"
27
27
from " ../schemas/apiml-common-lib-schema.json"
28
28
}
29
29
@@ -32,6 +32,33 @@ task packageCommonLib(type: Zip) {
32
32
}
33
33
}
34
34
35
+ // save build information to manifest
36
+ packageCommonLib. doFirst {
37
+ String manifest = file(' src/main/resources/manifest.yaml' ). text
38
+
39
+ def getCommitHash = ' git rev-parse --verify HEAD' . execute()
40
+ def commit_hash = new ByteArrayOutputStream ()
41
+ def command_err = new ByteArrayOutputStream ()
42
+ getCommitHash. consumeProcessOutput(commit_hash, command_err)
43
+ getCommitHash. waitForOrKill(1000 )
44
+
45
+ manifest = manifest. replaceAll(" \\ {\\ {build.branch\\ }\\ }" , System . getenv(" BRANCH_NAME" ) ?: " " )
46
+ .replaceAll(" \\ {\\ {build.number\\ }\\ }" , System . getenv(" BUILD_NUMBER" ) ?: " " )
47
+ .replaceAll(" \\ {\\ {build.commitHash\\ }\\ }" , commit_hash. toString(). trim())
48
+ .replaceAll(" \\ {\\ {build.timestamp\\ }\\ }" , (new Date ()). getTime(). toString())
49
+
50
+ def scriptOutputDir = new File (" $buildDir /convert/" );
51
+ if (! scriptOutputDir. exists()) {
52
+ scriptOutputDir. mkdirs();
53
+ }
54
+ File convertedManifest = new File (" $buildDir /convert/manifest.yaml" );
55
+ if (convertedManifest. exists()) {
56
+ convertedManifest. delete();
57
+ }
58
+ convertedManifest. createNewFile();
59
+ convertedManifest. write(manifest)
60
+ }
61
+
35
62
jar. dependsOn(packageCommonLib)
36
63
build. dependsOn(packageCommonLib)
37
64
packageCommonLib. dependsOn(" :liteLibJarAll" )
0 commit comments