-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathbuild.gradle
More file actions
86 lines (70 loc) · 2.47 KB
/
build.gradle
File metadata and controls
86 lines (70 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
ext {
artifactName = 'apiml-package'
pullNo = project.hasProperty("pullRequest") && project.getProperty("pullRequest") != null ? "-" + project.getProperty("pullRequest") : ""
}
configurations {
apimlServiceJar
zip
}
def resourceDir = 'src/main/resources/'
dependencies {
apimlServiceJar(project(path: ":apiml", configuration: "liteJarConfiguration"))
}
task packageApiml(type: Zip) {
archiveFileName = artifactName + pullNo + ".zip"
includeEmptyDirs = true
into('/') {
from "$resourceDir/zosmf-static-definition.yaml.template"
from "$buildDir/convert/manifest.yaml"
}
into('schemas/') {
from "$resourceDir/schemas/apiml-config.json"
from "$resourceDir/schemas/zowe-schema.json"
}
into('bin/') {
from configurations.apimlServiceJar
from "$resourceDir/bin/start.sh"
from "$resourceDir/bin/validate.sh"
}
}
// TODO should z/OSMF static definition be part of this package now?
// save build information to manifest
packageApiml.doFirst {
String manifest = file('src/main/resources/manifest.yaml').text
def getCommitHash = 'git rev-parse --verify HEAD'.execute()
def commit_hash = new ByteArrayOutputStream()
def command_err = new ByteArrayOutputStream()
getCommitHash.consumeProcessOutput(commit_hash, command_err)
getCommitHash.waitForOrKill(1000)
manifest = manifest.replaceAll("\\{\\{build.branch\\}\\}", System.getenv("BRANCH_NAME") ?: "")
.replaceAll("\\{\\{build.number\\}\\}", System.getenv("BUILD_NUMBER") ?: "")
.replaceAll("\\{\\{build.commitHash\\}\\}", commit_hash.toString().trim())
.replaceAll("\\{\\{build.timestamp\\}\\}", (new Date()).getTime().toString())
Provider<Directory> output = layout.buildDirectory.dir("convert")
def scriptOutputDir = output.get().asFile
if (!scriptOutputDir.exists()) {
scriptOutputDir.mkdirs()
}
Provider<RegularFile> manifestOutput = layout.buildDirectory.file("convert/manifest.yaml")
File convertedManifest = manifestOutput.get().asFile
if (convertedManifest.exists()) {
convertedManifest.delete()
}
convertedManifest.createNewFile()
convertedManifest.write(manifest)
}
jar.dependsOn(packageApiml)
build.dependsOn(packageApiml)
artifacts {
zip packageApiml
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact("$buildDir/distributions/$artifactName" + pullNo + ".zip")
}
}
}
jar {
enabled false
}