build.gradle 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. apply plugin: 'com.android.library'
  2. android {
  3. compileSdkVersion 28
  4. buildToolsVersion '28.0.3'
  5. defaultConfig {
  6. minSdkVersion 19
  7. targetSdkVersion 28
  8. versionCode 1
  9. versionName "1.0"
  10. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  11. externalNativeBuild {
  12. cmake {
  13. arguments '-DANDROID_TOOLCHAIN=clang'
  14. }
  15. }
  16. }
  17. buildTypes {
  18. release {
  19. minifyEnabled false
  20. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  21. }
  22. }
  23. externalNativeBuild {
  24. cmake {
  25. path "src/main/cpp/CMakeLists.txt"
  26. }
  27. }
  28. }
  29. dependencies {
  30. implementation fileTree(dir: 'libs', include: ['*.jar'])
  31. implementation 'com.android.support:appcompat-v7:28.0.0'
  32. testImplementation 'junit:junit:4.13'
  33. androidTestImplementation 'com.android.support.test:runner:1.0.2'
  34. androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  35. androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
  36. exclude group: 'com.android.support', module: 'support-annotations'
  37. })
  38. }
  39. // 生成 jar 包并修改名字
  40. task makeJar(type: Copy) {
  41. // 删除已经存在的 jar 包,如果有的话
  42. delete 'build/libs/SerialPort.jar'
  43. // 从该目录下加载要打包的文件,注意文件夹名称有可能为 default,也可能是 release
  44. from('build/intermediates/bundles/release/')
  45. // jar 包的保存目录
  46. into('build/libs/')
  47. // 设置过滤,只打包classes文件
  48. include('classes.jar')
  49. // 重命名 jar 包
  50. rename('classes.jar', 'SerialPort.jar')
  51. }
  52. makeJar.dependsOn(build)