| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you 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. |
| */ |
| |
| buildscript { |
| repositories { |
| google() |
| mavenCentral() |
| gradlePluginPortal() |
| } |
| configurations.classpath { |
| resolutionStrategy { |
| eachDependency { details -> |
| if (details.requested.group == 'io.netty') { |
| details.useVersion '4.1.133.Final' |
| } |
| if (details.requested.group == 'org.bouncycastle') { |
| details.useVersion '1.84' |
| } |
| } |
| force 'org.apache.commons:commons-compress:1.26.0' |
| force 'org.bitbucket.b_c:jose4j:0.9.6' |
| force 'org.jdom:jdom2:2.0.6.1' |
| } |
| } |
| dependencies { |
| classpath 'com.android.tools.build:gradle:8.13.2' |
| classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.20' |
| classpath 'com.google.devtools.ksp:symbol-processing-gradle-plugin:2.3.8' |
| } |
| } |
| |
| apply plugin: 'com.android.application' |
| apply plugin: 'org.jetbrains.kotlin.android' |
| apply plugin: 'com.google.devtools.ksp' |
| |
| def foryTestBuildType = providers.gradleProperty('foryTestBuildType').getOrElse('release') |
| |
| android { |
| namespace 'org.apache.fory.android.tests' |
| compileSdk 35 |
| |
| defaultConfig { |
| applicationId 'org.apache.fory.android.tests' |
| minSdk 26 |
| targetSdk 35 |
| versionCode 1 |
| versionName '1.0' |
| testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' |
| } |
| |
| compileOptions { |
| sourceCompatibility JavaVersion.VERSION_17 |
| targetCompatibility JavaVersion.VERSION_17 |
| } |
| |
| testBuildType foryTestBuildType |
| |
| buildTypes { |
| release { |
| minifyEnabled true |
| signingConfig signingConfigs.debug |
| proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| } |
| } |
| |
| packaging { |
| resources { |
| excludes += [ |
| 'META-INF/DEPENDENCIES', |
| 'META-INF/LICENSE', |
| 'META-INF/LICENSE.txt', |
| 'META-INF/NOTICE', |
| 'META-INF/NOTICE.txt' |
| ] |
| } |
| } |
| } |
| |
| kotlin { |
| compilerOptions { |
| jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) |
| } |
| } |
| |
| dependencies { |
| implementation('org.apache.fory:fory-core:1.8.0-SNAPSHOT') { |
| exclude group: 'com.google.guava', module: 'guava' |
| exclude group: 'org.codehaus.janino', module: 'janino' |
| } |
| implementation 'org.apache.fory:fory-json:1.8.0-SNAPSHOT' |
| implementation 'org.apache.fory:fory-json-kotlin:1.8.0-SNAPSHOT' |
| implementation 'org.apache.fory:kotlin-json-corpus:1.8.0-SNAPSHOT' |
| ksp 'org.apache.fory:fory-json-kotlin-ksp:1.8.0-SNAPSHOT' |
| annotationProcessor 'org.apache.fory:fory-annotation-processor:1.8.0-SNAPSHOT' |
| implementation 'com.google.guava:guava:32.1.2-android' |
| implementation 'org.slf4j:slf4j-api:2.0.12' |
| |
| androidTestImplementation 'androidx.test.ext:junit:1.2.1' |
| androidTestImplementation 'androidx.test:runner:1.6.2' |
| } |
| |
| def kotlinJsonRules = [ |
| 'fory-json-org.apache.fory.android.AndroidKotlinAccount.pro': |
| 'org.apache.fory.android.AndroidKotlinAccount', |
| 'fory-json-org.apache.fory.android.AndroidKotlinDefaults.pro': |
| 'org.apache.fory.android.AndroidKotlinDefaults', |
| 'fory-json-org.apache.fory.android.AndroidKotlinMarker.pro': |
| 'org.apache.fory.android.AndroidKotlinMarker', |
| ] |
| |
| tasks.register('verifyKotlinJsonRules') { |
| dependsOn 'kspDebugKotlin', 'kspReleaseKotlin' |
| doLast { |
| ['debug', 'release'].each { variant -> |
| def ruleDir = layout.buildDirectory |
| .dir("generated/ksp/${variant}/resources/META-INF/proguard") |
| .get().asFile |
| def expected = kotlinJsonRules |
| def actual = fileTree(ruleDir).matching { include 'fory-json-*.pro' }.files |
| .collectEntries { rule -> [(rule.name): rule] } |
| if (actual.keySet() != expected.keySet()) { |
| throw new GradleException( |
| "Unexpected Kotlin JSON rules for ${variant}: " + |
| (actual.keySet() - expected.keySet()) + |
| "; missing: " + (expected.keySet() - actual.keySet())) |
| } |
| expected.each { name, model -> |
| def exactKeep = "-keep,allowoptimization class ${model}".toString() |
| if (!actual[name].readLines('UTF-8').contains(exactKeep)) { |
| throw new GradleException("${actual[name]} does not retain exact model ${model}") |
| } |
| } |
| def request = layout.buildDirectory.file( |
| "generated/ksp/${variant}/java/org/apache/fory/android/" + |
| "AndroidKotlinJsonScenarios_d_KspJavaShapeMixin_" + |
| "ForyJsonSubtypeGeneration.java").get().asFile |
| if (!request.isFile() || !request.text.contains( |
| 'GeneratedJsonSubtypeTable.Generation')) { |
| throw new GradleException("Missing generated Java subtype request ${request}") |
| } |
| } |
| } |
| } |