-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-nexus.gradle
121 lines (103 loc) · 2.71 KB
/
build-nexus.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Nexus Repository Integration
*/
allprojects {
apply plugin: "net.saliman.properties"
apply plugin: "nu.studer.credentials"
/* We accept crypted credentials via "nu.studer.credentials" or plain
* credentials via gradle-local.properties.
*/
ext.registryUsername = credentials.user ?: project.properties['nexus.username']
ext.registryPassword = credentials.password ?: project.properties['nexus.password']
repositories {
mavenLocal()
mavenCentral()
String publicURL = project.properties['nexus.public.url']
String releasesURL = project.properties['nexus.releases.url']
String snapshotsURL = project.properties['nexus.snapshots.url']
if (snapshotsURL) {
maven {
credentials {
username project.properties['registryUsername']
password project.properties['registryPassword']
}
url snapshotsURL
}
}
if (releasesURL) {
maven {
credentials {
username project.properties['registryUsername']
password project.properties['registryPassword']
}
url releasesURL
}
}
if (publicURL) {
maven {
credentials {
username project.properties['registryUsername']
password project.properties['registryPassword']
}
url publicURL
}
}
}
}
/************************
* RELEASE vs SNAPSHOTS *
************************/
apply plugin: "org.ajoberstar.grgit"
if (grgit != null) {
logger.debug("Git ${grgit.branch.current().name}")
ext.gitClone = true
ext.gitBranchName = grgit.branch.current().name
if (ext.gitBranchName.startsWith("release")) {
ext.gitSnapshotsBranch = false
ext.registrySuffix = ""
}
else if (ext.gitBranchName.startsWith("development")) {
ext.gitSnapshotsBranch = false
ext.registrySuffix = ""
}
else if ("master".equals(gitBranchName)) {
ext.gitSnapshotsBranch = false
ext.registrySuffix = ""
}
else {
ext.gitSnapshotsBranch = true
def issueId = gitBranchName =~ /^(\d+)/
if (issueId.size() > 0) {
ext.gitIssueId = issueId[0][1]
ext.registrySuffix = "-${gitIssueId}-SNAPSHOT"
}
else if ("HEAD".equals(gitBranchName)) {
def lastTag = grgit.describe()
println "Git lastTag ${lastTag}"
if (lastTag.startsWith("rel_") || lastTag.startsWith("MP_v")) {
ext.gitSnapshotsBranch = false
ext.registrySuffix = ""
}
else {
ext.registrySuffix = "-SNAPSHOT"
}
}
else {
throw new GradleException("Unsupported branch name ${gitBranchName}. Manage it!!")
}
}
//println "${gitSnapshotsBranch} ${registrySuffix}"
logger.debug("${gitSnapshotsBranch} ${registrySuffix}")
}
else {
println "No Git"
ext.gitClone = false
}
if (!ext.gitClone) {
if (project.properties['nexus.release.mode'] == "true") {
ext.registrySuffix = ""
}
else {
ext.registrySuffix = "-SNAPSHOT"
}
}