Skip to content

Commit

Permalink
Merge pull request #23 from jtouzy/feature/auto_script
Browse files Browse the repository at this point in the history
Base project generation
  • Loading branch information
jtouzy authored Feb 11, 2020
2 parents 3e3533a + b3dec3c commit b6574a5
Show file tree
Hide file tree
Showing 43 changed files with 2,065 additions and 17 deletions.
15 changes: 0 additions & 15 deletions Examples/DemoApp/buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,16 @@ object Libs {
private object Versions {
const val timber = "4.7.1"
const val koin = "2.0.1"
const val uniflow = "0.9.3"
const val coil = "0.9.2"
const val jsr310 = "1.2.1"
}

const val timber = "com.jakewharton.timber:timber:${Versions.timber}"
const val koinAndroid = "org.koin:koin-androidx-viewmodel:${Versions.koin}"
const val uniflow = "io.uniflow:uniflow-androidx:${Versions.uniflow}"
const val coil = "io.coil-kt:coil:${Versions.coil}"
const val jsr310 = "com.jakewharton.threetenabp:threetenabp:${Versions.jsr310}"
}

object Google {

private object Versions {
const val material = "1.1.0-beta02"
const val firebaseCore = "17.2.1"
const val firebaseMessaging = "20.0.1"
}

const val material = "com.google.android.material:material:${Versions.material}"
const val firebaseCore = "com.google.firebase:firebase-core:${Versions.firebaseCore}"
const val firebaseMessaging = "com.google.firebase:firebase-messaging:${Versions.firebaseMessaging}"
}


object AndroidX {

Expand Down
36 changes: 36 additions & 0 deletions KomposeCli/Templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# built application files
*.apk
*.aab

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file
local.properties

# Intellij project files
*.iml
*.ipr
*.iws
.idea/
*.prefs

# Gradle
build/
.gradle

# Keys
*.jks
google-services.json

# iOS Frameworks
iosApp/Frameworks
xcuserdata/

1 change: 1 addition & 0 deletions KomposeCli/Templates/androidApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
99 changes: 99 additions & 0 deletions KomposeCli/Templates/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright $$YEAR$$ $$AUTHOR$$
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
id("com.android.application")
kotlin("android")
}

val versionMajor = 0
val versionMinor = 0
val versionPatch = 1

android {
compileSdkVersion(Android.compileSdkVersion)

defaultConfig {
applicationId = "$$PROJECT_PACKAGE$$.app"
versionCode = versionMajor * 100 + versionMinor * 10 + versionPatch
versionName = "$versionMajor.$versionMinor.$versionPatch"
vectorDrawables.useSupportLibrary = true
minSdkVersion(Android.minSdkVersion)
targetSdkVersion(Android.targetSdkVersion)
resConfigs("fr")
}

buildTypes {
getByName("release") {
isShrinkResources = true
isMinifyEnabled = true
isDebuggable = false
isJniDebuggable = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

viewBinding { isEnabled = true }

bundle {
language {
enableSplit = true
}
density {
enableSplit = true
}
abi {
enableSplit = true
}
}

sourceSets {
getByName("main").java.srcDirs("src/main/kotlin")
}

packagingOptions {
exclude("**/*.kotlin_module")
exclude("**/*.version")
exclude("**/kotlin/**")
exclude("**/*.txt")
exclude("**/*.xml")
exclude("**/*.properties")
}

buildFeatures {
compose = true
}
}

dependencies {
implementation(project(":shared"))
implementation(kotlin("stdlib", Build.Versions.kotlin))
implementation(Coroutines.core)
implementation(Coroutines.android)
implementation(AndroidX.appCompat)
implementation(AndroidX.coreKtx)
implementation(Libs.koinAndroid)
implementation(Libs.timber)
implementation(Libs.coil)
implementation(AndroidX.composeFoundation)
implementation(AndroidX.composeFramework)
implementation(AndroidX.composeLayout)
implementation(AndroidX.composeMaterial)
implementation(AndroidX.composeTooling)
}
47 changes: 47 additions & 0 deletions KomposeCli/Templates/androidApp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-dontwarn java.lang.invoke.*

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}

# Most of volatile fields are updated with AFU and should not be mangled
-keepclassmembernames class kotlinx.** {
volatile <fields>;
}
# ServiceLoader support
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}

# OkHttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

# Retrofit does reflection on generic parameters and InnerClass is required to use Signature.
-keepattributes Signature, InnerClasses

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.-KotlinExtensions

# ThreeTen ABP
-keep class org.threeten.bp.** { *; }
-keep interface org.threeten.bp.** { *; }
29 changes: 29 additions & 0 deletions KomposeCli/Templates/androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="$$PROJECT_PACKAGE$$.app"
>

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/Theme.Kompose"
tools:ignore="GoogleAppIndexingWarning"
>

<activity android:name=".ui.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
18 changes: 18 additions & 0 deletions KomposeCli/Templates/androidApp/src/main/kotlin/package/app/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package $$PROJECT_PACKAGE$$.app

import android.app.Application
import $$PROJECT_PACKAGE$$.app.di.appModule
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin

class App : Application() {

override fun onCreate() {
super.onCreate()

startKoin {
androidContext(this@App)
modules(appModule)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package $$PROJECT_PACKAGE$$.app.di

import org.koin.dsl.module

val appModule = module {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package $$PROJECT_PACKAGE$$.app.ui

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.Composable
import androidx.ui.core.setContent
import androidx.ui.material.MaterialTheme

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { App() }
}

@Composable
private fun App() {
MaterialTheme(colors = themeColors) {
TODO("Your app here")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package $$PROJECT_PACKAGE$$.app.ui

import androidx.compose.Model
import $$PROJECT_PACKAGE$$.ui.Store
import $$PROJECT_PACKAGE$$.ui.ViewState

@Model
class ObservableStore<T : ViewState>(override var viewState: T) : Store<T>
70 changes: 70 additions & 0 deletions KomposeCli/Templates/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright $$YEAR$$ $$AUTHOR$$
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.github.ben-manes.versions") version "0.27.0"
}

buildscript {
repositories {
jcenter()
google()
maven("https://plugins.gradle.org/m2/")
}

dependencies {
classpath(kotlin("gradle-plugin", Build.Versions.kotlin))
classpath(kotlin("serialization", Build.Versions.kotlin))
classpath(Build.androidGradle)
classpath(Build.xcodeSync)
}
}

allprojects {
repositories {
jcenter()
google()
maven("https://oss.sonatype.org/content/repositories/snapshots")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-progressive", "-Xuse-experimental=kotlin.Experimental")
jvmTarget = "1.8"
}
}
}

subprojects {
afterEvaluate {
extensions.configure<com.android.build.gradle.BaseExtension> {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
}
}

tasks.named<DependencyUpdatesTask>("dependencyUpdates") {
checkForGradleUpdate = true
outputFormatter = "json"
outputDir = "build/dependencyUpdates"
reportfileName = "report"
}
Loading

0 comments on commit b6574a5

Please sign in to comment.