-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
77 lines (65 loc) · 1.75 KB
/
build.gradle
File metadata and controls
77 lines (65 loc) · 1.75 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
apply plugin: "java"
// get git version
def describeOutput = new ByteArrayOutputStream()
project.exec({
commandLine(["git", "describe", "HEAD", "--tags"])
standardOutput = describeOutput
})
def gitCommit = describeOutput.toString().replace("\n", "")
def suffixOutput = new ByteArrayOutputStream()
project.exec({
commandLine(["git", "status", "--porcelain"])
standardOutput = suffixOutput
})
def modificationSuffix = ""
if (suffixOutput.toString().trim().replace("\n", "") != "") {
modificationSuffix = "-dev"
}
def gitVersion = gitCommit + modificationSuffix
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
String mainClass = "mapper.Main"
jar {
manifest {
attributes 'Main-Class': mainClass
}
}
dependencies {
test {
testImplementation "junit:junit:4.13"
}
}
def helpOutput = new ByteArrayOutputStream()
task updateHelp(type: Exec) {
dependsOn("assemble")
commandLine(["java", "-jar", "build/libs/x-mapper.jar", "--help"])
standardOutput = helpOutput
errorOutput = helpOutput
doLast {
project.file("build/help.txt").write(helpOutput.toString())
}
}
task updateReadme(type: Exec) {
dependsOn("updateHelp")
workingDir "${project.projectDir}/util"
commandLine(["bash", "-c", "./updateReadme.sh"])
}
task release(type: Copy) {
from "build/libs"
include "x-mapper.jar"
into "build/libs"
rename("x-mapper.jar", "x-mapper-${gitVersion}.jar")
dependsOn("build")
}
tasks["build"].dependsOn("updateReadme")
def expandProperties = new HashMap<String, String>()
expandProperties["mapperVersion"] = gitVersion
project.tasks["processResources"].configure { processTask ->
processTask.expand(expandProperties)
processTask.inputs.property("properties", expandProperties)
}
repositories {
mavenCentral()
}