Skip to content

Commit

Permalink
DSL-JSON v1.10.0
Browse files Browse the repository at this point in the history
Simplified converters which now support primitives without allocation.
Various generics improvement and bugfixes.
Various minor bugfixes and improvements.
  • Loading branch information
zapov committed Jan 6, 2023
1 parent be9f8f1 commit 325bc5c
Show file tree
Hide file tree
Showing 83 changed files with 1,345 additions and 1,154 deletions.
284 changes: 284 additions & 0 deletions DSL.md

Large diffs are not rendered by default.

190 changes: 66 additions & 124 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/AndroidDsl/app/build.gradle
Expand Up @@ -26,6 +26,6 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'

implementation 'com.dslplatform:dsl-json:1.9.9'
annotationProcessor 'com.dslplatform:dsl-json-processor:1.9.9'
implementation 'com.dslplatform:dsl-json:1.10.0'
annotationProcessor 'com.dslplatform:dsl-json-processor:1.10.0'
}
6 changes: 3 additions & 3 deletions examples/AndroidDsl/build.gradle
Expand Up @@ -2,11 +2,11 @@

buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.6.4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,7 +15,7 @@ buildscript {

allprojects {
repositories {
jcenter()
mavenCentral()
google()
mavenLocal()
}
Expand Down
6 changes: 3 additions & 3 deletions examples/AndroidJava/app/build.gradle
Expand Up @@ -39,11 +39,11 @@ dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'

//java8 version can work via desugar
implementation 'com.dslplatform:dsl-json-java8:1.9.9'
implementation 'com.dslplatform:dsl-json-java8:1.10.0'
//using alternative to java8 time api
implementation 'com.dslplatform:dsl-json-threetenbp:1.9.9'
implementation 'com.dslplatform:dsl-json-threetenbp:1.10.0'
//invoke the compile time databinding
annotationProcessor 'com.dslplatform:dsl-json-java8:1.9.9'
annotationProcessor 'com.dslplatform:dsl-json-java8:1.10.0'
//just satisfy Jsonb provided dependency
api 'javax.json.bind:javax.json.bind-api:1.0'
}
Expand Up @@ -189,33 +189,33 @@ public JsonObjectReference deserialize(JsonReader reader) throws IOException {
};
}
public static abstract class FormatDecimal2 {
public static final JsonReader.ReadObject<BigDecimal> JSON_READER = reader -> {
public static BigDecimal read(JsonReader reader) throws IOException {
if (reader.wasNull()) return null;
return NumberConverter.deserializeDecimal(reader).setScale(2);
};
public static final JsonWriter.WriteObject<BigDecimal> JSON_WRITER = (writer, value) -> {
}
public static void write(JsonWriter writer, BigDecimal value) {
if (value == null) {
writer.writeNull();
} else {
NumberConverter.serializeNullable(value.setScale(2), writer);
}
};
}
}
}

@JsonConverter(target = LocalTime.class)
public static abstract class LocalTimeConverter {
public static final JsonReader.ReadObject<LocalTime> JSON_READER = reader -> {
public static LocalTime read(JsonReader reader) throws IOException {
if (reader.wasNull()) return null;
return LocalTime.parse(reader.readSimpleString());
};
public static final JsonWriter.WriteObject<LocalTime> JSON_WRITER = (writer, value) -> {
}
public static void write(JsonWriter writer, LocalTime value) {
if (value == null) {
writer.writeNull();
} else {
writer.writeString(value.toString());
}
};
}
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions examples/AndroidJava/build.gradle
Expand Up @@ -2,11 +2,11 @@

buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.6.4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,7 +15,7 @@ buildscript {

allprojects {
repositories {
jcenter()
mavenCentral()
google()
mavenLocal()
}
Expand Down
24 changes: 15 additions & 9 deletions examples/AndroidKotlin/.gitignore
@@ -1,9 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
2 changes: 1 addition & 1 deletion examples/AndroidKotlin/app/.gitignore
@@ -1 +1 @@
/build
/build
102 changes: 59 additions & 43 deletions examples/AndroidKotlin/app/build.gradle
@@ -1,43 +1,59 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.dslplatform.androidkotlin"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"

javaCompileOptions {
annotationProcessorOptions {
//disable @javax.annotation.Generated("dsl_json")
arguments = ['dsljson.generatedmarker': '']
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.2'

implementation 'com.dslplatform:dsl-json-java8:1.9.9'
kapt 'com.dslplatform:dsl-json-java8:1.9.9'
annotationProcessor 'com.dslplatform:dsl-json-java8:1.9.9'
}
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.kapt'
}

android {
namespace 'com.dslplatform.androidkotlin'
compileSdk 32

defaultConfig {
applicationId "com.dslplatform.androidkotlin"
minSdk 28
targetSdk 32
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}

kapt {
arguments {
//disable @javax.annotation.Generated("dsl_json")
arg("dsljson.generatedmarker", "")
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.1'
implementation 'com.dslplatform:dsl-json-java8:1.10.0'
kapt 'com.dslplatform:dsl-json-java8:1.10.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
58 changes: 29 additions & 29 deletions examples/AndroidKotlin/app/proguard-rules.pro
@@ -1,30 +1,30 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# DSL-JSON
-keep class dsl_json.** { *; }
-keep class com.dslplatform.androidkotlin.** { *; }
-keep class **_DslJsonConverter { *; }
-dontwarn com.dslplatform.json.**
-dontwarn dsl_json.java.sql.**
-keep @com.dslplatform.json.CompiledJson class *
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# DSL-JSON
-keep class dsl_json.** { *; }
-keep class com.dslplatform.androidkotlin.** { *; }
-keep class **_DslJsonConverter { *; }
-dontwarn com.dslplatform.json.**
-dontwarn dsl_json.java.sql.**
-keep @com.dslplatform.json.CompiledJson class *
-keep @com.dslplatform.json.JsonConverter class *
@@ -0,0 +1,24 @@
package com.dslplatform.androidkotlin

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* 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.dslplatform.androidkotlin", appContext.packageName)
}
}
17 changes: 14 additions & 3 deletions examples/AndroidKotlin/app/src/main/AndroidManifest.xml
@@ -1,20 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dslplatform.androidkotlin">
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
android:theme="@style/Theme.AndroidKotlin"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.AndroidKotlin.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>

Expand Down

This file was deleted.

0 comments on commit 325bc5c

Please sign in to comment.