Skip to content

Commit

Permalink
Merge pull request #23 from SchwarzIT/feature/upgrade-kotlin
Browse files Browse the repository at this point in the history
Feature/upgrade kotlin
  • Loading branch information
sbra0902 authored Dec 11, 2023
2 parents d96747c + 6a49b62 commit fb7ffd2
Show file tree
Hide file tree
Showing 30 changed files with 175 additions and 218 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android_pre_hook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
cache: gradle

Expand Down
24 changes: 19 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: "org.jlleitschuh.gradle.ktlint"
buildscript {
ext.kotlin_version = '1.7.20'
ext.kotlin_version = '1.9.21'
ext.groupName = 'com.github.SchwarzIT'
repositories {
google()
jcenter()
Expand All @@ -11,17 +12,30 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20'
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.3.0"
classpath 'com.android.tools.build:gradle:8.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.7.20-1.0.7"
classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.9.21-1.0.15"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

def versionName() {

if (!hasProperty("version")) {
// don't care
return "dummy"
}

return property("version")
}

allprojects {
version = versionName()
group = groupName

repositories {
mavenCentral()
jcenter()
Expand Down
24 changes: 12 additions & 12 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "org.jlleitschuh.gradle.ktlint"
apply plugin: "com.google.devtools.ksp"
apply plugin: 'kotlin-allopen'

android {
compileSdkVersion 31
buildToolsVersion "28.0.3"
lint {
checkReleaseBuilds false
abortOnError false
}

namespace 'kaufland.com.demo'
defaultConfig {
applicationId "kaufland.com.demo"
minSdkVersion 21
targetSdkVersion 31
compileSdk = 33
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -25,12 +28,12 @@ android {
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "1.8"
buildFeatures {
viewBinding true
}

// workaround for "duplicate files during packaging of APK" issue:
Expand All @@ -53,10 +56,7 @@ allOpen {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
testImplementation 'junit:junit:4.12'
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion demo/src/main/java/kaufland/com/demo/DemoApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class DemoApplication : Application(), CustomCurator {
}

override fun <V : Any> getInstance(clazz: KClass<*>): V? {

return when (clazz) {
ClassFromAnotherLibrary::class -> ClassFromAnotherLibrary(this)
else -> null
Expand Down
16 changes: 10 additions & 6 deletions demo/src/main/java/kaufland/com/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.schwarz.kokain.di.inject
import kaufland.com.demo.bean.FooBean
import kaufland.com.demo.bean.FooBeanInterface
import kaufland.com.demo.bean.FooSingletonBean
import kotlinx.android.synthetic.main.activity_main.*
import kaufland.com.demo.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

Expand All @@ -19,12 +19,16 @@ class MainActivity : AppCompatActivity() {

private val mClassFromAnotherLibrary: ClassFromAnotherLibrary by inject()

private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
mClassFromAnotherLibrary.doSomething()
btnSwitch.text = "${resources.getString(R.string.switchTo)} $localClassName"
btnSwitch.setOnClickListener {
binding.btnSwitch.text = "${resources.getString(R.string.switchTo)} $localClassName"
binding.btnSwitch.setOnClickListener {
startActivity(Intent(this, MainActivity2::class.java))
finish()
}
Expand All @@ -35,9 +39,9 @@ class MainActivity : AppCompatActivity() {

override fun onResume() {
super.onResume()
runningSinceLbl.text = "Running for ${mSingletonBean.calculateRunningTime()}"
binding.runningSinceLbl.text = "Running for ${mSingletonBean.calculateRunningTime()}"
mFooBean.countUp()
title = mFooBean.saySomething()
customView.doTest()
binding.customView.doTest()
}
}
15 changes: 8 additions & 7 deletions demo/src/main/java/kaufland/com/demo/MainActivity2.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@ import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.schwarz.kokain.di.inject
// import com.schwarz.kokaindi.inject
// import com.schwarz.kokain.api.viewmodel
import kaufland.com.demo.bean.FooBean
import kotlinx.android.synthetic.main.activity_main.*
import kaufland.com.demo.databinding.ActivityMainBinding

class MainActivity2 : AppCompatActivity() {

private val mFooBean: FooBean by inject()

private lateinit var binding: ActivityMainBinding

// private val mBarViewModel: BarViewModel by viewmodel(this@MainActivity)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
title = mFooBean.saySomething()
btnSwitch.text = "${resources.getString(R.string.switchTo)} $localClassName"
btnSwitch.setOnClickListener {
binding.btnSwitch.text = "${resources.getString(R.string.switchTo)} $localClassName"
binding.btnSwitch.setOnClickListener {
startActivity(Intent(this, MainActivity::class.java))
finish()
}
// Log.e("test", test)
}

override fun onResume() {
Expand Down
23 changes: 14 additions & 9 deletions demolibrary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//apply plugin: 'kotlin-kapt'
apply plugin: "org.jlleitschuh.gradle.ktlint"
apply plugin: "com.google.devtools.ksp"

android {
compileSdkVersion 31
buildToolsVersion "29.0.3"

lint {
checkReleaseBuilds false
abortOnError false
}

namespace 'com.example.demolibrary'
defaultConfig {
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 33
compileSdk = 33
versionCode 1
versionName "1.0"

Expand All @@ -25,6 +29,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

}

Expand All @@ -36,14 +44,11 @@ kotlin {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.core:core-ktx:1.8.0'
implementation project(path: ':kokain-di')
implementation project(path: ':kokain-core-api')
ksp ksp(project(':kokain-ksp',))
testImplementation 'junit:junit:4.12'

androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

This file was deleted.

3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
android.useAndroidX=true
android.enableJetifier=true
ksp.incremental.log=true
ksp.incremental.log=true
org.gradle.jvmargs=-Dkotlin.daemon.jvm.options=--illegal-access=permit
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
21 changes: 9 additions & 12 deletions kokain-core-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@ dependencies {
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'com.schwarz.kokain'
artifactId = 'kokain-core-api'
version = '0.1'
groupId project.group
artifactId project.name
version project.version
from components.java
}
}
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17

java {
withSourcesJar()
withJavadocJar()
}
21 changes: 9 additions & 12 deletions kokain-core-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@ apply plugin: "org.jlleitschuh.gradle.ktlint"
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'com.schwarz.kokain'
artifactId = 'kokain-core-lib'
version = '0.1'
groupId project.group
artifactId project.name
version project.version
from components.java
}
}
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17

java {
withSourcesJar()
withJavadocJar()
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ abstract class KokainCore(diFactory: KDiFactory, customCurator: CustomCurator? =
private val customCurator = customCurator

fun <V : Any> create(thisRef: Any, clazz: KClass<*>): V {

var bean = beanLifecycleCurator.getInstance(clazz) as V?
if (bean == null) {
bean = customCurator?.getInstance(clazz)
Expand Down
Loading

0 comments on commit fb7ffd2

Please sign in to comment.