|
| 1 | +plugins { |
| 2 | + id 'com.android.application' |
| 3 | +} |
| 4 | + |
| 5 | +def jsEngine = "V8" |
| 6 | +if (project.hasProperty("jsEngine")) { |
| 7 | + jsEngine = project.property("jsEngine") |
| 8 | +} |
| 9 | + |
| 10 | +configurations { natives } |
| 11 | + |
| 12 | +android { |
| 13 | + namespace 'com.babylonnative.unittests' |
| 14 | + compileSdk 33 |
| 15 | + ndkVersion = "21.4.7075529" |
| 16 | + |
| 17 | + defaultConfig { |
| 18 | + applicationId "com.babylonnative.unittests" |
| 19 | + minSdk 21 |
| 20 | + targetSdk 33 |
| 21 | + versionCode 1 |
| 22 | + versionName "1.0" |
| 23 | + |
| 24 | + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 25 | + |
| 26 | + externalNativeBuild { |
| 27 | + cmake { |
| 28 | + arguments ( |
| 29 | + "-DANDROID_STL=c++_shared", |
| 30 | + "-DNAPI_JAVASCRIPT_ENGINE=${jsEngine}", |
| 31 | + "-DJSRUNTIMEHOST_CORE_APPRUNTIME_V8_INSPECTOR=ON", |
| 32 | + ) |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + if (project.hasProperty("abiFilters")) { |
| 37 | + ndk { |
| 38 | + abiFilters project.getProperty("abiFilters") |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + buildTypes { |
| 44 | + release { |
| 45 | + minifyEnabled false |
| 46 | + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 47 | + } |
| 48 | + } |
| 49 | + compileOptions { |
| 50 | + sourceCompatibility JavaVersion.VERSION_1_8 |
| 51 | + targetCompatibility JavaVersion.VERSION_1_8 |
| 52 | + } |
| 53 | + externalNativeBuild { |
| 54 | + cmake { |
| 55 | + path file('src/main/cpp/CMakeLists.txt') |
| 56 | + buildStagingDirectory '../../../../Build/Android' |
| 57 | + version '3.22.1+' |
| 58 | + } |
| 59 | + } |
| 60 | + buildFeatures { |
| 61 | + viewBinding true |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +dependencies { |
| 66 | + implementation 'com.google.ar:core:1.16.0' |
| 67 | + natives 'com.google.ar:core:1.16.0' |
| 68 | + implementation 'androidx.appcompat:appcompat:1.6.0' |
| 69 | + implementation 'com.google.android.material:material:1.7.0' |
| 70 | + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' |
| 71 | + implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.3' |
| 72 | + testImplementation 'junit:junit:4.13.2' |
| 73 | + androidTestImplementation 'androidx.test.ext:junit:1.1.5' |
| 74 | + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' |
| 75 | +} |
| 76 | + |
| 77 | +task copyScripts { |
| 78 | + doLast { |
| 79 | + // run copy at execution phase because npm command is not done at configuration phase |
| 80 | + copy |
| 81 | + { |
| 82 | + from "../../../node_modules/chai" |
| 83 | + include "chai.js" |
| 84 | + into 'src/main/assets/Scripts' |
| 85 | + } |
| 86 | + copy |
| 87 | + { |
| 88 | + from "../../../node_modules/mocha" |
| 89 | + include "mocha.js" |
| 90 | + into 'src/main/assets/Scripts' |
| 91 | + } |
| 92 | + copy |
| 93 | + { |
| 94 | + from "../../../node_modules/babylonjs" |
| 95 | + include "babylon.max.js" |
| 96 | + into 'src/main/assets/Scripts' |
| 97 | + } |
| 98 | + copy |
| 99 | + { |
| 100 | + from "../../../node_modules/babylonjs-materials" |
| 101 | + include "babylonjs.materials.js" |
| 102 | + into 'src/main/assets/Scripts' |
| 103 | + } |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +// Run copyScripts task after CMake external build |
| 108 | +// And make sure merging assets into output is performed after the scripts copy |
| 109 | +tasks.whenTaskAdded { task -> |
| 110 | + if (task.name == 'mergeDebugNativeLibs') { |
| 111 | + task.finalizedBy(copyScripts) |
| 112 | + } |
| 113 | + if (task.name == 'mergeDebugAssets') { |
| 114 | + task.dependsOn(copyScripts) |
| 115 | + } |
| 116 | +} |
0 commit comments