forked from zeugma-solutions/locale-helper-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradle-plugin-publish.gradle
79 lines (71 loc) · 2.3 KB
/
gradle-plugin-publish.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
apply plugin: 'maven-publish'
def getVersionAccordingTheTag(Project project) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--abbrev=0', '--tags'
standardOutput = stdout
}
String verByGit = stdout.toString().trim()
String versionSuffix
try {
versionSuffix = propertyOrEnvVar(project, "versionSuffix", "VERSION_SUFFIX")
} catch(RuntimeException e) {
versionSuffix = ""
}
return verByGit + versionSuffix
}
ext {
getVersionAccordingTheTag = this.&getVersionAccordingTheTag
}
// Configure the destination repository with
// S3 URL and access credentials
static def propertyOrEnvVar(Project project, String p, String e) {
def projectProperty = project.findProperty(p)
if (projectProperty?.trim()) {
return projectProperty
}
if (System.properties.hasProperty(p)) {
return System.properties.getProperty(p)
} else {
def value = System.getenv(e)
if (value?.trim()) {
return value
} else {
throw new RuntimeException("Unable to get value of property $p/$e")
}
}
}
def s3repo = propertyOrEnvVar(project, "s3Repo", "S3_REPO")
def s3accessKey = propertyOrEnvVar(project, "s3AccessKey", "S3_ACCESS_KEY")
def s3secretKey = propertyOrEnvVar(project, "s3SecretKey", "S3_SECRET_KEY")
def mavenHubalekNetRepo = propertyOrEnvVar(project, "mhnRepo", "MHN_REPO")
def mavenHubalekNetUser = propertyOrEnvVar(project, "mhnUser", "MHN_USER")
def mavenHubalekNetPassword = propertyOrEnvVar(project, "mhnPassword", "MHN_PASSWORD")
publishing {
repositories {
maven {
name "s3"
url "$s3repo"
credentials(AwsCredentials) {
accessKey "$s3accessKey"
secretKey "$s3secretKey"
}
}
maven {
name "hubalekNet"
url "$mavenHubalekNetRepo"
credentials {
username "$mavenHubalekNetUser"
password "$mavenHubalekNetPassword"
}
}
maven {
name "hubalekNetSnapshot"
url "$mavenHubalekNetRepo/../snapshot"
credentials {
username "$mavenHubalekNetUser"
password "$mavenHubalekNetPassword"
}
}
}
}