-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
81 lines (65 loc) · 1.75 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
apply plugin: 'java'
apply plugin: 'eclipse'
version = '1.1.1'
group = 'openeye'
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '12.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.3.1'
}
def in_jenkins = false
def env = System.getenv()
def jenkinsManifest = manifest {
if (env.BUILD_TAG != null) { // If this works, we'll assume we're in Jenkins atleast.
attributes("Jenkins-Build": "true", "Jenkins-Tag": env.BUILD_TAG, "Jenkins-ID": env.BUILD_ID)
in_jenkins = true
} else {
attributes("Jenkins-Build": "false")
}
}
def branch = null
def hash = null
def proc1 = "git rev-parse --short HEAD".execute()
proc1.in.eachLine { line -> hash = line }
proc1.err.eachLine { line -> println line }
proc1.waitFor()
if (!in_jenkins) {
def proc2 = "git rev-parse --abbrev-ref HEAD".execute()
proc2.in.eachLine { line -> branch = line }
proc2.err.eachLine { line -> println line }
proc2.waitFor()
} else { // In Jenkins
branch = env.GIT_BRANCH.minus("origin/")
}
def gitManifest = manifest {
if (branch != null) {
attributes("Git-Branch": branch, "Git-Hash": hash)
}
}
project.tasks.withType(Jar) {
baseName = "OpenEye"
appendix = "protocol"
manifest {
from jenkinsManifest, gitManifest
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
task wrapper (type: Wrapper) {
gradleVersion = "2.12"
}