-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle
94 lines (81 loc) · 3.05 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
plugins {
id 'java-library'
id 'checkstyle'
}
checkstyle {
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}
checkstyleMain {
//source has to be pointed at src/main/java, thats why it is a List
source = List.of('intelij-plugin/src/main/java', 'rfc-parser/src/main/java', 'intelij-plugin/src/main/resources')
}
checkstyleTest {
source = List.of('intelij-plugin/src/test/java', 'rfc-parser/src/test/java')
}
group 'tech.pantheon.YANGinator'
version '2.2-SNAPSHOT'
allprojects {
apply plugin: 'java'
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
repositories {
mavenCentral()
}
}
subprojects {
version = rootProject.version
group = rootProject.group
}
tasks {
wrapper {
gradleVersion = "$gradleVersion"
}
}
task createReleaseVersion {
doLast {
def snapshotVersion = buildFile.getText().find(version)
String tmp = snapshotVersion.toString()
if (tmp.contains("-beta-") || tmp.contains("-SNAPSHOT")) {
String currentMinor = version.substring(snapshotVersion.lastIndexOf('.') + 2)
tmp = snapshotVersion.replace(currentMinor, "")
}
println "Release version : " + tmp
String newBuildFile = buildFile.getText().replaceFirst("version '$version'", "version '" + tmp + "'")
buildFile.setText(newBuildFile)
}
}
task createNextSnapshotVersion {
doLast {
def releaseVersion = buildFile.getText().find(version)
String currentMinor = version.substring(releaseVersion.lastIndexOf('.') + 1)
int nextMinor = currentMinor.toInteger() + 1
def snapshotVersion = releaseVersion.replace("." + currentMinor, "." + nextMinor + "-SNAPSHOT")
println "Snapshot version : " + snapshotVersion
String newBuildFile = buildFile.getText().replaceFirst("version '$version'", "version '" + snapshotVersion + "'")
buildFile.setText(newBuildFile)
}
}
task createBetaVersion {
doLast {
def currentVersion = buildFile.getText().find(version)
currentVersion = currentVersion.replace("-SNAPSHOT", "")
if (!currentVersion.contains("-beta-")) {
currentVersion += "-beta-" + 1
}
println "Beta version : " + currentVersion
String newBuildFile = buildFile.getText().replaceFirst("version '$version'", "version '" + currentVersion + "'")
buildFile.setText(newBuildFile)
}
}
task createBetaSnapshotVersion {
doLast {
def currentVersion = buildFile.getText().find(version)
currentVersion = currentVersion.replace("-SNAPSHOT", "")
String currentMinor = currentVersion.substring(currentVersion.lastIndexOf('-') + 1)
int nextMinor = currentMinor.toInteger() + 1
currentVersion = currentVersion.replace("-" + currentMinor, "-" + nextMinor + "-SNAPSHOT")
println "Beta Snapshot version : " + currentVersion
String newBuildFile = buildFile.getText().replaceFirst("version '$version'", "version '" + currentVersion + "'")
buildFile.setText(newBuildFile)
}
}