This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
/
modules.gradle
165 lines (137 loc) · 4.27 KB
/
modules.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
ext {
COLORS = [
CYAN: 36,
GREEN: 32,
RED: 31,
YELLOW: 33,
WHITE: 37
]
N = System.getProperty("line.separator")
}
apply from: 'sdk-builder.gradle'
configure(subprojects.findAll { it.name.startsWith('modules-') }) {
apply from: '../../sdk-builder.gradle'
apply plugin: 'java'
archivesBaseName = "liferay-android-sdk-services"
sourceSets {
main {
java {
srcDir 'android/src/gen/java'
srcDir 'android/src/main/java'
}
}
test {
java {
srcDir 'android/src/test/java'
}
}
}
dependencies {
if (isJavaCompile()) {
compile 'com.liferay.mobile:liferay-android-sdk:7.0.8'
}
implementation group: 'com.google.android', name: 'android', version: '2.3.3'
implementation group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.3'
implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.6'
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
}
configurations {
testCompile.exclude module: 'httpclient-android'
}
task zip(type: Zip) {
group = tasksGroup
description = 'Zips generated iOS SDK for this module.'
baseName = "liferay-${contexts}-ios-sdk"
destinationDir = project.buildDir
version = project.version
from 'ios/Source'
doLast {
println "Zipped to ${archivePath}"
}
}
}
task createModule {
doLast {
def console = System.console()
if (console) {
def all = project.hasProperty('all')
def contexts = read("${N}Context", project.ext['contexts'])
def platforms = project.ext['platforms']
def url = project.ext['url']
def filter = project.ext['filter']
def portalVersion = project.ext['portalVersion']
def version = project.version
def packageName = project.ext['packageName']
def description = project.description
if (all) {
platforms = read('Platforms', platforms)
url = read('Server URL', url)
filter = read('Filter', filter, false)
portalVersion = read('Portal Version', portalVersion)
version = read('Module Version', version)
}
def moduleDir = "${project.rootDir}/modules/$contexts/"
file(moduleDir).mkdirs()
def props = file("$moduleDir/gradle.properties")
props.createNewFile()
write(props, 'contexts', contexts)
write(props, 'destination', '.')
if (all) {
write(props, 'platforms', platforms)
write(props, 'url', url)
write(props, 'filter', filter)
write(props, 'portalVersion', portalVersion)
write(props, 'version', version, project.version)
}
if (platforms.contains('android')) {
packageName = read('Package Name', packageName)
description = read('POM Description', description)
write(props, 'packageName', packageName)
write(props, 'description', description, project.description)
}
generate.args = [
"platforms=$platforms",
"url=$url",
"contexts=$contexts",
"filter=$filter",
"packageName=$packageName",
"portalVersion=$portalVersion",
"destination=$moduleDir"
]
println addTextColor("Module was successfully created at ${moduleDir}.", COLORS.GREEN)
println addTextColor("SDK Builder will generate now all services with the details you provided.", COLORS.GREEN)
}
else {
println addTextColor("Error while getting console.", COLORS.RED)
}
}
}
createModule {
group = tasksGroup
description = "Creates SDK Builder modules."
}
def isJavaCompile() {
return gradle.startParameter.taskNames.size() > 0 && gradle.startParameter.taskNames.get(0).equals("jar")
}
def addTextColor(text, startColor, endColor=COLORS.WHITE) {
return "${Character.toChars(27)}[${startColor}m${text}${Character.toChars(27)}[${endColor}m"
}
def read(phrase, property, required=true) {
def console = System.console()
def coloredProperty = addTextColor(" [${property}]", COLORS.CYAN, COLORS.YELLOW)
def defaultValue = (property.isAllWhitespace()) ? '' : coloredProperty
def line = console.readLine(addTextColor("${phrase}${defaultValue}: ", COLORS.YELLOW))
if (!line.isAllWhitespace()) {
property = line
}
if (required && property.isAllWhitespace()) {
println addTextColor("This property is required and can't be empty.", COLORS.RED)
property = read(phrase, property, true)
}
return property
}
def write(file, key, value, defaultValue=project.ext[key]) {
if (defaultValue != value) {
file.append("${key}=${value}${N}")
}
}