-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
50 lines (45 loc) · 1.28 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
plugins {
//id 'java'
id 'war'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
// https://mvnrepository.com/artifact/log4j/log4j
compile group: 'log4j', name: 'log4j', version: '1.2.17'
// https://mvnrepository.com/artifact/commons-io/commons-io
compile group: 'commons-io', name: 'commons-io', version: '2.6'
}
war {
dependsOn 'arelease'
archiveName = 'greeter.war'
}
task arelease {
dependsOn 'processResources'
doLast {
println '=== Building release version ' + version
println '=== Run \'./gradlew increment\' to update version'
def file = new File ('./build/resources/main/greeting.txt')
file.write (version)
}
}
task increment {
doLast {
println '=== Incrementing version'
println 'Version before ' + version
def parser = /(?<major>\d+).(?<minor>\d+).(?<patch>\d+)/
def match = version =~ parser
if ( match.matches () ) {
def (major, minor, patch) = ['major', 'minor', 'patch'].collect { match.group (it) }
patch = (patch as Integer) + 1
def newversion = major + '.' + minor + '.' + patch
println 'Version after ' + newversion
println 'Adding new version to gradle.properties'
def file = new File ('gradle.properties')
file.write ('version=' + newversion)
}
}
}