forked from liferay/liferay-mobile-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodules.gradle
158 lines (131 loc) · 4.04 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
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-${contexts}-android-sdk"
sourceSets {
main {
java {
srcDir 'android/src/gen/java'
srcDir 'android/src/main/java'
}
}
test {
java {
srcDir 'android/src/test/java'
}
}
}
dependencies {
compile project(':android')
compile group: 'com.google.android', name: 'android', version: '2.3.3'
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.3'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.3'
testCompile group: 'junit', name: 'junit', version: '4.12-beta-3'
}
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 << {
def console = System.console()
if (console) {
def all = project.hasProperty('all')
def contexts = read("${N}Context", project.ext['contexts'])
def String 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."
}
createModule.finalizedBy(generate)
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}")
}
}