forked from pukkaone/webappenhance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
88 lines (75 loc) · 2.16 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
apply plugin: 'eclipse'
apply plugin: 'java'
sourceCompatibility = 1.6
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'javax.el:el-api:2.2'
compile 'javax.servlet:servlet-api:2.5'
compile 'javax.servlet.jsp:jsp-api:2.2'
testCompile 'junit:junit:4.10'
}
// Gets version from tag.
def readVersion() {
def output = new ByteArrayOutputStream()
def result = exec {
commandLine = ['git', 'describe']
standardOutput = output
ignoreExitValue = true
}
def version = (result.getExitValue() == 0) ?
output.toString().trim() : 'UNKNOWN'
println "Version ${version}"
return version
}
// Gets build number by counting commits to tag named 'build'.
def readBuildNumber() {
def output = new ByteArrayOutputStream()
def result = exec {
commandLine = ['git', 'describe', '--match', 'build']
standardOutput = output
ignoreExitValue = true
}
def buildNumber = (result.getExitValue() == 0) ?
output.toString().split('-')[1] : 'UNKNOWN'
println "Build number ${buildNumber}"
return buildNumber
}
def assignVersion() {
ext.version = readVersion()
ext.buildNumber = readBuildNumber()
project.version = "${ext.version}.${ext.buildNumber}".toString()
}
def allProcessResourcesTasks() {
sourceSets*.processResourcesTaskName.collect {
tasks[it]
}
}
afterEvaluate { project ->
assignVersion()
jar {
manifest {
attributes('Implementation-Version': project.version)
}
}
configure(allProcessResourcesTasks()) {
filter(
org.apache.tools.ant.filters.ReplaceTokens,
tokens: [WAE_VERSION: project.version])
}
}
import org.gradle.plugins.ide.eclipse.model.SourceFolder
eclipse.classpath.file {
whenMerged { classpath ->
classpath.entries.findAll {
it instanceof SourceFolder &&
it.path.startsWith('src/main/')
}*.output = 'build/classes/main'
classpath.entries.findAll {
it instanceof SourceFolder &&
it.path.startsWith('src/test/')
}*.output = 'build/classes/test'
}
}