1buildscript { 2 repositories { 3 mavenCentral() 4 google() 5 } 6} 7 8plugins { 9 id 'com.github.sherter.google-java-format' version '0.9' 10 id 'maven-publish' 11 id 'signing' 12} 13 14apply plugin: 'com.android.library' 15 16android { 17 compileSdkVersion 31 18 19 defaultConfig { 20 minSdkVersion 26 21 targetSdkVersion 31 22 versionCode VERSION_CODE.toInteger() 23 versionName VERSION_NAME 24 25 // Need to set up some project properties to publish to bintray. 26 project.group = GROUP_ID 27 project.archivesBaseName = ARTIFACT_ID 28 project.version = VERSION_NAME 29 } 30 31 splits { 32 abi { 33 enable true 34 reset() 35 // Specifies a list of ABIs that Gradle should create APKs for. 36 include "arm64-v8a", "armeabi-v7a", "armeabi" 37 universalApk true 38 } 39 } 40 41 lintOptions { 42 abortOnError false 43 checkAllWarnings true 44 warningsAsErrors true 45 disable 'HardwareIds','MissingApplicationIcon','GoogleAppIndexingWarning','InvalidPackage','OldTargetApi' 46 } 47 48 compileOptions { 49 sourceCompatibility JavaVersion.VERSION_1_8 50 targetCompatibility JavaVersion.VERSION_1_8 51 } 52} 53 54dependencies { 55 implementation 'junit:junit:4.13.2' 56 implementation 'androidx.test:runner:1.4.0' 57} 58 59googleJavaFormat { 60 options style: 'AOSP' 61} 62 63task sourcesJar(type: Jar) { 64 from android.sourceSets.main.java.srcDirs 65 classifier = 'sources' 66} 67 68task javadoc(type: Javadoc) { 69 source = android.sourceSets.main.java.srcDirs 70 classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 71 options.addStringOption('Xdoclint:none', '-quiet') 72 options.addStringOption('encoding', 'UTF-8') 73 options.addStringOption('charSet', 'UTF-8') 74 failOnError false 75} 76 77task javadocJar(type: Jar, dependsOn: javadoc) { 78 classifier = 'javadoc' 79 from javadoc.destinationDir 80} 81 82artifacts { 83 archives javadocJar 84 archives sourcesJar 85} 86 87 88afterEvaluate { 89 publishing { 90 publications { 91 release(MavenPublication) { 92 groupId GROUP_ID 93 artifactId ARTIFACT_ID 94 version VERSION_NAME 95 from components.release 96 97 artifact sourcesJar 98 artifact javadocJar 99 100 pom { 101 name = ARTIFACT_ID 102 description = 'Android library for triggering device-side ' + 103 'code from host-side Mobly tests.' 104 url = 'https://github.com/google/mobly-snippet-lib' 105 licenses { 106 license { 107 name = 'The Apache Software License, Version 2.0' 108 url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 109 distribution = 'repo' 110 } 111 } 112 developers { 113 developer { 114 name = 'The Mobly Team' 115 } 116 } 117 scm { 118 connection = 'https://github.com/google/mobly-snippet-lib.git' 119 url = 'https://github.com/google/mobly-snippet-lib' 120 } 121 } 122 } 123 } 124 125 repositories { 126 maven { 127 def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' 128 def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' 129 url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl 130 credentials { 131 username ossrhUsername 132 password ossrhPassword 133 } 134 } 135 } 136 } 137 signing { 138 sign publishing.publications.release 139 } 140} 141 142// Open lint's HTML report in your default browser or viewer. 143task openLintReport(type: Exec) { 144 def lint_report = "build/reports/lint-results-debug.html" 145 def cmd = "cat" 146 def platform = System.getProperty('os.name').toLowerCase(Locale.ROOT) 147 if (platform.contains("linux")) { 148 cmd = "xdg-open" 149 } else if (platform.contains("mac os x")) { 150 cmd = "open" 151 } else if (platform.contains("windows")) { 152 cmd = "launch" 153 } 154 commandLine cmd, lint_report 155} 156 157task presubmit { 158 dependsOn { ['googleJavaFormat', 'lint', 'openLintReport'] } 159 doLast { 160 println "Fix any lint issues you see. When it looks good, submit the pull request." 161 } 162} 163 164