From 0fd0f0f0f9cf34abc7622f4e6823e9e5edaaa56f Mon Sep 17 00:00:00 2001 From: Christiaan de Die le Clercq Date: Mon, 3 Aug 2020 15:07:41 +0200 Subject: [PATCH] Correct signingconfig for Android --- README.md | 81 ++++++++++++++++++- build.gradle | 12 ++- .../androidci/UncIncAndroidCIPlugin.groovy | 55 ++----------- 3 files changed, 94 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 461857c..4d38e65 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,81 @@ # android-ci -Helper library to automatically build and publish a Android app via CI. + [ ![Download](https://api.bintray.com/packages/uncinc/android-ci/UncIncAndroidCIPlugin/images/download.svg) ](https://bintray.com/uncinc/android-ci/UncIncAndroidCIPlugin/_latestVersion) + +Helper library to automatically build [~~and publish~~](https://github.com/uncinc/android-ci/issues/1) an Android app via CI. -In early alpha stage currently. Documentation will follow. +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. + +## Setup +1. Include the repository, to your root build.gradle add the following contents: +```gradle +buildscript { + repositories { + maven { + url "https://dl.bintray.com/uncinc/android-ci" + } + } + dependencies { + classpath 'nl.uncinc.androidci:UncIncAndroidCI:0.2' + } +} +``` +2. In your app's build.gradle add the following before the `android {` block: +``` +apply plugin: 'nl.uncinc.androidci' +``` +3. Replace version code, version name, and the signing config for the release build in the Android config: +``` +android { + defaultConfig { + versionCode project.ext.androidciconfig.getVersionCode() + versionName project.ext.androidciconfig.getVersionName() + } + + buildTypes { + release { + signingConfig project.ext.androidciconfig.getSigningConfig(project) + } + } +} +``` +4. Create a signingProperties file in the build context (example, this as signing.properties): +``` +storePassword=keystorePassword +keyPassword=keyPassword +keyAlias=key0 +storeFile=/Full/Path/To/keystore.jks +``` +5. For building the app use: +``` +./gradlew -Pandroidci.signingProperties=/Full/Path/To/signing.properties -Pandroidci.versionCode=2 +``` + +# Possible properties +| Property | Purpose | Default Value | +|-----------------------------|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------| +| 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) | +| androidci.versionCode | Android versionCode, use an Integer value | 1 | +| androidci.versionName | Android versionName, should be a String | Git hash of the repo | + +# License +MIT License + +Copyright (c) 2020 Unc Inc + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/build.gradle b/build.gradle index ed7d846..5500c7f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group 'nl.uncinc.androidci' -version '1.0' +version '0.2' sourceCompatibility = 1.8 repositories { @@ -35,7 +35,7 @@ apply plugin: 'maven' uploadArchives { repositories { mavenDeployer { - repository(url: uri('/Users/techwolf12/local-gradle-repo')) + repository(url: uri('/Users/techwolf12/gradletest')) } } } @@ -45,10 +45,14 @@ bintray { key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') configurations = ['archives'] pkg { - repo = 'maven' - name = 'android-ci' + repo = 'android-ci' + name = 'UncIncAndroidCIPlugin' userOrg = 'uncinc' licenses = ['MIT'] vcsUrl = 'https://github.com/uncinc/android-ci.git' + version { + name = '0.2' + vcsTag = '0.2' + } } } \ No newline at end of file diff --git a/src/main/groovy/nl/uncinc/androidci/UncIncAndroidCIPlugin.groovy b/src/main/groovy/nl/uncinc/androidci/UncIncAndroidCIPlugin.groovy index 7ea98b9..9fb4372 100644 --- a/src/main/groovy/nl/uncinc/androidci/UncIncAndroidCIPlugin.groovy +++ b/src/main/groovy/nl/uncinc/androidci/UncIncAndroidCIPlugin.groovy @@ -1,6 +1,6 @@ package nl.uncinc.androidci -import com.android.builder.model.SigningConfig +import com.android.build.gradle.internal.dsl.SigningConfig import org.gradle.api.Plugin import org.gradle.api.Project @@ -51,53 +51,12 @@ class UncIncAndroidCIPlugin implements Plugin { return androidci.versionName } - SigningConfig getSigningConfig() { - def signingConfig = new SigningConfig() { - @Override - String getName() { - return "androidcisigning" - } - - @Override - File getStoreFile() { - return file(androidci.keystoreProperties['storeFile']) - } - - @Override - String getStorePassword() { - return androidci.keystoreProperties['storePassword'] - } - - @Override - String getKeyAlias() { - return androidci.keystoreProperties['keyAlias'] - } - - @Override - String getKeyPassword() { - return androidci.keystoreProperties['keyPassword'] - } - - @Override - String getStoreType() { - return androidci.keystoreProperties['storeFileType'] - } - - @Override - boolean isV1SigningEnabled() { - return true - } - - @Override - boolean isV2SigningEnabled() { - return true - } - - @Override - boolean isSigningReady() { - return true - } - } + SigningConfig getSigningConfig(Project project) { + def signingConfig = new SigningConfig() + signingConfig.storeFile = project.file(androidci.keystoreProperties['storeFile']) + signingConfig.storePassword = androidci.keystoreProperties['storePassword'] + signingConfig.keyAlias = androidci.keystoreProperties['keyAlias'] + signingConfig.keyPassword = androidci.keystoreProperties['keyPassword'] return signingConfig }