-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild.gradle
167 lines (143 loc) · 5.18 KB
/
build.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
166
167
apply plugin: 'io.codearte.nexus-staging'
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
// Android build
classpath 'com.android.tools.build:gradle:' + ANDROID_PLUGIN_GRADLE
// Kotlin
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:' + KOTLIN_VERSION
// Dokka
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:' + KOTLIN_DOKKA
// Nexus staging
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:' + GRADLE_NEXUS_STAGING
}
}
// define global parameters
allprojects {
repositories {
// local maven
mavenLocal()
// basic repositories
google()
mavenCentral()
gradlePluginPortal()
// Logger
maven { url 'https://jitpack.io' }
}
}
// Support for GitHub packages
// currently disabled as GP does not allow auth-less access to public packages (for now 05/2020)
// https://github.community/t5/GitHub-API-Development-and/Download-from-Github-Package-Registry-without-authentication/td-p/35255
//subprojects {
// apply plugin: "maven-publish"
// publishing {
// repositories {
// maven {
// name = "GitHubPackages"
// url = uri("https://maven.pkg.github.com/asamm/locus-api")
// credentials {
// username = System.getenv("GH_USER")
// password = System.getenv("GH_PERSONAL_ACCESS_TOKEN")
// }
// }
// maven {
// name = 'CustomMavenRepo'
// url = "file://${buildDir}/repo"
// }
// }
// }
//}
configure([
project(":locus-api-android-sample")]) {
apply plugin: 'com.android.application'
apply plugin: "kotlin-android"
android {
// setup SDK
compileSdkVersion Integer.valueOf(PARAM_COMPILE_SDK_VERSION)
buildToolsVersion ANDROID_BUILD_TOOLS
defaultConfig {
minSdkVersion Integer.valueOf(PARAM_MIN_SDK_VERSION)
targetSdkVersion Integer.valueOf(PARAM_TARGET_SDK_VERSION)
}
dexOptions {
jumboMode true
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// enable lint in project
lintOptions {
checkReleaseBuilds true
abortOnError true
absolutePaths false
lintConfig file("../lint-global.xml")
}
// signing of versions
signingConfigs {
debug {
storeFile file(System.getenv('ANDROID_SIGN_DEBUG').split("\\|")[0])
storePassword System.getenv('ANDROID_SIGN_DEBUG').split("\\|")[1]
keyAlias System.getenv('ANDROID_SIGN_DEBUG').split("\\|")[2]
keyPassword System.getenv('ANDROID_SIGN_DEBUG').split("\\|")[3]
}
release {
storeFile file(System.getenv('ANDROID_SIGN_RELEASE').split("\\|")[0])
storePassword System.getenv('ANDROID_SIGN_RELEASE').split("\\|")[1]
keyAlias System.getenv('ANDROID_SIGN_RELEASE').split("\\|")[2]
keyPassword System.getenv('ANDROID_SIGN_RELEASE').split("\\|")[3]
}
}
// building task
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}
}
// iterate over all versions
android.applicationVariants.all { variant ->
// define base parameters
println "Config for: " + build
// rename result file
variant.outputs.all {
// generate base name
def newName = variant.name.capitalize()
// remove from 'LocusFreeSamsungDebug', last work 'Debug'
newName = newName.substring(0, newName.length() - variant.buildType.name.length())
// create full name like 'LocusFreeSamsung_342_3.5.2_debug.apk'
def baseFileName = "${newName}_${variant.versionCode}_${variant.versionName}_${variant.buildType.name}"
// set new output file name
outputFileName = "${baseFileName}.apk"
}
// create also release task for "release builds"
variant.productFlavors.each { flavor ->
// do not handle certain flavors at all
def flavorName = flavor.name.capitalize()
if (flavor.name == '') {
return;
}
// skip invalid build types (so generate only releases versions)
if (variant.buildType.name != 'release') {
return;
}
// create task for release
tasks.create(name: variant.buildType.name + flavorName,
dependsOn: variant.assemble) {
group 'Publish'
description "Assembles and archives $flavorName and its proguard mapping for the $build build"
}
}
}
}