forked from kobo/gaiden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
126 lines (103 loc) · 3.47 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
/*
* Copyright 2013 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.internal.os.OperatingSystem
apply plugin: 'groovy'
apply plugin: 'application'
apply plugin: 'codenarc'
apply plugin: 'idea'
version = '0.4'
mainClassName = 'gaiden.GaidenMain'
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.2.0'
compile 'org.apache.ant:ant:1.9.1'
compile 'org.pegdown:pegdown:1.2.1'
compile 'commons-io:commons-io:2.4'
compile 'commons-cli:commons-cli:1.2'
compile 'org.apache.commons:commons-lang3:3.1'
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
// optional dependencies for using Spock
testRuntime 'cglib:cglib-nodep:2.2.2' // enables mocking of classes (in addition to interfaces)
testRuntime 'org.objenesis:objenesis:1.3' // enables mocking of without default constructor (together with CGLIB)
}
test {
afterTest { desc, result ->
println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
}
task distribution(dependsOn: 'distZip')
task release(dependsOn: 'distribution')
gradle.taskGraph.whenReady { taskGraph ->
if (!taskGraph.hasTask(release)) {
version = "$version-SNAPSHOT"
}
}
startScripts {
doLast {
unixScript.text = unixScript.text.replace('$GAIDEN_OPTS', '$GAIDEN_OPTS -Dapp.home=$APP_HOME')
windowsScript.text = windowsScript.text.replace('%GAIDEN_OPTS%', '%GAIDEN_OPTS% -Dapp.home=%APP_HOME%')
}
}
def distFiles = files(
"${project.projectDir}/README.md",
"${project.projectDir}/NOTICE",
"${project.projectDir}/LICENSE",
)
applicationDistribution.from(distFiles) {
into '/'
}
codenarc {
configFile = new File('codenarc.groovy')
ignoreFailures = true
reportFormat = 'xml'
}
processResources {
filter ReplaceTokens, tokens: [
revision: revision,
version: version,
buildDate: new Date().format("yyyy-MM-dd HH:mm:ss.SSSZ"),
username: System.properties["user.name"],
javaVersion: System.properties["java.version"],
osName: System.properties["os.name"],
osVersion: System.properties["os.version"]
]
}
def getRevision() {
if (!file(".git/HEAD").exists()) {
return
}
def baos = new ByteArrayOutputStream()
def execResult = exec {
ignoreExitValue = true
commandLine = ["git", "log", "-1", "--format=%H"]
if (OperatingSystem.current().windows) {
commandLine = ["cmd", "/c"] + commandLine
}
standardOutput = baos
}
if (execResult.exitValue == 0) {
return new String(baos.toByteArray(), "utf8").trim()
}
// Read commit id directly from filesystem
def headRef = file(".git/HEAD").text
headRef = headRef.replaceAll('ref: ', '').trim()
file(".git/$headRef").text.trim()
}