build.gradle.kts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import com.otaliastudios.tools.publisher.common.License
  2. import com.otaliastudios.tools.publisher.common.Release
  3. plugins {
  4. id("com.android.library")
  5. id("kotlin-android")
  6. id("com.otaliastudios.tools.publisher")
  7. id("jacoco")
  8. }
  9. android {
  10. setCompileSdkVersion(29)
  11. defaultConfig {
  12. setMinSdkVersion(21)
  13. setTargetSdkVersion(29)
  14. versionCode = 1
  15. versionName = "2.6.4"
  16. testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
  17. testInstrumentationRunnerArgument("filter", "" +
  18. "com.otaliastudios.cameraview.tools.SdkExcludeFilter," +
  19. "com.otaliastudios.cameraview.tools.SdkIncludeFilter")
  20. }
  21. buildTypes["debug"].isTestCoverageEnabled = true
  22. buildTypes["release"].isMinifyEnabled = false
  23. }
  24. dependencies {
  25. testImplementation("junit:junit:4.13")
  26. testImplementation("org.mockito:mockito-inline:2.28.2")
  27. androidTestImplementation("androidx.test:runner:1.3.0")
  28. androidTestImplementation("androidx.test:rules:1.3.0")
  29. androidTestImplementation("androidx.test.ext:junit:1.1.1")
  30. androidTestImplementation("org.mockito:mockito-android:2.28.2")
  31. androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0")
  32. api("androidx.exifinterface:exifinterface:1.2.0")
  33. api("androidx.lifecycle:lifecycle-common:2.2.0")
  34. api("com.google.android.gms:play-services-tasks:17.2.0")
  35. implementation("androidx.annotation:annotation:1.1.0")
  36. implementation("com.otaliastudios.opengl:egloo:0.5.3")
  37. }
  38. // Publishing
  39. publisher {
  40. project.description = "A well documented, high-level Android interface that makes capturing " +
  41. "pictures and videos easy, addressing all of the common issues and needs. " +
  42. "Real-time filters, gestures, watermarks, frame processing, RAW, output of any size."
  43. project.artifact = "cameraview"
  44. project.group = "com.otaliastudios"
  45. project.url = "https://github.com/natario1/CameraView"
  46. project.addLicense(License.APACHE_2_0)
  47. release.setSources(Release.SOURCES_AUTO)
  48. release.setDocs(Release.DOCS_AUTO)
  49. bintray {
  50. auth.user = "BINTRAY_USER"
  51. auth.key = "BINTRAY_KEY"
  52. auth.repo = "BINTRAY_REPO"
  53. }
  54. directory {
  55. directory = "build/local"
  56. }
  57. }
  58. // Code Coverage
  59. val buildDir = project.buildDir.absolutePath
  60. val coverageInputDir = "$buildDir/coverage_input" // changing? change github workflow
  61. val coverageOutputDir = "$buildDir/coverage_output" // changing? change github workflow
  62. // Run unit tests, with coverage enabled in the android { } configuration.
  63. // Output will be an .exec file in build/jacoco.
  64. tasks.register("runUnitTests") { // changing name? change github workflow
  65. dependsOn("testDebugUnitTest")
  66. doLast {
  67. copy {
  68. from("$buildDir/jacoco/testDebugUnitTest.exec")
  69. into("$coverageInputDir/unit_tests") // changing? change github workflow
  70. }
  71. }
  72. }
  73. // Run android tests with coverage.
  74. tasks.register("runAndroidTests") { // changing name? change github workflow
  75. dependsOn("connectedDebugAndroidTest")
  76. doLast {
  77. copy {
  78. from("$buildDir/outputs/code_coverage/debugAndroidTest/connected")
  79. include("*coverage.ec")
  80. into("$coverageInputDir/android_tests") // changing? change github workflow
  81. }
  82. }
  83. }
  84. // Merge the two with a jacoco task.
  85. jacoco { toolVersion = "0.8.5" }
  86. tasks.register("computeCoverage", JacocoReport::class) {
  87. dependsOn("compileDebugSources") // Compile sources, needed below
  88. executionData.from(fileTree(coverageInputDir))
  89. sourceDirectories.from(android.sourceSets["main"].java.sourceFiles)
  90. additionalSourceDirs.from("$buildDir/generated/source/buildConfig/debug")
  91. additionalSourceDirs.from("$buildDir/generated/source/r/debug")
  92. classDirectories.from(fileTree("$buildDir/intermediates/javac/debug") {
  93. // Not everything here is relevant for CameraView, but let's keep it generic
  94. exclude(
  95. "**/R.class",
  96. "**/R$*.class",
  97. "**/BuildConfig.*",
  98. "**/Manifest*.*",
  99. "android/**",
  100. "androidx/**",
  101. "com/google/**",
  102. "**/*\$ViewInjector*.*",
  103. "**/Dagger*Component.class",
  104. "**/Dagger*Component\$Builder.class",
  105. "**/*Module_*Factory.class",
  106. // We don"t test OpenGL filters.
  107. "**/com/otaliastudios/cameraview/filters/**.*"
  108. )
  109. })
  110. reports.html.isEnabled = true
  111. reports.xml.isEnabled = true
  112. reports.html.destination = file("$coverageOutputDir/html")
  113. reports.xml.destination = file("$coverageOutputDir/xml/report.xml")
  114. }