Skip to content

Commit

Permalink
Merge pull request #78 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 7, 2023
2 parents 5e1b555 + 7054d76 commit 0116288
Show file tree
Hide file tree
Showing 58 changed files with 270 additions and 248 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
26 changes: 21 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.

buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.9.21'
ext.groupName = 'com.github.SchwarzIT'
repositories {
google()
mavenCentral()
Expand All @@ -10,17 +11,17 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.2.0"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.android.tools.build:gradle:8.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21"
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

subprojects {
apply plugin: "org.jlleitschuh.gradle.ktlint"
apply plugin: 'maven-publish'

repositories {
mavenCentral()
Expand All @@ -38,9 +39,24 @@ subprojects {
"no-wildcard-imports"
]
}

}

def versionName() {

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

return property("version")
}


allprojects {
version = versionName()
group = groupName

repositories {
google()
mavenCentral()
Expand Down
49 changes: 16 additions & 33 deletions crystal-map-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'kotlin'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
Expand All @@ -8,39 +9,21 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
java {
withSourcesJar()
withJavadocJar()
}

artifacts {
archives sourcesJar
archives javadocJar
}
buildscript {
ext.kotlin_version = '1.7.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
publishing {
publications {
maven(MavenPublication) {
groupId project.group
artifactId project.name
version project.version
from components.java
}
}
}
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ open class DefaultSchemaValidator : SchemaValidator {
}

protected open fun validateModelLevel(current: EntitySchema?, released: EntitySchema, logger: SchemaValidationLogger): Boolean {

current?.let {

released.docId?.let {
if (current.docId?.scheme != it.scheme) {
logger.error(released, "forbidden DocId Schema change")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ object CrystalWrap {
PersistenceConfig.onTypeConversionError(
com.schwarz.crystalapi.TypeConversionErrorWrapper(
ex,
fieldName, value, clazz
fieldName,
value,
clazz
)
)
null
Expand All @@ -117,7 +119,9 @@ object CrystalWrap {
PersistenceConfig.onTypeConversionError(
com.schwarz.crystalapi.TypeConversionErrorWrapper(
ex,
fieldName, value, clazz
fieldName,
value,
clazz
)
)
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package com.schwarz.crystalapi.util

import com.schwarz.crystalapi.mapify.IMapifyable
import org.apache.commons.codec.binary.Base64
import java.io.*
import java.util.*
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.io.Serializable

class SerializableMapifyable<T : Serializable> : IMapifyable<T?> {
override fun fromMap(map: Map<String, Any>): T? = (map.get("serial") as? String)?.let { serializableFromMapValue<T>(it) }
Expand Down
43 changes: 16 additions & 27 deletions crystal-map-couchbase-connector/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 33
namespace "com.schwarz.crystalcouchbaseconnector"

defaultConfig {
minSdkVersion 21
targetSdkVersion 33
compileSdk = 33
versionCode 1
versionName "1.0"

Expand All @@ -22,36 +23,24 @@ android {
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

group = 'com.github.SchwarzIT'

task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}

task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

task classesJar(type: Jar) {
from "$buildDir/intermediates/classes/release"
}

artifacts {
archives classesJar
archives javadocJar
archives sourcesJar
afterEvaluate {
publishing {
publications {
maven(MavenPublication) {
groupId groupName
artifactId project.name
version project.version
from components.release
}
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ abstract class Couchbase2Connector : PersistenceConfig.Connector {
onlyInclude: List<String>?
): List<Map<String, Any>> {
try {

val builder = QueryBuilder.select(SelectResult.expression(Meta.id), SelectResult.all())
.from(DataSource.database(getDatabase(dbName)))

Expand Down Expand Up @@ -131,11 +130,9 @@ abstract class Couchbase2Connector : PersistenceConfig.Connector {
}

private fun parseExpressions(queryParams: Map<String, Any?>): Expression? {

var result: Expression? = null

for (queryParam in queryParams) {

val equalTo = Expression.property(queryParam.key).equalTo(
Expression.value(queryParam.value)
)
Expand Down
70 changes: 41 additions & 29 deletions crystal-map-processor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
apply plugin: 'kotlin'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'pmd'
apply plugin: 'kotlin-kapt'
apply plugin: 'java'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
Expand All @@ -12,9 +13,9 @@ dependencies {
implementation 'org.apache.commons:commons-lang3:3.4'
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.13.3"
implementation 'com.j2html:j2html:1.4.0'
testImplementation 'com.google.testing.compile:compile-testing:0.19'
testImplementation 'com.google.testing.compile:compile-testing:0.21.0'
testImplementation 'junit:junit:4.12'
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'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
Expand All @@ -23,17 +24,40 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

targetCompatibility = '1.8'
sourceCompatibility = '1.8'
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
java {
withSourcesJar()
withJavadocJar()
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
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",
)
}
}

publishing {
publications {
maven(MavenPublication) {
groupId project.group
artifactId project.name
version project.version
from components.java
}
}
}

jacoco {
Expand All @@ -46,24 +70,12 @@ jacocoTestReport {

reports {

xml.enabled = true
html.enabled = false
}
}

artifacts {
archives sourcesJar
archives javadocJar
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
xml{
enabled true
}
html{
enabled false
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import javax.annotation.processing.*
import javax.lang.model.SourceVersion
import javax.lang.model.element.TypeElement

@SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedSourceVersion(SourceVersion.RELEASE_17)
@AutoService(Processor::class)
@SupportedOptions(KAPT_KOTLIN_GENERATED_OPTION_NAME, FRAMEWORK_USE_SUSPEND_OPTION_NAME, FRAMEWORK_DOCUMENTATION_PATH_OPTION_NAME, FRAMEWORK_DOCUMENTATION_FILENAME_OPTION_NAME, FRAMEWORK_SCHEMA_PATH_OPTION_NAME, FRAMEWORK_SCHEMA_FILENAME_OPTION_NAME)
class CoachBaseBinderProcessor : AbstractProcessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ fun TypeName.javaToKotlinType(): TypeName = if (this is ParameterizedTypeName) {
} else {
val className = JavaToKotlinClassMap.INSTANCE
.mapJavaToKotlin(FqName(toString()))?.asSingleFqName()?.asString()
if (className == null) this
else ClassName.bestGuess(className)
if (className == null) {
this
} else {
ClassName.bestGuess(className)
}
}
Loading

0 comments on commit 0116288

Please sign in to comment.