-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
104 lines (88 loc) · 3.22 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
plugins {
id 'java'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.10.1'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'distribution'
}
import org.ajoberstar.grgit.Grgit
def grgit = Grgit.open(dir: project.rootDir)
String readVersionFile() {
return new File('conf/version').text.trim()
}
boolean deployVersionMatchesGitTag(deployVersion, gitTag) {
return "v${deployVersion}" == gitTag
}
String buildArtifactVersionString(deployVersion, gitTag, gitRevisionHash) {
// the convention is that the git tag starts with "v", but the number in the file is just the number
return deployVersionMatchesGitTag(deployVersion, gitTag) ? gitTag : "v${deployVersion}-untagged-${gitRevisionHash}"
}
ext {
gitTag = grgit.describe()
gitRevisionHash = grgit.head().id
gitRevisionHashShort = grgit.head().getAbbreviatedId()
gitCommitMessage = grgit.head().shortMessage
gitCommitMessageFull = grgit.head().fullMessage
deployVersion = readVersionFile()
artifactVersionString = buildArtifactVersionString(deployVersion, gitTag, gitRevisionHashShort)
}
version = artifactVersionString
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
mavenCentral() // for jacoco and kt3k.coveralls plugins
}
configurations {
include
}
dependencies {
// include these jars in the tar output
include "io.honeybadger:honeybadger-java:1.1.+"
include "commons-validator:commons-validator:1.6+"
include "com.google.guava:guava:29.+"
// and use these jars for testing:
implementation "io.honeybadger:honeybadger-java:1.1.+"
implementation "commons-validator:commons-validator:1.6+"
implementation "com.google.guava:guava:29.+"
implementation fileTree('lib')
testImplementation "org.mockito:mockito-core:3.+"
// Honeybadger (which we use for exception tracking) relies on the slf4j API. Wowza includes slf4j
// jars, but we need to list the dependency here for the tests to be able to run (alternatively, slf4j
// could be downloaded and committed in the lib dir).
testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30'
}
jacocoTestReport {
reports {
xml.required = true // coveralls plugin depends on xml format report
html.required = true
}
}
check.dependsOn jacocoTestReport
// for an intro to writing gradle tasks: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html
task deploymentJarRelaxed(type: Jar) {
manifest {
attributes("gitTag": "${gitTag}",
"gitRevisionHash": "${gitRevisionHash}",
"deployVersion": "${deployVersion}",
"artifactVersionString": "${artifactVersionString}")
}
dependsOn(jar)
}
task deploymentJar(type: Jar) {
doFirst {
assert deployVersionMatchesGitTag(deployVersion, gitTag) :
"deployVersion must match current git tag (or invoke deploymentJarRelaxed instead). deployVersion=${deployVersion} gitTag=${gitTag}"
}
dependsOn(deploymentJarRelaxed)
}
distributions {
main {
contents {
from(deploymentJarRelaxed)
from(project.configurations.include)
exclude('slf4j*')
}
}
}