diff --git a/.gitignore b/.gitignore index 0f02b4c0..92a71b67 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ # mpeltonen/sbt-idea plugin .idea_modules/ + +/secrets.gradle.kts +/*.keystore diff --git a/app/.gitignore b/app/.gitignore index be07e02f..2abde4aa 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,3 +1,2 @@ /build -/src/main/res/values/secrets.xml -/google-services.json \ No newline at end of file +/google-services.json diff --git a/app/build.gradle b/app/build.gradle index f8cd2112..eed227cf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,6 +4,25 @@ apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'io.fabric' +def secretsFilename = "secrets.gradle.kts" +try { + apply from: "$rootDir/$secretsFilename" +} catch (e) { + throw new GradleException( + "To build this project, you must make a `$secretsFilename` file that provides the " + + "required secrets keys.\n" + + "To get your secret keys, go here: " + + "https://app.put.io/settings/account/oauth/apps" + + """ +Example `$secretsFilename`: + +extra["secrets"] = PutioSecrets( + putioClientId = "your put.io Client ID", + putioApiKey = "your put.io API key" +) +""", e) +} + repositories { maven { url 'https://maven.fabric.io/public' @@ -25,14 +44,30 @@ android { arg("room.schemaLocation", "$projectDir/schemas") } } + + resValue "string", "putio_client_id", secrets.putioClientId + resValue "string", "putio_api_key", secrets.putioApiKey + } + signingConfigs { + if (secrets.keystorePath != null) { + release { + storeFile file(secrets.keystorePath) + storePassword secrets.keystorePassword + keyAlias secrets.keyAlias + keyPassword secrets.keyPassword + } + } } buildTypes { debug { versionNameSuffix "-debug" - manifestPlaceholders = [crashlyticsEnabled:false] + manifestPlaceholders = [crashlyticsEnabled: false] } release { - manifestPlaceholders = [crashlyticsEnabled:true] + if (signingConfigs.findByName("release") != null) { + signingConfig signingConfigs.release + } + manifestPlaceholders = [crashlyticsEnabled: true] } } lintOptions { diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/buildSrc/.gitignore @@ -0,0 +1 @@ +/build diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 00000000..35bb2de4 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,22 @@ +plugins { + id 'org.jetbrains.kotlin.jvm' version '1.3.11' +} + +repositories { + jcenter() +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" +} + +compileKotlin { + kotlinOptions { + jvmTarget = "1.8" + } +} +compileTestKotlin { + kotlinOptions { + jvmTarget = "1.8" + } +} diff --git a/buildSrc/src/main/java/PutioSecrets.kt b/buildSrc/src/main/java/PutioSecrets.kt new file mode 100644 index 00000000..05aff03b --- /dev/null +++ b/buildSrc/src/main/java/PutioSecrets.kt @@ -0,0 +1,9 @@ +class PutioSecrets( + val keystorePath: String? = null, + val keystorePassword: String? = null, + val keyAlias: String? = null, + val keyPassword: String? = null, + + val putioClientId: String, + val putioApiKey: String +)