diff options
| author | StevenWdV <stevenwdv@gmail.com> | 2022-02-09 00:40:38 +0100 |
|---|---|---|
| committer | StevenWdV <stevenwdv@gmail.com> | 2022-02-09 00:40:38 +0100 |
| commit | 2aad9b6ae61337ef94b05adc377a9ad2cbaa8eb8 (patch) | |
| tree | 022c006cfac7a60fd0ab8896fac3991cf34b8fce /wrappers/java-android/lib/build.gradle | |
| parent | b60ecf2fe5ddfe506e02093286b3931873187e91 (diff) | |
Add Android wrapper, remove plain Java Maven wrapper.
Fix some overrides in Makefiles.
Diffstat (limited to 'wrappers/java-android/lib/build.gradle')
| -rw-r--r-- | wrappers/java-android/lib/build.gradle | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/wrappers/java-android/lib/build.gradle b/wrappers/java-android/lib/build.gradle new file mode 100644 index 0000000..be666aa --- /dev/null +++ b/wrappers/java-android/lib/build.gradle @@ -0,0 +1,107 @@ +import com.android.build.api.dsl.ManagedVirtualDevice + +plugins { + id 'com.android.library' // Build AAR +} + +android { + compileSdk 31 + + defaultConfig { + minSdk 21 + targetSdk 31 + versionCode 1 + versionName '1.0' + + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + + consumerProguardFiles 'consumer-rules.pro' + + externalNativeBuild { + cmake { + // Specify which target we want to build + targets 'shared-lib' + } + } + } + + buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + // Support Java 8+ + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + externalNativeBuild { + cmake { + version '3.18.1' // See cmake_minimum_required in CMakeLists.txt + path 'CMakeLists.txt' + } + } + + sourceSets { + androidTest { + // Use same sources & resources for Android instrumented tests as unit tests + java.srcDirs = sourceSets.test.java.srcDirs + resources.srcDirs = sourceSets.test.resources.srcDirs + } + } + + task copyTestData(type: Copy, description: 'Copy test_data to test resources') { + from('../../../test_data') { + exclude '**/*.py', '**/*.sh' + } + into sourceSets.test.resources.srcDirs[0].toPath().resolve('org/eduvpn/common') + } + + // Copy test_data to Java resources before these are processed + // (.named does not find all tasks. Task names were obtained with com.dorongold.task-tree plugin) + tasks.matching { t -> + t.name in [ + 'processDebugUnitTestJavaRes', 'processReleaseUnitTestJavaRes', + 'processDebugAndroidTestJavaRes', 'processReleaseAndroidTestJavaRes'] + }.all { + dependsOn copyTestData + } + + // Do not cache unit test results as the shared library may have changed + tasks.matching { t -> t.name in ['testDebugUnitTest', 'testReleaseUnitTest'] }.all { + outputs.upToDateWhen { false } + } + + testOptions { + // Display full exceptions and passed tests for unit tests + unitTests.all { + testLogging { + events 'passed', 'skipped', 'failed' + exceptionFormat 'full' + } + } + + devices { + pixel2(ManagedVirtualDevice) { + device = 'Pixel 2' + apiLevel = 30 + systemImageSource = 'aosp' + abi = 'x86_64' + } + } + } +} + +dependencies { + implementation 'net.java.dev.jna:jna:5.10.0@aar' + + testImplementation 'commons-io:commons-io:2.11.0' + testImplementation 'net.java.dev.jna:jna:5.10.0' // Include jnidispatch library in unit tests + testImplementation 'junit:junit:4.+' + + androidTestImplementation 'commons-io:commons-io:2.11.0' + androidTestImplementation 'androidx.test:runner:1.4.0' +} |
