This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Jason Sznol
committed
Nov 19, 2020
0 parents
commit b8bb31a
Showing
43 changed files
with
1,825 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
name: Core | ||
|
||
on: | ||
push: | ||
tags: | ||
- '**' | ||
|
||
env: | ||
ORG_GRADLE_PROJECT_githubUsername: ${{ github.actor }} | ||
ORG_GRADLE_PROJECT_githubPassword: ${{ github.token }} | ||
|
||
jobs: | ||
|
||
publish: | ||
name: Publish | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Cache Gradle and Kotlin packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.konan/dependencies | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Fix Android NDK | ||
run: echo "ndk.dir=$ANDROID_HOME/ndk-bundle" > local.properties | ||
|
||
- name: Publish | ||
run: gradle publish --no-configure-on-demand --no-watch-fs --no-daemon |
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,20 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
|
||
bin/ | ||
gen/ | ||
classes/ | ||
gen-external-apklibs/ | ||
build/ | ||
schemas/ | ||
xcuserdata/ | ||
|
||
iOSInjectionProject/ |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Timehop | ||
|
||
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. |
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,66 @@ | ||
# Kotlin Multiplatform Client ![Core](https://github.com/timehop/kotlin-mpp-template/workflows/Core/badge.svg) | ||
|
||
This repository is a template for creating a new Kotlin Mulitplatform project with Android and iOS | ||
targets using the latest build tooling. | ||
|
||
## IDE Setup | ||
|
||
Before you begin working with the project, install the Kotlin Multiplatform plugin for your IDE of | ||
choice. | ||
|
||
[Android Studio](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile) | ||
[XCode](https://github.com/touchlab/xcode-kotlin) | ||
|
||
## Versioning | ||
|
||
### Project | ||
|
||
The project version defaults to `development` unless built within Github actions which will compute | ||
the version using tag ref that started the build. | ||
|
||
### Dependencies | ||
|
||
Versions for all dependencies are defined in the gradle.properties file to centralize where updates | ||
to libraries happen. | ||
|
||
## One Click Deployments | ||
|
||
To publish a version of the client library, push a tag to the default branch or use the Releases | ||
page to create a new release. This will publish a version that matches the tag name with a | ||
package name generated when deploying from Github Actions in the format `${owner}.mpp` | ||
|
||
## Integrating with an existing project | ||
|
||
Add the following to your Android build | ||
|
||
```kotlin | ||
repositories { | ||
maven { | ||
name = "github" | ||
url = uri("https://maven.pkg.github.com/${owner}/${repository}") | ||
credentials(PasswordCredentials) | ||
// Optional filter to speed up dependency resolution | ||
content { | ||
includeGroup("${owner}.mpp") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("${owner}.mpp:core") | ||
} | ||
``` | ||
|
||
### buildSrc gradle.properties symlink | ||
|
||
To simplify updates to gradle.properties, the buildSrc gradle.properties file is symlinked to the | ||
root of the project. | ||
|
||
#### Windows symlinks | ||
|
||
Symlink creation requires admin access. If you have admin access delete the | ||
buildSrc/gradle.properties and run the following command from the root of the project | ||
|
||
```shell script | ||
cmd> mklink /H "buildSrc/gradle.properties" "gradle.properties" | ||
``` |
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 @@ | ||
plugins { | ||
id("com.android.application") | ||
kotlin("android") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":core")) | ||
implementation(androidx("annotation")) | ||
implementation(androidx("appcompat")) | ||
implementation(androidx("constraintlayout")) | ||
} | ||
|
||
android { | ||
compileSdk = project.compileSdk | ||
defaultConfig { | ||
applicationId = "${project.group}.android" | ||
minSdk = project.minSdk | ||
targetSdk = project.targetSdk | ||
versionCode = 1 | ||
versionName = "${project.version}" | ||
} | ||
|
||
buildFeatures { | ||
viewBinding = true | ||
} | ||
|
||
buildTypes { | ||
getByName("release") { | ||
isMinifyEnabled = false | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility(JavaVersion.VERSION_1_8) | ||
targetCompatibility(JavaVersion.VERSION_1_8) | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_1_8.toString() | ||
useIR = 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,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="template.mpp.android"> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
16 changes: 16 additions & 0 deletions
16
android/app/src/main/java/template/mpp/android/MainActivity.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,16 @@ | ||
package template.mpp.android | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.widget.TextView | ||
import template.mpp.core.Platform | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
val tv: TextView = findViewById(R.id.text_view) | ||
tv.text = Platform().platform | ||
} | ||
} |
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,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:id="@+id/main_view" | ||
tools:context=".MainActivity"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" | ||
android:id="@+id/text_view" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#FBCF27</color> | ||
<color name="colorPrimaryDark">#B08A00</color> | ||
<color name="colorAccent">#14B6EF</color> | ||
</resources> |
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,10 @@ | ||
<resources> | ||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |
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 @@ | ||
allprojects { | ||
group = System.getenv("GITHUB_REPOSITORY")?.split('/')?.first()?.plus(".mpp") ?: "mpp" | ||
version = System.getenv("GITHUB_REF")?.split('/')?.last() ?: "development" | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} |
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 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
`kotlin-dsl-precompiled-script-plugins` | ||
} | ||
|
||
repositories { | ||
jcenter() | ||
google() | ||
} | ||
|
||
dependencies { | ||
implementation("com.android.tools.build:gradle:${property("agp")}") | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${property("kgp")}") | ||
|
||
} |
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 @@ | ||
../gradle.properties |
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 @@ | ||
import org.gradle.api.Project | ||
|
||
fun Project.intProperty(propName: String) = Integer.parseInt(property(propName) as String) | ||
|
||
inline val Project.compileSdk: Int get() = intProperty("android.sdk.compile") | ||
inline val Project.minSdk: Int get() = intProperty("android.sdk.min") | ||
inline val Project.targetSdk: Int get() = intProperty("android.sdk.target") | ||
|
||
fun Project.androidx(library: String) = | ||
"androidx.$library:$library:${property("androidx.$library")}" | ||
|
Oops, something went wrong.