buildscript { repositories { mavenCentral() mavenLocal() jcenter() } dependencies { classpath libraries.android_tools classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } description = 'Conscrypt: Android' ext { androidHome = "$System.env.ANDROID_HOME" androidSdkInstalled = file("$androidHome").exists() androidVersionCode = 1 androidVersionName = "$version" androidMinSdkVersion = 9 androidTargetSdkVersion = 25 androidBuildToolsVersion = "25.0.0" } if (androidSdkInstalled) { apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' // Since we're not taking a direct dependency on the constants module, we need to add an // explicit task dependency to make sure the code is generated. evaluationDependsOn(':conscrypt-constants') android { compileSdkVersion androidTargetSdkVersion buildToolsVersion androidBuildToolsVersion compileOptions { sourceCompatibility androidMinJavaVersion; targetCompatibility androidMinJavaVersion } defaultConfig { minSdkVersion androidMinSdkVersion targetSdkVersion androidTargetSdkVersion versionCode androidVersionCode versionName androidVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" consumerProguardFiles 'proguard-rules.pro' externalNativeBuild { cmake { arguments '-DANDROID=True', '-DANDROID_STL=c++_static', "-DBORINGSSL_HOME=$boringsslHome" cFlags '-fvisibility=hidden', '-DBORINGSSL_SHARED_LIBRARY', '-DBORINGSSL_IMPLEMENTATION', '-DOPENSSL_SMALL', '-D_XOPEN_SOURCE=700', '-Wno-unused-parameter' } } ndk { abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets.main { java { srcDirs = [ "${rootDir}/common/src/main/java", "src/main/java" ] // Requires evaluationDependsOn(':conscrypt-constants') above. srcDirs += project(':conscrypt-constants').sourceSets.main.java.srcDirs } } externalNativeBuild { cmake { path 'CMakeLists.txt' } } lintOptions { lintConfig file('lint.xml') } } configurations { publicApiDocs } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) publicApiDocs project(':conscrypt-api-doclet') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude module: 'support-annotations' exclude module: 'support-v4' exclude module: 'support-v13' exclude module: 'recyclerview-v7' exclude module: 'appcompat-v7' exclude module: 'design' }) provided project(':conscrypt-android-stub') // Adds the constants module as a dependency so that we can include its generated source provided project(':conscrypt-constants') } task javadocs(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + project(':conscrypt-android-stub').sourceSets.main.output // TODO(nmittler): Fix the javadoc errors. failOnError false options { encoding = 'UTF-8' links "https://docs.oracle.com/javase/7/docs/api/" doclet = "org.conscrypt.doclet.FilterDoclet" docletpath = configurations.publicApiDocs.files as List // Disable JavaDoc doclint on Java 8. It's annoying. if (JavaVersion.current().isJava8Compatible()) { addStringOption('Xdoclint:none', '-quiet') } } } task javadocsJar(type: Jar, dependsOn: javadocs) { classifier = 'javadoc' from javadocs.destinationDir } task sourcesJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } artifacts { archives sourcesJar archives javadocsJar } uploadArchives.repositories.mavenDeployer { beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } String stagingUrl if (rootProject.hasProperty('repositoryId')) { stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + rootProject.repositoryId } else { stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' } def configureAuth = { if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) } } repository(url: stagingUrl, configureAuth) snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) } [ install.repositories.mavenInstaller, uploadArchives.repositories.mavenDeployer, ]*.pom*.whenConfigured { pom -> pom.project { name "$project.group:$project.name" description project.description url 'https://conscrypt.org/' scm { connection 'scm:git:https://github.com/google/conscrypt.git' developerConnection 'scm:git:git@github.com:google/conscrypt.git' url 'https://github.com/google/conscrypt' } licenses { license { name 'Apache 2' url 'https://www.apache.org/licenses/LICENSE-2.0' } } developers { developer { id "conscrypt" name "Conscrypt Contributors" email "conscrypt@googlegroups.com" url "https://conscrypt.org/" organization = "Google, Inc." organizationUrl "https://www.google.com" } } } } } else { logger.warn('Android SDK has not been detected. The Android module will not be built.') // Disable all tasks tasks.collect { it.enabled = false } }