You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
269 lines
10 KiB
269 lines
10 KiB
apply plugin: 'com.android.library'
|
|
apply plugin: 'com.github.dcendents.android-maven'
|
|
apply plugin: 'com.jfrog.bintray'
|
|
|
|
// Required by bintray
|
|
version = '2.4.0'
|
|
group = 'com.otaliastudios'
|
|
|
|
//region android dependencies
|
|
|
|
android {
|
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
|
|
|
defaultConfig {
|
|
minSdkVersion rootProject.ext.minSdkVersion
|
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
versionCode 1
|
|
versionName project.version
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
testInstrumentationRunnerArgument "filter", "com.otaliastudios.cameraview.tools.SdkExcludeFilter"
|
|
}
|
|
|
|
buildTypes {
|
|
debug {
|
|
testCoverageEnabled true
|
|
}
|
|
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
testImplementation 'junit:junit:4.12'
|
|
testImplementation 'org.mockito:mockito-inline:2.28.2'
|
|
|
|
androidTestImplementation 'androidx.test:runner:1.2.0'
|
|
androidTestImplementation 'androidx.test:rules:1.2.0'
|
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
|
androidTestImplementation 'org.mockito:mockito-android:2.28.2'
|
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
|
|
|
api 'androidx.exifinterface:exifinterface:1.1.0'
|
|
api 'androidx.lifecycle:lifecycle-common:2.1.0'
|
|
api 'com.google.android.gms:play-services-tasks:17.0.0'
|
|
implementation 'androidx.annotation:annotation:1.1.0'
|
|
}
|
|
|
|
//endregion
|
|
|
|
//region bintray
|
|
|
|
// install is a task defined by the Gradle Maven plugin, which is used to
|
|
// publish a maven repo to a local repository. (we actually use the android version of the plugin,
|
|
// com.github.dcendents.android-maven, to support AARs)
|
|
// https://docs.gradle.org/current/userguide/maven_plugin.html#sec:maven_tasks
|
|
install {
|
|
// The repositories property is common to all tasks of type Upload and returns the repositories
|
|
// into which we will upload data. https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Upload.html#org.gradle.api.tasks.Upload:repositories
|
|
// It returns a RepositoryHandler: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.RepositoryHandler.html
|
|
repositories {
|
|
// The maven plugin adds a mavenInstaller property to the RepositoryHandler which can be used to
|
|
// add and configure a local maven repository cache.
|
|
// https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.RepositoryHandler.html#N11785
|
|
mavenInstaller {
|
|
// The object here extends PomFilterContainer so we can configure the pom file here.
|
|
// https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/maven/PomFilterContainer.html#pom-groovy.lang.Closure-
|
|
pom {
|
|
// Now we are inside a MavenPom object that can be configured. We get the project and configure.
|
|
// https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/maven/MavenPom.html
|
|
project {
|
|
name 'CameraView'
|
|
description 'A well documented, high-level Android interface that makes capturing pictures ' +
|
|
'and videos easy, addressing most of the common issues and needs.'
|
|
url 'https://github.com/natario1/CameraView'
|
|
packaging 'aar'
|
|
groupId project.group
|
|
artifactId 'cameraview'
|
|
version project.version
|
|
licenses {
|
|
license {
|
|
name 'The Apache Software License, Version 2.0'
|
|
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
}
|
|
}
|
|
scm {
|
|
connection 'https://github.com/natario1/CameraView.git'
|
|
developerConnection 'https://github.com/natario1/CameraView.git'
|
|
url 'https://github.com/natario1/CameraView'
|
|
|
|
}
|
|
developers {
|
|
developer {
|
|
id = 'natario'
|
|
name 'Mattia Iavarone'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def bintrayUser
|
|
def bintrayKey
|
|
def isCI = System.getenv("TRAVIS")
|
|
if (isCI) {
|
|
bintrayUser = System.getenv("BINTRAY_USER")
|
|
bintrayKey = System.getenv("BINTRAY_KEY")
|
|
} else {
|
|
Properties props = new Properties()
|
|
props.load(project.rootProject.file('local.properties').newDataInputStream())
|
|
bintrayUser = props.getProperty('bintray.user')
|
|
bintrayKey = props.get('bintray.key')
|
|
}
|
|
|
|
bintray {
|
|
// https://github.com/bintray/gradle-bintray-plugin
|
|
user = bintrayUser
|
|
key = bintrayKey
|
|
configurations = ['archives']
|
|
pkg {
|
|
repo = 'android'
|
|
name = 'CameraView'
|
|
licenses = ['Apache-2.0']
|
|
vcsUrl = 'https://github.com/natario1/CameraView.git'
|
|
publish = true
|
|
override = true
|
|
version {
|
|
name = project.version
|
|
desc = 'CameraView v. '+project.version
|
|
released = new Date()
|
|
vcsTag = 'v'+project.version
|
|
}
|
|
}
|
|
}
|
|
|
|
//endregion
|
|
|
|
//region javadoc and sources
|
|
|
|
// From official sample https://github.com/bintray/bintray-examples/blob/master/gradle-aar-example/build.gradle
|
|
task sourcesJar(type: Jar) {
|
|
classifier = 'sources'
|
|
from android.sourceSets.main.java.sourceFiles
|
|
}
|
|
|
|
task javadoc(type: Javadoc) {
|
|
source = android.sourceSets.main.java.srcDirs
|
|
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
|
|
classpath += project.files("${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
|
|
project.android.libraryVariants.all { variant ->
|
|
if (variant.name == 'release') {
|
|
classpath += files(variant.javaCompile.classpath)
|
|
}
|
|
}
|
|
exclude '**/BuildConfig.java'
|
|
exclude '**/R.java'
|
|
// This excludes our internal folder, which is nice, but also creates
|
|
// errors anytime we reference excluded classes in public classes javadocs,
|
|
// which is unfortunate. There might be a fix but I don't know any.
|
|
// exclude '**/internal/**'
|
|
}
|
|
|
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
classifier = 'javadoc'
|
|
from javadoc.destinationDir
|
|
}
|
|
|
|
artifacts {
|
|
archives javadocJar
|
|
archives sourcesJar
|
|
}
|
|
|
|
//endregion
|
|
|
|
//region code coverage
|
|
|
|
// 1. running androidTests with connectedCheck will generate an .ec file
|
|
// in build/outputs/code-coverage/connected, plus the XML result in
|
|
// in build/reports/coverage/debug/report.xml .
|
|
|
|
// 2. running unit tests with testDebugUnitTest will just generate the .exec file.
|
|
// The JacocoReport task from the jacoco plugin can create the XML report out of it.
|
|
|
|
// to have a unified report, we just pass both the .exec and the .ec file
|
|
// to the jacoco task, so we get a unified XML report with total coverage.
|
|
// Reference: https://medium.com/@rafael_toledo/setting-up-an-unified-coverage-report-in-android-with-jacoco-robolectric-and-espresso-ffe239aaf3fa
|
|
|
|
apply plugin: 'jacoco'
|
|
|
|
def reportsDirectory = "$buildDir/reports/"
|
|
jacoco {
|
|
toolVersion = "0.8.1"
|
|
reportsDir = file(reportsDirectory)
|
|
}
|
|
|
|
task createCoverageReports() {
|
|
dependsOn "testDebugUnitTest"
|
|
dependsOn "connectedCheck"
|
|
}
|
|
|
|
task mergeCoverageReports(type: JacocoReport) {
|
|
// Let this be called without running the tests.
|
|
// dependsOn "createCoverageReports"
|
|
// However, ensure we have the compiled .class files.
|
|
dependsOn "compileDebugSources"
|
|
|
|
// Merge unit tests and android tests data
|
|
executionData = fileTree(dir: "$buildDir", includes: [
|
|
"jacoco/testDebugUnitTest.exec", // Unit tests
|
|
"outputs/code_coverage/debugAndroidTest/connected/*coverage.ec" // Android tests
|
|
])
|
|
|
|
// Sources
|
|
sourceDirectories = files(android.sourceSets.main.java.sourceFiles)
|
|
additionalSourceDirs = files([ // Add BuildConfig and R.
|
|
"$buildDir/generated/source/buildConfig/debug",
|
|
"$buildDir/generated/source/r/debug"
|
|
])
|
|
|
|
// Classes (.class files)
|
|
// Not everything in the filter relates to CameraView,
|
|
// but let's keep a generic filter
|
|
def classDir = "$buildDir/intermediates/javac/debug"
|
|
def classFilter = [
|
|
'**/R.class',
|
|
'**/R$*.class',
|
|
'**/BuildConfig.*',
|
|
'**/Manifest*.*',
|
|
'android/**',
|
|
'androidx/**',
|
|
'com/google/**',
|
|
'**/*$ViewInjector*.*',
|
|
'**/Dagger*Component.class',
|
|
'**/Dagger*Component$Builder.class',
|
|
'**/*Module_*Factory.class',
|
|
]
|
|
if (isCI) {
|
|
// All these classes are tested by the integration tests that we are not able to
|
|
// run on the CI emulator.
|
|
classFilter.add('**/com/otaliastudios/cameraview/engine/CameraEngine**.*')
|
|
classFilter.add('**/com/otaliastudios/cameraview/engine/Camera1Engine**.*')
|
|
classFilter.add('**/com/otaliastudios/cameraview/engine/Camera2Engine**.*')
|
|
classFilter.add('**/com/otaliastudios/cameraview/engine/action/**.*')
|
|
classFilter.add('**/com/otaliastudios/cameraview/engine/lock/**.*')
|
|
classFilter.add('**/com/otaliastudios/cameraview/engine/meter/**.*')
|
|
classFilter.add('**/com/otaliastudios/cameraview/picture/**.*')
|
|
classFilter.add('**/com/otaliastudios/cameraview/video/**.*')
|
|
// TODO these below could be easily testable ALSO outside of the integration tests
|
|
classFilter.add('**/com/otaliastudios/cameraview/orchestrator/**.*')
|
|
classFilter.add('**/com/otaliastudios/cameraview/video/encoding/**.*')
|
|
}
|
|
// We don't test OpenGL filters.
|
|
classFilter.add('**/com/otaliastudios/cameraview/filters/**.*')
|
|
|
|
classDirectories = fileTree(dir: classDir, excludes: classFilter);
|
|
|
|
reports.html.enabled = true
|
|
reports.xml.enabled = true
|
|
reports.xml.destination file("$reportsDirectory/mergedCoverageReport/report.xml")
|
|
}
|
|
|
|
//endregion
|
|
|
|
// To deploy ./gradlew bintrayUpload
|
|
|
|
|