1buildscript { 2 repositories { 3 jcenter() 4 google() 5 } 6 dependencies { 7 classpath 'com.android.tools.build:gradle:4.1.2' 8 9 // NOTE: Do not place your application dependencies here. 10 } 11} 12 13plugins { 14 id "com.github.sherter.google-java-format" version "0.9" 15} 16 17allprojects { 18 repositories { 19 google() 20 jcenter() 21 } 22 gradle.projectsEvaluated { 23 tasks.withType(JavaCompile) { 24 options.compilerArgs << "-Xlint:all" 25 } 26 } 27} 28 29apply plugin: 'com.android.application' 30 31android { 32 compileSdkVersion 29 33 buildToolsVersion "30.0.2" 34 35 defaultConfig { 36 applicationId "com.google.android.mobly.snippet.bundled" 37 minSdkVersion 15 38 // Set target to 22 to avoid having to deal with runtime permissions. 39 targetSdkVersion 22 40 versionCode 1 41 versionName "0.0.1" 42 setProperty("archivesBaseName", "mobly-bundled-snippets") 43 multiDexEnabled true 44 } 45 compileOptions { 46 sourceCompatibility JavaVersion.VERSION_1_8 47 targetCompatibility JavaVersion.VERSION_1_8 48 } 49 lintOptions { 50 abortOnError false 51 checkAllWarnings true 52 warningsAsErrors true 53 disable 'HardwareIds','MissingApplicationIcon','GoogleAppIndexingWarning','InvalidPackage','OldTargetApi' 54 } 55} 56 57// Produces a jar of source files. Needed for compliance reasons. 58task sourcesJar(type: Jar) { 59 from android.sourceSets.main.java.srcDirs 60 classifier = 'src' 61} 62 63task javadoc(type: Javadoc) { 64 source = android.sourceSets.main.java.srcDirs 65 classpath += project.files( 66 android.getBootClasspath().join(File.pathSeparator)) 67} 68 69artifacts { 70 archives sourcesJar 71} 72 73dependencies { 74 implementation 'androidx.test:runner:1.3.0' 75 implementation 'com.google.android.mobly:mobly-snippet-lib:1.2.0' 76 implementation 'com.google.code.gson:gson:2.8.6' 77 implementation 'com.google.guava:guava:30.1-jre' 78 implementation 'com.google.errorprone:error_prone_annotations:2.5.1' 79 80 testImplementation 'com.google.errorprone:error_prone_annotations:2.5.1' 81 testImplementation 'com.google.guava:guava:30.1-jre' 82 testImplementation 'com.google.truth:truth:1.1.2' 83 testImplementation 'junit:junit:4.13.2' 84} 85 86googleJavaFormat { 87 options style: 'AOSP' 88} 89 90// Open lint's HTML report in your default browser or viewer. 91task openLintReport(type: Exec) { 92 def lint_report = "build/reports/lint-results.html" 93 def cmd = "cat" 94 def platform = System.getProperty('os.name').toLowerCase(Locale.ROOT) 95 if (platform.contains("linux")) { 96 cmd = "xdg-open" 97 } else if (platform.contains("mac os x")) { 98 cmd = "open" 99 } else if (platform.contains("windows")) { 100 cmd = "launch" 101 } 102 commandLine cmd, lint_report 103} 104 105task presubmit { 106 dependsOn { ['googleJavaFormat', 'lint', 'openLintReport'] } 107 doLast { 108 println "Fix any lint issues you see. When it looks good, submit the pull request." 109 } 110} 111 112