diff --git a/.github/workflows/android_pre_hook.yml b/.github/workflows/android_pre_hook.yml
index 2afa101..60d9fd0 100644
--- a/.github/workflows/android_pre_hook.yml
+++ b/.github/workflows/android_pre_hook.yml
@@ -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
diff --git a/build.gradle b/build.gradle
index 1c390e9..16410b0 100755
--- a/build.gradle
+++ b/build.gradle
@@ -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()
@@ -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()
diff --git a/demo/build.gradle b/demo/build.gradle
index 043e2ab..e444b67 100644
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -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"
@@ -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:
@@ -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'
diff --git a/demo/src/androidTest/java/kaufland/com/demo/ExampleInstrumentedTest.java b/demo/src/androidTest/java/kaufland/com/demo/ExampleInstrumentedTest.java
deleted file mode 100644
index 6babf30..0000000
--- a/demo/src/androidTest/java/kaufland/com/demo/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package kaufland.com.demo;
-
-import android.content.Context;
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("kaufland.com.demo", appContext.getPackageName());
- }
-}
diff --git a/demo/src/main/java/kaufland/com/demo/DemoApplication.kt b/demo/src/main/java/kaufland/com/demo/DemoApplication.kt
index 7140531..447c89f 100644
--- a/demo/src/main/java/kaufland/com/demo/DemoApplication.kt
+++ b/demo/src/main/java/kaufland/com/demo/DemoApplication.kt
@@ -18,7 +18,6 @@ class DemoApplication : Application(), CustomCurator {
}
override fun getInstance(clazz: KClass<*>): V? {
-
return when (clazz) {
ClassFromAnotherLibrary::class -> ClassFromAnotherLibrary(this)
else -> null
diff --git a/demo/src/main/java/kaufland/com/demo/MainActivity.kt b/demo/src/main/java/kaufland/com/demo/MainActivity.kt
index 582798d..ab6a94a 100644
--- a/demo/src/main/java/kaufland/com/demo/MainActivity.kt
+++ b/demo/src/main/java/kaufland/com/demo/MainActivity.kt
@@ -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() {
@@ -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()
}
@@ -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()
}
}
diff --git a/demo/src/main/java/kaufland/com/demo/MainActivity2.kt b/demo/src/main/java/kaufland/com/demo/MainActivity2.kt
index 618bbed..efeae33 100644
--- a/demo/src/main/java/kaufland/com/demo/MainActivity2.kt
+++ b/demo/src/main/java/kaufland/com/demo/MainActivity2.kt
@@ -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() {
diff --git a/demolibrary/build.gradle b/demolibrary/build.gradle
index 28ad350..b21ea13 100644
--- a/demolibrary/build.gradle
+++ b/demolibrary/build.gradle
@@ -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"
@@ -25,6 +29,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
}
@@ -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'
}
diff --git a/demolibrary/src/androidTest/java/com/example/demolibrary/ExampleInstrumentedTest.kt b/demolibrary/src/androidTest/java/com/example/demolibrary/ExampleInstrumentedTest.kt
deleted file mode 100644
index e8cf2be..0000000
--- a/demolibrary/src/androidTest/java/com/example/demolibrary/ExampleInstrumentedTest.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.example.demolibrary
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.platform.app.InstrumentationRegistry
-import org.junit.Assert.assertEquals
-import org.junit.Test
-import org.junit.runner.RunWith
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-@RunWith(AndroidJUnit4::class)
-class ExampleInstrumentedTest {
- @Test
- fun useAppContext() {
- // Context of the app under test.
- val appContext = InstrumentationRegistry.getInstrumentation().targetContext
- assertEquals("com.example.demolibrary.test", appContext.packageName)
- }
-}
diff --git a/gradle.properties b/gradle.properties
index cc9d33e..f2e50b8 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,3 +1,4 @@
android.useAndroidX=true
android.enableJetifier=true
-ksp.incremental.log=true
\ No newline at end of file
+ksp.incremental.log=true
+org.gradle.jvmargs=-Dkotlin.daemon.jvm.options=--illegal-access=permit
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 69ac56e..21d7124 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -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
diff --git a/kokain-core-api/build.gradle b/kokain-core-api/build.gradle
index c38bf96..57e4837 100644
--- a/kokain-core-api/build.gradle
+++ b/kokain-core-api/build.gradle
@@ -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()
}
\ No newline at end of file
diff --git a/kokain-core-lib/build.gradle b/kokain-core-lib/build.gradle
index d3b3d7e..3f62c55 100644
--- a/kokain-core-lib/build.gradle
+++ b/kokain-core-lib/build.gradle
@@ -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 {
diff --git a/kokain-core-lib/src/main/java/com/schwarz/kokain/corelib/KokainCore.kt b/kokain-core-lib/src/main/java/com/schwarz/kokain/corelib/KokainCore.kt
index 1f08eb5..e94976a 100644
--- a/kokain-core-lib/src/main/java/com/schwarz/kokain/corelib/KokainCore.kt
+++ b/kokain-core-lib/src/main/java/com/schwarz/kokain/corelib/KokainCore.kt
@@ -14,7 +14,6 @@ abstract class KokainCore(diFactory: KDiFactory, customCurator: CustomCurator? =
private val customCurator = customCurator
fun create(thisRef: Any, clazz: KClass<*>): V {
-
var bean = beanLifecycleCurator.getInstance(clazz) as V?
if (bean == null) {
bean = customCurator?.getInstance(clazz)
diff --git a/kokain-di-jvm/build.gradle b/kokain-di-jvm/build.gradle
index c704f9e..87a8e1c 100644
--- a/kokain-di-jvm/build.gradle
+++ b/kokain-di-jvm/build.gradle
@@ -5,24 +5,22 @@ apply plugin: "org.jlleitschuh.gradle.ktlint"
publishing {
publications {
mavenJava(MavenPublication) {
- groupId = 'com.schwarz.kokain'
- artifactId = 'kokain-di-jvm'
- 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 {
api project(path: ':kokain-core-lib', configuration: 'default')
}
\ No newline at end of file
diff --git a/kokain-di/build.gradle b/kokain-di/build.gradle
index 4cbfd26..09829a1 100644
--- a/kokain-di/build.gradle
+++ b/kokain-di/build.gradle
@@ -1,6 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
-apply plugin: 'kotlin-android-extensions'
apply plugin: "org.jlleitschuh.gradle.ktlint"
apply plugin: 'maven-publish'
@@ -10,18 +9,18 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.1.2'
+ classpath 'com.android.tools.build:gradle:8.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
android {
- compileSdkVersion 31
-
+ namespace 'com.schwarz.kokain'
defaultConfig {
minSdkVersion 21
+ compileSdk 31
targetSdkVersion 31
versionCode 1
versionName "1.0"
@@ -36,16 +35,19 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
- buildToolsVersion = '30.0.2'
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
}
afterEvaluate {
publishing {
publications {
mavenJava(MavenPublication) {
- groupId = 'com.schwarz.kokain'
- artifactId = 'kokain-di'
- version = '0.1'
+ groupId groupName
+ artifactId project.name
+ version project.version
from components.release
}
}
@@ -54,9 +56,9 @@ afterEvaluate {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation "androidx.lifecycle:lifecycle-runtime:2.1.0"
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
+ implementation 'androidx.appcompat:appcompat:1.3.0'
+ implementation "androidx.lifecycle:lifecycle-runtime:2.3.1"
implementation project(path: ':kokain-core-api')
api project(path: ':kokain-core-lib')
testImplementation 'junit:junit:4.12'
diff --git a/kokain-di/src/main/java/com/schwarz/kokain/di/ActivityContextGuard.kt b/kokain-di/src/main/java/com/schwarz/kokain/di/ActivityContextGuard.kt
index 91d67d8..0d181e6 100644
--- a/kokain-di/src/main/java/com/schwarz/kokain/di/ActivityContextGuard.kt
+++ b/kokain-di/src/main/java/com/schwarz/kokain/di/ActivityContextGuard.kt
@@ -88,7 +88,6 @@ class ActivityContextGuard(applicationContext: Application) : LifecycleObserver
}
fun onNewContext(activity: ComponentActivity) {
-
if (activityRefs[activity.toString()]?.isSame(activity) == true) {
return
}
diff --git a/kokain-generator-lib/build.gradle b/kokain-generator-lib/build.gradle
index 0f01c43..abd8e6d 100644
--- a/kokain-generator-lib/build.gradle
+++ b/kokain-generator-lib/build.gradle
@@ -5,15 +5,12 @@ apply plugin: 'pmd'
apply plugin: 'kotlin-kapt'
apply plugin: "org.jlleitschuh.gradle.ktlint"
-targetCompatibility = '1.8'
-sourceCompatibility = '1.8'
-
publishing {
publications {
mavenJava(MavenPublication) {
- groupId = 'com.schwarz.kokain'
- artifactId = 'kokain-generator-lib'
- version = '0.1'
+ groupId project.group
+ artifactId project.name
+ version project.version
from components.java
}
}
@@ -30,24 +27,21 @@ jacocoTestReport {
reports {
- xml.enabled = true
- html.enabled = false
+ xml.required = true
+ html.required = false
}
}
-compileKotlin {
- kotlinOptions {
- jvmTarget = "1.8"
- }
-}
-compileTestKotlin {
- kotlinOptions {
- jvmTarget = "1.8"
- }
+targetCompatibility = JavaVersion.VERSION_17
+sourceCompatibility = JavaVersion.VERSION_17
+
+java {
+ withSourcesJar()
+ withJavadocJar()
}
dependencies {
- implementation 'com.squareup:kotlinpoet:1.12.0'
+ implementation 'com.squareup:kotlinpoet:1.15.3'
api project(path: ':kokain-core-api', configuration: 'default')
implementation 'org.apache.commons:commons-lang3:3.4'
}
\ No newline at end of file
diff --git a/kokain-generator-lib/src/main/java/com/schwarz/kokain/kokaingeneratorlib/generation/FactoryGenerator.kt b/kokain-generator-lib/src/main/java/com/schwarz/kokain/kokaingeneratorlib/generation/FactoryGenerator.kt
index 93df7dd..e98ad22 100644
--- a/kokain-generator-lib/src/main/java/com/schwarz/kokain/kokaingeneratorlib/generation/FactoryGenerator.kt
+++ b/kokain-generator-lib/src/main/java/com/schwarz/kokain/kokaingeneratorlib/generation/FactoryGenerator.kt
@@ -28,7 +28,6 @@ class FactoryGenerator {
}
private fun propAdditionalFactories(factory: IEFactoryModel): PropertySpec {
-
val builder = StringBuilder("arrayOf<%T>")
val types = ArrayList()
val joiner = StringJoiner(",", "(", ")")
@@ -45,7 +44,6 @@ class FactoryGenerator {
}
private fun create(beans: List): FunSpec {
-
var builder = FunSpec.builder("createInstance").addModifiers(KModifier.PUBLIC, KModifier.OVERRIDE).addParameter("clazz", TypeUtil.classStar()).returns(TypeUtil.any().copy(true))
builder = builder.beginControlFlow("when(clazz)")
@@ -69,7 +67,6 @@ class FactoryGenerator {
}
private fun mapScope(scope: EBean.Scope): MemberName {
-
return MemberName(TypeUtil.scope() as ClassName, scope.toString())
}
diff --git a/kokain-ksp/build.gradle b/kokain-ksp/build.gradle
index 09433b4..6a32c5e 100644
--- a/kokain-ksp/build.gradle
+++ b/kokain-ksp/build.gradle
@@ -5,15 +5,15 @@ apply plugin: 'pmd'
apply plugin: 'kotlin-kapt'
apply plugin: "org.jlleitschuh.gradle.ktlint"
-targetCompatibility = '1.8'
-sourceCompatibility = '1.8'
+targetCompatibility = JavaVersion.VERSION_17
+sourceCompatibility = JavaVersion.VERSION_17
publishing {
publications {
mavenJava(MavenPublication) {
- groupId = 'com.schwarz.kokain'
- artifactId = 'kokain-ksp'
- version = '0.1'
+ groupId project.group
+ artifactId project.name
+ version project.version
from components.java
}
}
@@ -30,30 +30,24 @@ jacocoTestReport {
reports {
- xml.enabled = true
- html.enabled = false
+ xml.required = true
+ html.required = false
}
}
-compileKotlin {
- kotlinOptions {
- jvmTarget = "1.8"
- }
-}
-compileTestKotlin {
- kotlinOptions {
- jvmTarget = "1.8"
- }
+java {
+ withSourcesJar()
+ withJavadocJar()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
- implementation 'com.squareup:kotlinpoet:1.12.0'
- implementation("com.squareup:kotlinpoet-ksp:1.12.0")
- implementation("com.google.devtools.ksp:symbol-processing-api:1.6.21-1.0.6")
+ implementation 'com.squareup:kotlinpoet:1.15.3'
+ implementation("com.squareup:kotlinpoet-ksp:1.15.3")
+ implementation("com.google.devtools.ksp:symbol-processing-api:1.9.21-1.0.15")
testImplementation 'junit:junit:4.12'
testImplementation project(path: ':kokain-core-api', configuration: 'default')
- testImplementation 'com.github.tschuchortdev:kotlin-compile-testing-ksp:1.4.9'
+ testImplementation 'dev.zacsweers.kctfork:ksp:0.4.0'
testImplementation 'org.mockito:mockito-core:1.10.19'
implementation project(path: ':kokain-generator-lib', configuration: 'default')
}
\ No newline at end of file
diff --git a/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/factory/EFactoryModelFactory.kt b/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/factory/EFactoryModelFactory.kt
index f67a359..336bcfa 100644
--- a/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/factory/EFactoryModelFactory.kt
+++ b/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/factory/EFactoryModelFactory.kt
@@ -19,7 +19,6 @@ class EFactoryModelFactory(val logger: KSPLogger, resolver: Resolver) {
fun create(element: KSAnnotated): EFactoryModel? {
(element as? KSClassDeclaration)?.let {
if (preValidator.validateFactory(it)) {
-
val factories = extractTypesNamesFromAdditionalFactoriesField(element.getAnnotationsByType(EFactory::class).first())
val simpleName = element.simpleName.asString()
diff --git a/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/generation/KokainCodeGenerator.kt b/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/generation/KokainCodeGenerator.kt
index 338fe57..bc35b8d 100644
--- a/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/generation/KokainCodeGenerator.kt
+++ b/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/generation/KokainCodeGenerator.kt
@@ -11,7 +11,6 @@ class KokainCodeGenerator(private val generator: CodeGenerator) {
@Throws(IOException::class)
fun generate(toGenerate: FileSpec, containingFile: List, aggregating: Boolean = false) {
-
val fileWithHeader = toGenerate.toBuilder().addFileComment(HEADER).build()
generator.createNewFile(
Dependencies(aggregating, *containingFile.toTypedArray()),
diff --git a/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/validation/PreValidator.kt b/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/validation/PreValidator.kt
index aa395ff..f6c0dbc 100644
--- a/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/validation/PreValidator.kt
+++ b/kokain-ksp/src/main/java/com/schwarz/kokain/ksp/validation/PreValidator.kt
@@ -16,7 +16,6 @@ class PreValidator(logger: KSPLogger, val resolver: Resolver) {
@Throws(ClassNotFoundException::class)
fun validateEbean(model: KSClassDeclaration): Boolean {
-
val entityElement = model
var result = true
diff --git a/kokain-ksp/src/test/java/com/schwarz/kokain/ksp/KokainProcessorKotlinTest.kt b/kokain-ksp/src/test/java/com/schwarz/kokain/ksp/KokainProcessorKotlinTest.kt
index 0f53bc0..aa2d16b 100644
--- a/kokain-ksp/src/test/java/com/schwarz/kokain/ksp/KokainProcessorKotlinTest.kt
+++ b/kokain-ksp/src/test/java/com/schwarz/kokain/ksp/KokainProcessorKotlinTest.kt
@@ -1,11 +1,14 @@
package com.schwarz.kokain.ksp
+import com.tschuchort.compiletesting.JvmCompilationResult
import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.SourceFile
import com.tschuchort.compiletesting.symbolProcessorProviders
+import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.junit.Assert
import org.junit.Test
+@OptIn(ExperimentalCompilerApi::class)
class KokainProcessorKotlinTest {
@Test
@@ -24,10 +27,11 @@ class KokainProcessorKotlinTest {
Assert.assertEquals(KotlinCompilation.ExitCode.OK, compilation.exitCode)
}
- private fun compileKotlin(vararg sourceFiles: SourceFile): KotlinCompilation.Result {
+ private fun compileKotlin(vararg sourceFiles: SourceFile): JvmCompilationResult {
return KotlinCompilation().apply {
sources = sourceFiles.toMutableList()
symbolProcessorProviders = listOf(KokainProcessorProvider())
+ jvmTarget = "17"
inheritClassPath = true
messageOutputStream = System.out // see diagnostics in real time
diff --git a/kokain-processor/build.gradle b/kokain-processor/build.gradle
index 66aee5c..805c0e4 100644
--- a/kokain-processor/build.gradle
+++ b/kokain-processor/build.gradle
@@ -7,29 +7,29 @@ apply plugin: "org.jlleitschuh.gradle.ktlint"
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.squareup:kotlinpoet:1.12.0'
- implementation 'com.squareup:kotlinpoet-metadata:1.12.0'
+ implementation 'com.squareup:kotlinpoet:1.15.3'
+ implementation 'com.squareup:kotlinpoet-metadata:1.15.3'
implementation project(path: ':kokain-generator-lib', configuration: 'default')
implementation 'org.apache.commons:commons-lang3:3.4'
testImplementation 'junit:junit:4.12'
testImplementation project(path: ':kokain-core-api', configuration: 'default')
- testImplementation 'com.github.tschuchortdev:kotlin-compile-testing:1.4.9'
+ testImplementation 'dev.zacsweers.kctfork:core:0.4.0'
testImplementation 'org.mockito:mockito-core:1.10.19'
- kapt "com.google.auto.service:auto-service:1.0-rc6"
- implementation "com.google.auto.service:auto-service:1.0-rc6"
+ kapt "com.google.auto.service:auto-service:1.0-rc7"
+ compileOnly "com.google.auto.service:auto-service:1.0-rc7"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
-targetCompatibility = '1.8'
-sourceCompatibility = '1.8'
+targetCompatibility = JavaVersion.VERSION_17
+sourceCompatibility = JavaVersion.VERSION_17
publishing {
publications {
mavenJava(MavenPublication) {
- groupId = 'com.schwarz.kokain'
- artifactId = 'kokain-processor'
- version = '0.1'
+ groupId project.group
+ artifactId project.name
+ version project.version
from components.java
}
}
@@ -46,19 +46,30 @@ jacocoTestReport {
reports {
- xml.enabled = true
- html.enabled = false
+ xml.required = true
+ html.required = false
}
}
-compileKotlin {
- kotlinOptions {
- jvmTarget = "1.8"
- }
+java {
+ withSourcesJar()
+ withJavadocJar()
}
-compileTestKotlin {
- kotlinOptions {
- jvmTarget = "1.8"
+
+if (JavaVersion.current() >= JavaVersion.VERSION_16) {
+ test {
+ jvmArgs(
+ "--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
+ "--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+ )
}
}
diff --git a/kokain-processor/src/main/java/com/schwarz/kokain/processor/KokainProcessor.kt b/kokain-processor/src/main/java/com/schwarz/kokain/processor/KokainProcessor.kt
index 953d9f8..5c7999a 100644
--- a/kokain-processor/src/main/java/com/schwarz/kokain/processor/KokainProcessor.kt
+++ b/kokain-processor/src/main/java/com/schwarz/kokain/processor/KokainProcessor.kt
@@ -48,7 +48,6 @@ class KokainProcessor : AbstractProcessor() {
}
override fun process(set: Set, roundEnv: RoundEnvironment): Boolean {
-
if (set.isEmpty()) {
// no annotation we should take care off
return false
diff --git a/kokain-processor/src/main/java/com/schwarz/kokain/processor/generation/CodeGenerator.kt b/kokain-processor/src/main/java/com/schwarz/kokain/processor/generation/CodeGenerator.kt
index 2e3a6a6..8938105 100644
--- a/kokain-processor/src/main/java/com/schwarz/kokain/processor/generation/CodeGenerator.kt
+++ b/kokain-processor/src/main/java/com/schwarz/kokain/processor/generation/CodeGenerator.kt
@@ -8,7 +8,6 @@ class CodeGenerator(private val filer: Filer) {
@Throws(IOException::class)
fun generate(entityToGenerate: FileSpec) {
-
val fileWithHeader = entityToGenerate.toBuilder().addFileComment(HEADER).build()
fileWithHeader.writeTo(filer)
diff --git a/kokain-processor/src/main/java/com/schwarz/kokain/processor/util/ElementUtil.kt b/kokain-processor/src/main/java/com/schwarz/kokain/processor/util/ElementUtil.kt
index 6437ad6..3595480 100644
--- a/kokain-processor/src/main/java/com/schwarz/kokain/processor/util/ElementUtil.kt
+++ b/kokain-processor/src/main/java/com/schwarz/kokain/processor/util/ElementUtil.kt
@@ -6,10 +6,8 @@ import java.util.Arrays
object ElementUtil {
fun splitGenericIfNeeded(name: String): List {
-
val result = ArrayList()
if (name.contains("<")) {
-
result.add(name.substring(0, name.indexOf("<")).trim { it <= ' ' })
for (item in Arrays.asList(*name.substring(name.indexOf("<") + 1, name.indexOf(">")).split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray())) {
diff --git a/kokain-processor/src/main/java/com/schwarz/kokain/processor/validation/PreValidator.kt b/kokain-processor/src/main/java/com/schwarz/kokain/processor/validation/PreValidator.kt
index b1726a3..173d612 100644
--- a/kokain-processor/src/main/java/com/schwarz/kokain/processor/validation/PreValidator.kt
+++ b/kokain-processor/src/main/java/com/schwarz/kokain/processor/validation/PreValidator.kt
@@ -22,7 +22,6 @@ class PreValidator(logger: Logger, types: Types, elements: Elements) {
@Throws(ClassNotFoundException::class)
fun validate(model: EBeanModel) {
-
val entityElement = model.sourceElement
if (entityElement.modifiers.contains(Modifier.PRIVATE)) {
@@ -36,9 +35,7 @@ class PreValidator(logger: Logger, types: Types, elements: Elements) {
}
for (member in entityElement.enclosedElements) {
-
if (member.kind == ElementKind.CONSTRUCTOR) {
-
val constructor = member as Symbol.MethodSymbol
if (constructor.parameters.size != 0) {
@@ -50,9 +47,7 @@ class PreValidator(logger: Logger, types: Types, elements: Elements) {
@Throws(ClassNotFoundException::class)
fun validateFactory(model: EFactoryModel) {
-
for (factory in model.additionalFactoriesTypeMirror) {
-
if (!types.isSameType(factory, elements.getTypeElement("java.lang.Void").asType()) && !types.isAssignable(factory, elements.getTypeElement("${TypeUtil.KOKAIN_API_BASE_PACKAGE}.KDiFactory").asType())) {
logger.error(EFactory::class.java.simpleName + " additionalFactories have to implement KdiFactory", model.sourceElement)
}
diff --git a/kokain-processor/src/test/java/com/schwarz/kokain/processor/util/KokainProcessorKotlinTest.kt b/kokain-processor/src/test/java/com/schwarz/kokain/processor/util/KokainProcessorKotlinTest.kt
index 3897a93..039ac01 100644
--- a/kokain-processor/src/test/java/com/schwarz/kokain/processor/util/KokainProcessorKotlinTest.kt
+++ b/kokain-processor/src/test/java/com/schwarz/kokain/processor/util/KokainProcessorKotlinTest.kt
@@ -1,16 +1,17 @@
package com.schwarz.kokain.processor.util
import com.schwarz.kokain.processor.KokainProcessor
+import com.tschuchort.compiletesting.JvmCompilationResult
import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.SourceFile
+import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.junit.Assert
import org.junit.Test
-
+@OptIn(ExperimentalCompilerApi::class)
class KokainProcessorKotlinTest {
@Test
fun testKotlinBasicGeneration() {
-
val subEntity = SourceFile.kotlin(
"FooBean.kt",
HEADER +
@@ -27,7 +28,6 @@ class KokainProcessorKotlinTest {
@Test
fun testKotlinInternalBasicGeneration() {
-
val subEntity = SourceFile.kotlin(
"FooBean.kt",
HEADER +
@@ -42,12 +42,13 @@ class KokainProcessorKotlinTest {
Assert.assertEquals(compilation.exitCode, KotlinCompilation.ExitCode.OK)
}
- private fun compileKotlin(vararg sourceFiles: SourceFile): KotlinCompilation.Result {
+ private fun compileKotlin(vararg sourceFiles: SourceFile): JvmCompilationResult {
return KotlinCompilation().apply {
sources = sourceFiles.toMutableList()
// pass your own instance of an annotation processor
annotationProcessors = listOf(KokainProcessor())
+ jvmTarget = "17"
inheritClassPath = true
messageOutputStream = System.out // see diagnostics in real time