forked from getodk/validate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
105 lines (90 loc) · 2.65 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
plugins {
id 'application'
id 'checkstyle'
id 'idea'
id 'de.fuerstenau.buildconfig' version '1.1.8'
}
repositories {
mavenCentral()
maven { url = 'https://oss.sonatype.org/content/groups/public' }
}
sourceSets {
main {
java {
srcDirs = ['src']
exclude 'test'
}
resources {
srcDirs = ['resources']
}
}
}
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
dependencies {
compile group: 'net.sf.kxml', name: 'kxml2', version: '2.3.0'
compile group: 'org.getodk', name: 'javarosa', version: '4.4.1'
compile group: 'org.slf4j', name: 'slf4j-nop', version: '1.7.25'
testCompile 'junit:junit:4.13.2'
testCompile 'org.hamcrest:hamcrest-all:1.3'
}
// Required to use fileExtensions property in checkstyle file
checkstyle {
toolVersion = '7.6.1'
}
ant.condition(property: 'os', value: 'windows') {
os(family: 'windows')
}
ant.condition(property: 'os', value: 'unix' ) {
os(family: 'unix')
}
// Use the result of git describe --tags --dirty as the version name
// From http://stackoverflow.com/questions/17097263#24121734
def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
switch(ant.properties.os) {
case 'windows':
commandLine 'cmd', '/c', 'git', 'describe', '--tags', '--dirty', '--always'
break
case 'unix':
commandLine 'git', 'describe', '--tags', '--dirty', '--always'
break
}
standardOutput = stdout
}
return stdout.toString().trim()
}
catch (ignored) {
return null;
}
}
buildConfig {
appName = 'ODK Validate'
version = getVersionName()
clsName = 'BuildConfig'
packageName = 'org.opendatakit.validate.buildconfig'
}
mainClassName = 'org.opendatakit.validate.FormValidator'
jar {
baseName = buildConfig.appName
version = buildConfig.version
archiveName = (baseName + ' ' + version + '.jar').replaceAll(" ","-")
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest {
attributes 'Main-Class': mainClassName
}
// Some of the dependencies are signed jars. When combined into a big jar, the corresponding signature files
// don't match with big jar, so the runtime refuses to run the jar. The fix is to exclude the signature files.
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
// Useful for testing
task explodedJar(type: Copy) {
into "$buildDir/libs/$jar.baseName $jar.version"
with jar
}