1buildscript { 2 repositories { 3 google() 4 jcenter() 5 } 6 dependencies { 7 classpath libraries.android_tools 8 } 9} 10 11plugins { 12 id 'com.github.dcendents.android-maven' version '2.1' 13} 14 15description = 'Conscrypt: Android' 16 17ext { 18 androidHome = "$System.env.ANDROID_HOME" 19 androidSdkInstalled = file("$androidHome").exists() 20 androidVersionCode = 1 21 androidVersionName = "$version" 22 androidMinSdkVersion = 9 23 androidTargetSdkVersion = 26 24} 25 26if (androidSdkInstalled) { 27 apply plugin: 'com.android.library' 28 apply plugin: 'com.github.dcendents.android-maven' 29 30 // Since we're not taking a direct dependency on the constants module, we need to add an 31 // explicit task dependency to make sure the code is generated. 32 evaluationDependsOn(':conscrypt-constants') 33 34 android { 35 compileSdkVersion androidTargetSdkVersion 36 37 compileOptions { 38 sourceCompatibility androidMinJavaVersion 39 targetCompatibility androidMinJavaVersion 40 } 41 42 defaultConfig { 43 minSdkVersion androidMinSdkVersion 44 targetSdkVersion androidTargetSdkVersion 45 versionCode androidVersionCode 46 versionName androidVersionName 47 48 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 49 50 consumerProguardFiles 'proguard-rules.pro' 51 52 externalNativeBuild { 53 cmake { 54 arguments '-DANDROID=True', 55 '-DANDROID_STL=c++_static', 56 "-DBORINGSSL_HOME=$boringsslHome" 57 cFlags '-fvisibility=hidden', 58 '-DBORINGSSL_SHARED_LIBRARY', 59 '-DBORINGSSL_IMPLEMENTATION', 60 '-DOPENSSL_SMALL', 61 '-D_XOPEN_SOURCE=700', 62 '-Wno-unused-parameter' 63 } 64 } 65 ndk { 66 abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' 67 } 68 } 69 buildTypes { 70 release { 71 minifyEnabled false 72 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 73 } 74 } 75 sourceSets.main { 76 java { 77 srcDirs = [ 78 "${rootDir}/common/src/main/java", 79 "src/main/java" 80 ] 81 // Requires evaluationDependsOn(':conscrypt-constants') above. 82 srcDirs += project(':conscrypt-constants').sourceSets.main.java.srcDirs 83 } 84 resources { 85 srcDirs += "build/generated/resources" 86 } 87 } 88 externalNativeBuild { 89 cmake { 90 path 'CMakeLists.txt' 91 } 92 } 93 lintOptions { 94 lintConfig file('lint.xml') 95 } 96 } 97 98 configurations { 99 publicApiDocs 100 } 101 102 preBuild { 103 dependsOn generateProperties 104 } 105 106 dependencies { 107 publicApiDocs project(':conscrypt-api-doclet') 108 androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', { 109 exclude module: 'support-annotations' 110 exclude module: 'support-v4' 111 exclude module: 'support-v13' 112 exclude module: 'recyclerview-v7' 113 exclude module: 'appcompat-v7' 114 exclude module: 'design' 115 }) 116 compileOnly project(':conscrypt-android-stub') 117 118 // Adds the constants module as a dependency so that we can include its generated source 119 compileOnly project(':conscrypt-constants') 120 } 121 122 task configureJavadocs { 123 dependsOn configurations.publicApiDocs 124 doLast { 125 javadocs.options.docletpath = configurations.publicApiDocs.files as List 126 } 127 } 128 129 task javadocs(type: Javadoc, dependsOn: [configureJavadocs]) { 130 source = android.sourceSets.main.java.srcDirs 131 classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + project(':conscrypt-android-stub').sourceSets.main.output 132 // TODO(nmittler): Fix the javadoc errors. 133 failOnError false 134 options { 135 encoding = 'UTF-8' 136 links "https://docs.oracle.com/javase/7/docs/api/" 137 doclet = "org.conscrypt.doclet.FilterDoclet" 138 // Disable JavaDoc doclint on Java 8. It's annoying. 139 if (JavaVersion.current().isJava8Compatible()) { 140 addStringOption('Xdoclint:none', '-quiet') 141 } 142 } 143 } 144 145 task javadocsJar(type: Jar, dependsOn: javadocs) { 146 classifier = 'javadoc' 147 from javadocs.destinationDir 148 } 149 150 task sourcesJar(type: Jar) { 151 classifier = 'sources' 152 from android.sourceSets.main.java.srcDirs 153 } 154 155 artifacts { 156 archives sourcesJar 157 archives javadocsJar 158 } 159 160 uploadArchives.repositories.mavenDeployer { 161 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 162 String stagingUrl 163 if (rootProject.hasProperty('repositoryId')) { 164 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + 165 rootProject.repositoryId 166 } else { 167 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' 168 } 169 def configureAuth = { 170 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { 171 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) 172 } 173 } 174 repository(url: stagingUrl, configureAuth) 175 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) 176 } 177 178 [ 179 install.repositories.mavenInstaller, 180 uploadArchives.repositories.mavenDeployer, 181 ]*.pom*.whenConfigured { pom -> 182 pom.project { 183 name "$project.group:$project.name" 184 description project.description 185 url 'https://conscrypt.org/' 186 187 scm { 188 connection 'scm:git:https://github.com/google/conscrypt.git' 189 developerConnection 'scm:git:git@github.com:google/conscrypt.git' 190 url 'https://github.com/google/conscrypt' 191 } 192 193 licenses { 194 license { 195 name 'Apache 2' 196 url 'https://www.apache.org/licenses/LICENSE-2.0' 197 } 198 } 199 200 developers { 201 developer { 202 id "conscrypt" 203 name "Conscrypt Contributors" 204 email "conscrypt@googlegroups.com" 205 url "https://conscrypt.org/" 206 organization = "Google, Inc." 207 organizationUrl "https://www.google.com" 208 } 209 } 210 } 211 } 212 213} else { 214 logger.warn('Android SDK has not been detected. The Android module will not be built.') 215 216 // Disable all tasks 217 tasks.collect { 218 it.enabled = false 219 } 220} 221