1buildscript { 2 repositories { 3 mavenCentral() 4 mavenLocal() 5 jcenter() 6 } 7 dependencies { 8 classpath 'com.android.tools.build:gradle:2.2.3' // jcenter has the latest 9 classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 10 } 11} 12 13description = 'Conscrypt: Android' 14 15ext { 16 androidHome = "$System.env.ANDROID_HOME" 17 androidSdkInstalled = file("$androidHome").exists() 18 androidVersionCode = 1 19 androidVersionName = "$version" 20 androidMinSdkVersion = 9 21 androidTargetSdkVersion = 25 22 androidBuildToolsVersion = "25.0.0" 23} 24 25if (androidSdkInstalled) { 26 apply plugin: 'com.android.library' 27 apply plugin: 'com.github.dcendents.android-maven' 28 29 // Since we're not taking a direct dependency on the constants module, we need to add an 30 // explicit task dependency to make sure the code is generated. 31 evaluationDependsOn(':conscrypt-constants') 32 33 android { 34 compileSdkVersion androidTargetSdkVersion 35 buildToolsVersion androidBuildToolsVersion 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 "android.support.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 } 85 externalNativeBuild { 86 cmake { 87 path 'CMakeLists.txt' 88 } 89 } 90 lintOptions { 91 lintConfig file('lint.xml') 92 } 93 } 94 95 configurations { 96 publicApiDocs 97 } 98 99 dependencies { 100 compile fileTree(dir: 'libs', include: ['*.jar']) 101 publicApiDocs project(':conscrypt-api-doclet') 102 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 103 exclude group: 'com.android.support', module: 'support-annotations' 104 }) 105 provided project(':conscrypt-android-stub') 106 107 // Adds the constants module as a dependency so that we can include its generated source 108 provided project(':conscrypt-constants') 109 } 110 111 task javadocs(type: Javadoc) { 112 source = android.sourceSets.main.java.srcDirs 113 classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + project(':conscrypt-android-stub').sourceSets.main.output 114 // TODO(nmittler): Fix the javadoc errors. 115 failOnError false 116 options { 117 encoding = 'UTF-8' 118 links "https://docs.oracle.com/javase/7/docs/api/" 119 doclet = "org.conscrypt.doclet.FilterDoclet" 120 docletpath = configurations.publicApiDocs.files as List 121 // Disable JavaDoc doclint on Java 8. It's annoying. 122 if (JavaVersion.current().isJava8Compatible()) { 123 addStringOption('Xdoclint:none', '-quiet') 124 } 125 } 126 } 127 128 task javadocsJar(type: Jar, dependsOn: javadocs) { 129 classifier = 'javadoc' 130 from javadocs.destinationDir 131 } 132 133 task sourcesJar(type: Jar) { 134 classifier = 'sources' 135 from android.sourceSets.main.java.srcDirs 136 } 137 138 artifacts { 139 archives sourcesJar 140 archives javadocsJar 141 } 142 143 uploadArchives.repositories.mavenDeployer { 144 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 145 String stagingUrl 146 if (rootProject.hasProperty('repositoryId')) { 147 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + 148 rootProject.repositoryId 149 } else { 150 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' 151 } 152 def configureAuth = { 153 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { 154 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) 155 } 156 } 157 repository(url: stagingUrl, configureAuth) 158 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) 159 } 160 161 [ 162 install.repositories.mavenInstaller, 163 uploadArchives.repositories.mavenDeployer, 164 ]*.pom*.whenConfigured { pom -> 165 pom.project { 166 name "$project.group:$project.name" 167 description project.description 168 url 'https://conscrypt.org/' 169 170 scm { 171 connection 'scm:git:https://github.com/google/conscrypt.git' 172 developerConnection 'scm:git:git@github.com:google/conscrypt.git' 173 url 'https://github.com/google/conscrypt' 174 } 175 176 licenses { 177 license { 178 name 'Apache 2' 179 url 'https://www.apache.org/licenses/LICENSE-2.0' 180 } 181 } 182 183 developers { 184 developer { 185 id "conscrypt" 186 name "Conscrypt Contributors" 187 email "conscrypt@googlegroups.com" 188 url "https://conscrypt.org/" 189 organization = "Google, Inc." 190 organizationUrl "https://www.google.com" 191 } 192 } 193 } 194 } 195 196} else { 197 logger.warn('Android SDK has not been detected. The Android module will not be built.') 198 199 // Disable all tasks 200 tasks.collect { 201 it.enabled = false 202 } 203} 204