Last active
August 13, 2020 07:58
-
-
Save EricBatlle/1275cfbdb5c750c7c0d08eeed1adf98f to your computer and use it in GitHub Desktop.
Module gradle configuration for deploying faster Android Unity Plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.library' | |
android { | |
compileSdkVersion 26 | |
defaultConfig { | |
minSdkVersion 26 | |
targetSdkVersion 26 | |
versionCode 1 | |
versionName "1.0" | |
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} | |
} | |
dependencies { | |
compileOnly files('./libs/classesEric.jar') // Avoid redundant Unity Player in final application APK | |
implementation 'com.android.support:appcompat-v7:26.1.0' | |
testImplementation 'junit:junit:4.12' | |
androidTestImplementation 'com.android.support.test:runner:1.0.2' | |
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | |
} | |
android.libraryVariants.all { variant -> | |
// Task names. | |
String variantName = "${variant.name.capitalize()}"; // Like 'Debug' | |
String deployTaskGroup = "plugin"; | |
String deployTaskName = "deploy${variantName}PluginArchive"; // Like 'deployDebugPluginArchive' | |
String dependencyTaskName = "assemble${variantName}"; // Like 'assembleDebug' | |
// Source. | |
String sourceAARFolder = "${buildDir.getPath()}/outputs/aar/"; | |
String sourceAARName = "${project.name}-${variant.name}.aar"; | |
// Target. | |
String targetAssetFolder = "Unity_Workspace\\Unity.Blog.Unity_Android_plugin_tutorial-master\\Assets\\Plugins\\Eric\\Android"; | |
String targetAARFolder = "${rootDir.getPath()}/../../${targetAssetFolder}"; // Navigate into 'Assets' | |
String targetAARName = "SpeechRecognizer.aar"; // The form you ship your plugin | |
// Create task. | |
task(deployTaskName, dependsOn: dependencyTaskName, type: Copy) { | |
from(sourceAARFolder) | |
into(targetAARFolder) | |
include(sourceAARName) | |
rename(sourceAARName, targetAARName) | |
}.group = deployTaskGroup; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment