-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle
131 lines (110 loc) · 3.71 KB
/
build.gradle
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.owasp:dependency-check-gradle:5.2.2'
}
}
plugins {
id 'java-library'
id 'base'
id 'idea'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
//// Allows to use "--scan" option without manual interactive confirmation. So it can be used on CI.
//plugins {
// id "com.gradle.build-scan" version "3.5"
//}
//buildScan {
// termsOfServiceUrl = "https://gradle.com/terms-of-service"
// termsOfServiceAgree = "yes"
//}
apply from: "$rootDir/gradle/Release.gradle"
apply from: "$rootDir/gradle/DockerSupport.gradle"
ext {
dockerImages = [
main : 'src/main/docker/Dockerfile'
]
}
allprojects {
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
if (project.hasProperty("failOnHighCVSS") && project.getProperty("failOnHighCVSS") == 'true') {
failBuildOnCVSS = 7
}
skipProjects = []
suppressionFile = file("$rootDir/dependency-check-suppression-file.xml")
analyzers {
assemblyEnabled = false
}
}
configurations.all {
exclude group: 'org.finos.timebase-ce', module: 'timebase-s3'
}
}
idea {
project {
jdkName = '11'
languageLevel = '1.8'
vcs = 'git'
}
}
subprojects {
apply plugin: 'com.github.johnrengelman.shadow'
}
def currentJvm = org.gradle.internal.jvm.Jvm.current()
private String getGitRevision() {
def gitOutput = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = gitOutput
}
return gitOutput.toString().replace("\n", "")
}
/**
* Returns difference between number of commits from repo root to current head and to a specified commit.
* If the current HEAD is directly inherited from from the tag then returned number represents number of commits since tag.
* Otherwise the returned value has no special meaning.
*/
private Integer getCountOfCommitsSinceTag(tag) {
def gitOutput = new ByteArrayOutputStream()
try {
exec {
commandLine 'git', 'rev-list', '--count', tag
standardOutput = gitOutput
errorOutput = new ByteArrayOutputStream()
}
} catch (Exception ignore) {
logger.warn("WARN: Failed to find git tag: " + project.version)
return null;
}
def commitsFromRootToTag = gitOutput.toString()
gitOutput.reset()
exec {
commandLine 'git', 'rev-list', '--count', 'HEAD'
standardOutput = gitOutput
}
def commitsFromRootToHead = gitOutput.toString()
return Integer.parseInt(commitsFromRootToHead.replace("\n", "")) - Integer.parseInt(commitsFromRootToTag.replace("\n", ""))
}
private String getBuildTimestamp() {
def gitOutput = new ByteArrayOutputStream()
exec {
workingDir project.rootDir
commandLine 'git', 'log', '-1', '--date=iso8601', '--pretty=format:%cd'
standardOutput = gitOutput
}
return gitOutput.toString()
}
ext.revision = getGitRevision()
ext.commitsAfterTag = getCountOfCommitsSinceTag(project.version) // Note: project version is expected to match existing tag name
ext.commitTimestamp = getBuildTimestamp()
println '======================================================================'
println 'Current JVM ' + currentJvm
println 'Project version ' + project.version
println 'Revision ' + ext.revision
println 'Commits after tag: ' + ext.commitsAfterTag
println 'Commit timestamp: ' + ext.commitTimestamp
println 'Repository user: ' + findProperty("ARTIFACTORY_USER");
println '======================================================================'