Skip to content

Commit 95ae12e

Browse files
author
Christiaan de Die le Clercq
committed
Allow applicationId from CI config.
1 parent 4aa96c0 commit 95ae12e

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ buildscript {
1515
}
1616
}
1717
dependencies {
18-
classpath 'nl.uncinc.androidci:UncIncAndroidCI:0.2'
18+
classpath 'nl.uncinc.androidci:UncIncAndroidCI:0.3'
1919
}
2020
}
2121
```
@@ -27,13 +27,14 @@ apply plugin: 'nl.uncinc.androidci'
2727
```
2828
android {
2929
defaultConfig {
30-
versionCode project.ext.androidciconfig.getVersionCode()
31-
versionName project.ext.androidciconfig.getVersionName()
30+
applicationId project.ext.androidci.getApplicationId("nl.uncinc.demo")
31+
versionCode project.ext.androidci.getVersionCode()
32+
versionName project.ext.androidci.getVersionName()
3233
}
3334
3435
buildTypes {
3536
release {
36-
signingConfig project.ext.androidciconfig.getSigningConfig(project)
37+
signingConfig project.ext.androidci.getSigningConfig()
3738
}
3839
}
3940
}
@@ -51,11 +52,12 @@ storeFile=/Full/Path/To/keystore.jks
5152
```
5253

5354
# Possible properties
54-
| Property | Purpose | Default Value |
55-
|-----------------------------|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
56-
| androidci.signingProperties | Full path to the file with the signing configuration. Should be available to CI. | android-app-signing.properties (and if it does not exist. The Debug build key) |
57-
| androidci.versionCode | Android versionCode, use an Integer value | 1 |
58-
| androidci.versionName | Android versionName, should be a String | Git hash of the repo |
55+
| Property | Purpose | Default Value |
56+
|-----------------------------|------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
57+
| androidci.signingProperties | Full path to the file with the signing configuration. Should be available to CI. | android-app-signing.properties (and if it does not exist. The Debug build key) |
58+
| androidci.versionCode | Android versionCode, use an Integer value | 1 |
59+
| androidci.versionName | Android versionName, should be a String | Git hash of the repo |
60+
| androidci.applicationId | Override for application identifier, for multiple app flavours (e.g. Beta release) | Parameter given in the android defaultConfig |
5961

6062
# License
6163
MIT License

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group 'nl.uncinc.androidci'
8-
version '0.2'
8+
version '0.3'
99
sourceCompatibility = 1.8
1010

1111
repositories {

src/main/groovy/nl/uncinc/androidci/UncIncAndroidCIPlugin.groovy

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ import org.gradle.api.Project
77

88
class UncIncAndroidCIPlugin implements Plugin<Project> {
99
def androidci = new Properties()
10+
Project project
1011

1112
void apply(Project project) {
13+
this.project = project
14+
15+
androidci.signingProperies = project.hasProperty('androidci.signingProperties')
16+
? project.getProperty('androidci.signingProperties') : 'android-app-signing.properties'
17+
androidci.versionCode = project.hasProperty('androidci.versionCode')
18+
? project.getProperty('androidci.versionCode') as Integer : 1
19+
androidci.versionName = project.hasProperty('androidci.versionName')
20+
? project.getProperty('androidci.versionName') : getGitHash()
1221

13-
androidci.signingProperies = project.hasProperty('androidci.signingProperties') ? project.getProperty('androidci.signingProperties') : 'android-app-signing.properties'
14-
androidci.versionCode = project.hasProperty('androidci.versionCode') ? project.getProperty('androidci.versionCode') as Integer : 1
15-
androidci.versionName = project.hasProperty('androidci.versionName') ? project.getProperty('androidci.versionName') : getGitHash(project)
1622
def keystoreProperties = new Properties()
1723

1824
if (project.file(androidci.signingProperies).exists()) {
@@ -23,7 +29,8 @@ class UncIncAndroidCIPlugin implements Plugin<Project> {
2329
keystoreProperties.setProperty("storeFileType", 'jks')
2430
}
2531
} else {
26-
project.logger.error("No release build via CI currently or signing properties file not found. Defaulting to debug keystore for CI configuration.")
32+
project.logger.error("No release build via CI currently or signing properties file not found." +
33+
" Defaulting to debug keystore for CI configuration.")
2734
keystoreProperties.setProperty("keyAlias", 'androiddebugkey')
2835
keystoreProperties.setProperty("keyPassword", 'android')
2936
keystoreProperties.setProperty("storePassword", 'android')
@@ -32,26 +39,35 @@ class UncIncAndroidCIPlugin implements Plugin<Project> {
3239

3340
}
3441
androidci.keystoreProperties = keystoreProperties
35-
project.ext.androidciconfig = this
42+
43+
// Expose this class to the project
44+
project.ext.androidci = this
3645

3746
project.task('printAndroidCIVars') {
3847
doLast {
3948
println 'Signing: ' + androidci.signingProperies
4049
println 'versionCode: ' + androidci.versionCode
4150
println 'versionName: ' + androidci.versionName
51+
println 'androidApplicationId': + androidci.applicationId
4252
}
4353
}
4454
}
4555

4656
Integer getVersionCode() {
47-
return androidci.versionCode
57+
return androidci.versionCode as Integer
4858
}
4959

5060
String getVersionName() {
5161
return androidci.versionName
5262
}
5363

54-
SigningConfig getSigningConfig(Project project) {
64+
String getApplicationId(String appId) {
65+
androidci.applicationId = project.hasProperty('androidci.applicationId')
66+
? project.getProperty('androidci.applicationId') : appId
67+
return androidci.applicationId
68+
}
69+
70+
SigningConfig getSigningConfig() {
5571
def signingConfig = new SigningConfig("CIStore")
5672
signingConfig.storeFile = project.file(androidci.keystoreProperties['storeFile'])
5773
signingConfig.storePassword = androidci.keystoreProperties['storePassword']
@@ -60,7 +76,7 @@ class UncIncAndroidCIPlugin implements Plugin<Project> {
6076
return signingConfig
6177
}
6278

63-
String getGitHash(Project project) {
79+
String getGitHash() {
6480
def stdout = new ByteArrayOutputStream()
6581
project.exec {
6682
commandLine 'git', 'rev-parse', '--short', 'HEAD'

0 commit comments

Comments
 (0)