-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3f4be0c
Showing
118 changed files
with
2,680 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/.idea | ||
.DS_Store | ||
/build | ||
build/ | ||
.externalNativeBuild | ||
.cxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
`kotlin-dsl` // This enables src/main/kotlin | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30") | ||
implementation("com.android.tools.build:gradle:7.0.4") | ||
api(project(":android-plugins")) | ||
} |
25 changes: 25 additions & 0 deletions
25
mono-build-logic/android-k-plugins/src/main/kotlin/app-android-module.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import com.blundell.systemPropertyIsInAppPurchaseTest | ||
|
||
plugins { | ||
id("android-module") | ||
id("com.android.application") | ||
id("kotlin-android") | ||
id("kotlin-kapt") | ||
} | ||
|
||
android { | ||
buildTypes { | ||
getByName("release") { | ||
isMinifyEnabled = true | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
getByName("debug") { | ||
isDebuggable = true | ||
if (systemPropertyIsInAppPurchaseTest()) { | ||
println(" IAP TEST - DEBUG BUILD WITH PROD PACKAGE NAME -") | ||
} else { | ||
applicationIdSuffix = ".debug" | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
mono-build-logic/android-k-plugins/src/main/kotlin/com/blundell/GradleKtsExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.blundell | ||
|
||
import com.android.build.api.dsl.ApplicationDefaultConfig | ||
import com.android.build.api.dsl.VariantDimension | ||
|
||
fun ApplicationDefaultConfig.appIdentifier(): String { | ||
return "${applicationId}${applicationIdSuffix ?: ""}" | ||
} | ||
|
||
fun VariantDimension.buildConfigStringField(key: String, value: String) { | ||
buildConfigField("String", key, value) | ||
println(" $key BuildConfig: $value") | ||
} | ||
|
||
fun VariantDimension.resStringValue(key: String, value: String) { | ||
resValue("string", key, value) | ||
println(" $key ResourceString: $value") | ||
} | ||
|
||
fun quotedString(value: String): String { | ||
return "\"${value}\"" | ||
} | ||
|
||
fun systemPropertyIsInAppPurchaseTest(): Boolean { | ||
return System.getProperty("iap-test", "false").toBoolean() | ||
} | ||
|
||
/** | ||
* Cannot access class 'java.io.File'. Check your module classpath for missing or conflicting dependencies | ||
* ^ avoiding this errors (seems like a gradle bug) by duplicating this method in each settings.gradle.kts | ||
*/ | ||
//fun SettingsDelegate.monoInclude(name: String) { | ||
// include(":$name") | ||
// val project: ProjectDescriptor = project(":$name") | ||
// project.projectDir = File("../mono-libraries/$name") | ||
//} |
15 changes: 15 additions & 0 deletions
15
mono-build-logic/android-k-plugins/src/main/kotlin/com/blundell/SemVersion.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.blundell | ||
|
||
data class SemVersion(val major: Int, val minor: Int, val patch: Int, val build: Int) { | ||
|
||
/** | ||
* 'nnn.nnn.nnn' (leading zero's dropped) | ||
*/ | ||
fun asCode(): Int { | ||
return (major * 10_000 + minor * 1000 + patch * 100) + build | ||
} | ||
|
||
fun asName(): String { | ||
return "$major.$minor.$patch" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
mono-build-logic/android-k-plugins/src/main/kotlin/library-android-module.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
plugins { | ||
id("android-module") | ||
id("com.android.library") | ||
id("kotlin-android") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugins { | ||
id("groovy-gradle-plugin") // This enables src/main/groovy | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30") | ||
implementation("com.android.tools.build:gradle:7.0.4") | ||
} |
42 changes: 42 additions & 0 deletions
42
mono-build-logic/android-plugins/src/main/groovy/android-module.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
afterEvaluate { project -> | ||
if (project.hasProperty("android")) { | ||
android { | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
minSdk 28 | ||
targetSdk 30 | ||
|
||
vectorDrawables { | ||
useSupportLibrary true | ||
} | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
testOptions { | ||
unitTests.returnDefaultValues = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion compose_version | ||
} | ||
packagingOptions { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_11 | ||
targetCompatibility JavaVersion.VERSION_11 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "11" | ||
useIR = true | ||
} | ||
buildFeatures { | ||
compose true | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
google() | ||
} | ||
} | ||
|
||
include("android-plugins") | ||
include("android-k-plugins") | ||
include("tut-app-1-plugins") | ||
include("tut-app-2-plugins") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/.idea | ||
.DS_Store | ||
/build | ||
build/ | ||
.externalNativeBuild | ||
.cxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
// id("groovy-gradle-plugin") // This enables src/main/groovy | ||
`kotlin-dsl` // This enables src/main/kotlin | ||
// id("java-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30") // 1.4.10 | ||
implementation("com.android.tools.build:gradle:7.0.4") //4.1.0 | ||
implementation(project(":android-k-plugins")) | ||
} |
19 changes: 19 additions & 0 deletions
19
mono-build-logic/tut-app-1-plugins/src/main/kotlin/tut-app-1.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import com.blundell.SemVersion | ||
|
||
plugins { | ||
id("app-android-module") | ||
id("com.android.application") | ||
id("kotlin-android") | ||
id("kotlin-kapt") | ||
} | ||
|
||
android { | ||
defaultConfig { | ||
applicationId = "com.blundell.tut1" | ||
|
||
SemVersion(0, 1, 0, 0).apply { | ||
versionCode = asCode() | ||
versionName = asName() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/.idea | ||
.DS_Store | ||
/build | ||
build/ | ||
.externalNativeBuild | ||
.cxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
// id("groovy-gradle-plugin") // This enables src/main/groovy | ||
`kotlin-dsl` // This enables src/main/kotlin | ||
// id("java-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30") // 1.4.10 | ||
implementation("com.android.tools.build:gradle:7.0.4") //4.1.0 | ||
implementation(project(":android-k-plugins")) | ||
} |
19 changes: 19 additions & 0 deletions
19
mono-build-logic/tut-app-2-plugins/src/main/kotlin/tut-app-2.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import com.blundell.* | ||
|
||
plugins { | ||
id("app-android-module") | ||
id("com.android.application") | ||
id("kotlin-android") | ||
id("kotlin-kapt") | ||
} | ||
|
||
android { | ||
defaultConfig { | ||
applicationId = "com.blundell.tut2" | ||
|
||
SemVersion(0, 1, 3, 0).apply { | ||
versionCode = asCode() | ||
versionName = asName() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build | ||
.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This module handles talking through HTTP. | ||
It also makes some assumptions about mobile connections: | ||
- we'll want to retry failed connections a few times before reporting an error | ||
- we expect timeouts to be longer than the default on mobile (TODO) | ||
- we want errors to be reported as kotlin.Result and not exceptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
plugins { | ||
id("library-android-module") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":logging")) | ||
|
||
implementation("androidx.core:core-ktx:1.6.0") | ||
val composeVersion = rootProject.extra["compose_version"] | ||
implementation("androidx.compose.runtime:runtime-livedata:$composeVersion") | ||
implementation("com.squareup.okhttp3:okhttp:4.9.1") | ||
|
||
testImplementation("junit:junit:latest.release") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="modularisation.blundell.library.http"> | ||
|
||
</manifest> |
40 changes: 40 additions & 0 deletions
40
mono-libraries/http/src/main/java/modularisation/blundell/library/http/OkHttpExecutor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package modularisation.blundell.library.http | ||
|
||
import modularisation.blundell.library.http.api.NetworkException | ||
import modularisation.blundell.library.http.api.NetworkException.Failure | ||
import modularisation.blundell.library.http.api.NetworkException.Timeout | ||
import modularisation.blundell.library.logging.api.Logg | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
import okhttp3.Response | ||
import java.io.InterruptedIOException | ||
import java.net.SocketTimeoutException | ||
|
||
class OkHttpExecutor( | ||
private val logg: Logg, | ||
private val client: OkHttpClient, | ||
) { | ||
|
||
/** | ||
* TODO retries | ||
*/ | ||
internal fun execute(request: Request): Result<Response> { | ||
logg.d("Executing request [${request.method}/${request.url}]") | ||
try { | ||
val response = this.client.newCall(request).execute() | ||
if (response.isSuccessful) { | ||
return Result.success(response) | ||
} else { | ||
logg.e("Network exception [${response.code}].") | ||
return Result.failure(NetworkException(Failure("${response.code}/${response.message}"))) | ||
} | ||
} catch (e: SocketTimeoutException) { | ||
logg.e("Socket exception.") | ||
return Result.failure(NetworkException(Timeout(e))) | ||
} catch (e: InterruptedIOException) { | ||
logg.e("Interrupted exception.") | ||
return Result.failure(NetworkException(Timeout(e))) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.