-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle
75 lines (73 loc) · 4.06 KB
/
settings.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
plugins {
id 'org.ajoberstar.grgit' version '4.0.2' apply false
}
import org.ajoberstar.grgit.Grgit
rootProject.name = 'eccelwrap'
def msgPrefix = rootProject.name + " settings: "
// do specific snapshot dependency resolution for snapshot builds
if (!hasProperty("release")) {
def compositeLibraries = ["math"]
for (String lib : compositeLibraries) {
def libPrefix = "dependency " + lib
def libPath = file("../" + lib).getPath()
def grgitLib
def cloned
if (file(libPath).exists()) {
println(msgPrefix + libPrefix + ": Local repository exists.")
grgitLib = Grgit.open(dir: libPath)
cloned = false
} else {
println(msgPrefix + libPrefix + ": Local repository does not exist. Cloning to " + libPath + ".")
grgitLib = Grgit.clone(dir: libPath, uri: "https://github.com/cryptimeleon/" + lib + ".git")
cloned = true
}
def grgitThis = Grgit.open(dir: rootProject.projectDir)
def branchThis = grgitThis.branch.current()
if (hasProperty("useCurrentBranch")) {
println(msgPrefix + libPrefix + ": Parameter 'useCurrentBranch' is set. Using branch '" + grgitLib.branch.current().getName() + "'.")
} else {
if (file(libPath + "/.git/refs/heads/" + branchThis.getName()).exists()) {
if (grgitLib.branch.current().getName() == branchThis.getName()) {
println(msgPrefix + libPrefix + ": Branch '" + branchThis.getName() + "' exists and is checked out already.")
} else {
throw new GradleException(msgPrefix + libPrefix + ": Branch '" + branchThis.getName() + "' exists but is not checked out. "
+ "Please check it out yourself before building.")
}
} else {
println(msgPrefix + libPrefix + ": Branch " + branchThis.getName() + " does not exist locally.")
if (grgitLib.branch.list { mode = "REMOTE" }.collect { it.getName() }.contains("origin/" + branchThis.getName())) {
if (hasProperty("checkoutIfCloned") && cloned) {
println(msgPrefix + libPrefix + ": Branch '" + branchThis.getName() + "' exists but is not checked out. "
+ "'checkoutIfCloned' is set. Automatically checking it out.")
grgitLib.checkout {
branch = branchThis.getName()
startPoint = "origin/" + branchThis.getName()
createBranch = true
}
} else {
throw new GradleException(msgPrefix + libPrefix + ": Branch '" + branchThis.getName()
+ "' exists remotely but not locally. Please check it out yourself before building.")
}
} else {
println(msgPrefix + libPrefix + ": Branch '" + branchThis.getName() + "' does not exist remotely. Using develop.")
if (grgitLib.branch.current().getName() == "develop") {
println(msgPrefix + libPrefix + ": Branch develop is checked out already. Using it.")
} else {
if (hasProperty("checkoutIfCloned") && cloned) {
println(msgPrefix + libPrefix + ": Branch develop is not checked out. "
+ "'checkoutIfCloned' is set. Automatically checking it out.")
grgitLib.checkout {
branch = develop
}
} else {
throw new GradleException(msgPrefix + libPrefix + ": Branch develop exists but is not checked out. "
+ "Please check it out yourself before building.")
}
}
}
}
}
println(msgPrefix + libPrefix + ": Enabling composite build.")
includeBuild(libPath)
}
}