-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
76 lines (70 loc) · 2.09 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
apply plugin :'war'
repositories {
mavenCentral()
}
dependencies {
compile "log4j:log4j:1.2.17"
compile "commons-io:commons-io:2.4"
}
task increment << {
def versionName = version.split("\\.")
def last = Integer.parseInt(versionName[versionName.length - 1])
versionName[versionName.length - 1] = Integer.toString(last + 1)
versionName = versionName.join(".")
ant.propertyfile(file: "gradle.properties") {
entry(key: "version", value: versionName)
}
}
task populate {
doLast{
def out = new File("build/resources/main/greeting.txt")
out << '\nversion='+version
}
}
task sorting << {
//unsorted array of versions
def unsortedArray = [
'1.1.3',
'1.1.0',
'1.10.2',
'1.9.1',
'1.1.8',
'1.1.15'
]
def arrayLength = unsortedArray.size()
def mas = new Integer[arrayLength][3]
for (int i=0;i<arrayLength;i++){
def a = unsortedArray[i].split("\\.")
for (int j=0; j<3; j++)
mas[i][j] = Integer.parseInt(a[j])
}
def x
for (int k=0;k<3;k++)
for (int i=0;i<arrayLength-1; i++)
for (int j=0; j<arrayLength-1; j++){
if ((mas[j][k]>mas[j+1][k]) && (k == 0))
for (int z=0; z<3; z++){
x = mas[j+1][z]
mas[j+1][z] = mas[j][z]
mas[j][z] = x
}
if ((mas[j][k]>mas[j+1][k]) && (mas[j][k-1] == mas[j+1][k-1]) && (k!=0))
for (int z=0; z<3; z++){
x = mas[j+1][z]
mas[j+1][z] = mas[j][z]
mas[j][z] = x
}
}
def sortedArray = new String[arrayLength]
for (int i=0;i<arrayLength;i++){
def a =''
for (int j=0; j<3; j++){
a =a+Integer.toString(mas[i][j])
if (j<2) a = a+"."
}
sortedArray[i] = a
}
println sortedArray
}
war {dependsOn populate
war.archiveName='gradleSample.war'}