buildscript { repositories { jcenter() google() } dependencies { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' } } plugins { id 'com.github.sherter.google-java-format' version '0.6' id 'com.github.dcendents.android-maven' version '2.0' } apply plugin: 'com.android.library' apply plugin: 'com.jfrog.bintray' android { compileSdkVersion 26 defaultConfig { minSdkVersion 15 targetSdkVersion 22 // testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" versionCode VERSION_CODE.toInteger() versionName VERSION_NAME // Need to set up some project properties to publish to bintray. project.group = GROUP_ID project.archivesBaseName = ARTIFACT_ID project.version = VERSION_NAME } splits { abi { enable true reset() // Specifies a list of ABIs that Gradle should create APKs for. include "arm64-v8a", "armeabi-v7a", "armeabi" universalApk true } } lintOptions { abortOnError false checkAllWarnings true warningsAsErrors true disable 'HardwareIds','MissingApplicationIcon','GoogleAppIndexingWarning','InvalidPackage','OldTargetApi' } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { // implementation fileTree(include: ['*.jar'], dir: 'libs') // implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'junit:junit:4.12' implementation 'com.android.support.test:runner:1.0.1' } googleJavaFormat { options style: 'AOSP' } task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files( android.getBootClasspath().join(File.pathSeparator)) } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives javadocJar archives sourcesJar } // bintray packaging information install { repositories.mavenInstaller { pom.project { name ARTIFACT_ID description 'Android library for triggering device-side code from ' + 'host-side Mobly tests.' url 'https://github.com/google/mobly-snippet-lib' packaging 'aar' groupId GROUP_ID artifactId ARTIFACT_ID version VERSION_NAME name ARTIFACT_ID licenses { license { name 'The Apache Software License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' distribution 'repo' } } scm { connection 'https://github.com/google/mobly-snippet-lib.git' url 'https://github.com/google/mobly-snippet-lib' } } } } // Try loading bintray.properties. It's okay if this fails; we might not be // uploading. def bintrayPropFile = project.rootProject.file('bintray.properties') if (bintrayPropFile.exists()) { Properties prop = new Properties() prop.load(new FileInputStream(bintrayPropFile)) project.ext.bintrayUser = prop.user project.ext.bintrayKey = prop.key } else { project.ext.bintrayUser = null project.ext.bintrayKey = null } gradle.taskGraph.whenReady { graph -> if (graph.hasTask(bintrayUpload)) { if (project.bintrayUser == null || project.bintrayKey == null) { if (bintrayPropFile.exists()) { throw new IllegalArgumentException( bintrayPropFile.toString() + ' does not contain "user" or "key" props') } else { throw new FileNotFoundException( 'bintray.properties not found at path: ' + bintrayPropFile) } } } } bintray { user = project.bintrayUser key = project.bintrayKey configurations = ['archives'] pkg { repo = 'mobly' name = ARTIFACT_ID userOrg = 'google' licenses = ['Apache-2.0'] vcsUrl = 'https://github.com/google/mobly-snippet-lib.git' version { name = VERSION_NAME desc = 'Mobly Snippet Lib ' + VERSION_NAME released = new Date() vcsTag = VERSION_NAME } } } // Open lint's HTML report in your default browser or viewer. task openLintReport(type: Exec) { def lint_report = "build/reports/lint-results.html" def cmd = "cat" def platform = System.getProperty('os.name').toLowerCase(Locale.ROOT) if (platform.contains("linux")) { cmd = "xdg-open" } else if (platform.contains("mac os x")) { cmd = "open" } else if (platform.contains("windows")) { cmd = "launch" } commandLine cmd, lint_report } task presubmit { dependsOn { ['googleJavaFormat', 'lint', 'openLintReport'] } doLast { println "Fix any lint issues you see. When it looks good, submit the pull request." } }