Skip to content

Commit 0fd0f0f

Browse files
author
Christiaan de Die le Clercq
committed
Correct signingconfig for Android
1 parent 561b895 commit 0fd0f0f

File tree

3 files changed

+94
-54
lines changed

3 files changed

+94
-54
lines changed

README.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,81 @@
11
# android-ci
2-
Helper library to automatically build and publish a Android app via CI.
2+
[ ![Download](https://api.bintray.com/packages/uncinc/android-ci/UncIncAndroidCIPlugin/images/download.svg) ](https://bintray.com/uncinc/android-ci/UncIncAndroidCIPlugin/_latestVersion)
3+
4+
Helper library to automatically build [~~and publish~~](https://github.com/uncinc/android-ci/issues/1) an Android app via CI.
35

4-
In early alpha stage currently. Documentation will follow.
6+
The current library is an internal testing alpha release, more documentation and features will be available in the future. Feature requests are welcome, please submit a Github issue.
7+
8+
## Setup
9+
1. Include the repository, to your root build.gradle add the following contents:
10+
```gradle
11+
buildscript {
12+
repositories {
13+
maven {
14+
url "https://dl.bintray.com/uncinc/android-ci"
15+
}
16+
}
17+
dependencies {
18+
classpath 'nl.uncinc.androidci:UncIncAndroidCI:0.2'
19+
}
20+
}
21+
```
22+
2. In your app's build.gradle add the following before the `android {` block:
23+
```
24+
apply plugin: 'nl.uncinc.androidci'
25+
```
26+
3. Replace version code, version name, and the signing config for the release build in the Android config:
27+
```
28+
android {
29+
defaultConfig {
30+
versionCode project.ext.androidciconfig.getVersionCode()
31+
versionName project.ext.androidciconfig.getVersionName()
32+
}
33+
34+
buildTypes {
35+
release {
36+
signingConfig project.ext.androidciconfig.getSigningConfig(project)
37+
}
38+
}
39+
}
40+
```
41+
4. Create a signingProperties file in the build context (example, this as signing.properties):
42+
```
43+
storePassword=keystorePassword
44+
keyPassword=keyPassword
45+
keyAlias=key0
46+
storeFile=/Full/Path/To/keystore.jks
47+
```
48+
5. For building the app use:
49+
```
50+
./gradlew -Pandroidci.signingProperties=/Full/Path/To/signing.properties -Pandroidci.versionCode=2
51+
```
52+
53+
# 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 |
59+
60+
# License
61+
MIT License
62+
63+
Copyright (c) 2020 Unc Inc
64+
65+
Permission is hereby granted, free of charge, to any person obtaining a copy
66+
of this software and associated documentation files (the "Software"), to deal
67+
in the Software without restriction, including without limitation the rights
68+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
69+
copies of the Software, and to permit persons to whom the Software is
70+
furnished to do so, subject to the following conditions:
71+
72+
The above copyright notice and this permission notice shall be included in all
73+
copies or substantial portions of the Software.
74+
75+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
78+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
79+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
80+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
81+
SOFTWARE.

build.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

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

1111
repositories {
@@ -35,7 +35,7 @@ apply plugin: 'maven'
3535
uploadArchives {
3636
repositories {
3737
mavenDeployer {
38-
repository(url: uri('/Users/techwolf12/local-gradle-repo'))
38+
repository(url: uri('/Users/techwolf12/gradletest'))
3939
}
4040
}
4141
}
@@ -45,10 +45,14 @@ bintray {
4545
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
4646
configurations = ['archives']
4747
pkg {
48-
repo = 'maven'
49-
name = 'android-ci'
48+
repo = 'android-ci'
49+
name = 'UncIncAndroidCIPlugin'
5050
userOrg = 'uncinc'
5151
licenses = ['MIT']
5252
vcsUrl = 'https://github.com/uncinc/android-ci.git'
53+
version {
54+
name = '0.2'
55+
vcsTag = '0.2'
56+
}
5357
}
5458
}

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

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package nl.uncinc.androidci
22

3-
import com.android.builder.model.SigningConfig
3+
import com.android.build.gradle.internal.dsl.SigningConfig
44
import org.gradle.api.Plugin
55
import org.gradle.api.Project
66

@@ -51,53 +51,12 @@ class UncIncAndroidCIPlugin implements Plugin<Project> {
5151
return androidci.versionName
5252
}
5353

54-
SigningConfig getSigningConfig() {
55-
def signingConfig = new SigningConfig() {
56-
@Override
57-
String getName() {
58-
return "androidcisigning"
59-
}
60-
61-
@Override
62-
File getStoreFile() {
63-
return file(androidci.keystoreProperties['storeFile'])
64-
}
65-
66-
@Override
67-
String getStorePassword() {
68-
return androidci.keystoreProperties['storePassword']
69-
}
70-
71-
@Override
72-
String getKeyAlias() {
73-
return androidci.keystoreProperties['keyAlias']
74-
}
75-
76-
@Override
77-
String getKeyPassword() {
78-
return androidci.keystoreProperties['keyPassword']
79-
}
80-
81-
@Override
82-
String getStoreType() {
83-
return androidci.keystoreProperties['storeFileType']
84-
}
85-
86-
@Override
87-
boolean isV1SigningEnabled() {
88-
return true
89-
}
90-
91-
@Override
92-
boolean isV2SigningEnabled() {
93-
return true
94-
}
95-
96-
@Override
97-
boolean isSigningReady() {
98-
return true
99-
}
100-
}
54+
SigningConfig getSigningConfig(Project project) {
55+
def signingConfig = new SigningConfig()
56+
signingConfig.storeFile = project.file(androidci.keystoreProperties['storeFile'])
57+
signingConfig.storePassword = androidci.keystoreProperties['storePassword']
58+
signingConfig.keyAlias = androidci.keystoreProperties['keyAlias']
59+
signingConfig.keyPassword = androidci.keystoreProperties['keyPassword']
10160
return signingConfig
10261
}
10362

0 commit comments

Comments
 (0)