Home | History | Annotate | Download | only in platform
      1 buildscript {
      2     repositories {
      3         google()
      4         jcenter()
      5     }
      6     dependencies {
      7         classpath libraries.android_tools
      8     }
      9 }
     10 
     11 plugins {
     12     id 'com.github.dcendents.android-maven' version '2.1'
     13 }
     14 
     15 description = 'Conscrypt: Android Platform'
     16 
     17 ext {
     18     androidHome = "$System.env.ANDROID_HOME"
     19     androidSdkInstalled = file("$androidHome").exists()
     20     androidVersionCode = 1
     21     androidVersionName = "$version"
     22     // Platform is always built against head, so we can use newer API versions.
     23     androidMinSdkVersion = 26
     24     androidTargetSdkVersion = 26
     25 }
     26 
     27 if (androidSdkInstalled) {
     28     apply plugin: 'com.android.library'
     29 
     30     android {
     31         compileSdkVersion androidTargetSdkVersion
     32 
     33         compileOptions {
     34             sourceCompatibility androidMinJavaVersion;
     35             targetCompatibility androidMinJavaVersion
     36         }
     37 
     38         defaultConfig {
     39             minSdkVersion androidMinSdkVersion
     40             targetSdkVersion androidTargetSdkVersion
     41             versionCode androidVersionCode
     42             versionName androidVersionName
     43 
     44             testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     45 
     46             consumerProguardFiles 'proguard-rules.pro'
     47 
     48             externalNativeBuild {
     49                 cmake {
     50                     arguments '-DANDROID=True',
     51                             '-DANDROID_STL=c++_static',
     52                             "-DBORINGSSL_HOME=$boringsslHome"
     53                     cFlags '-fvisibility=hidden',
     54                             '-DBORINGSSL_SHARED_LIBRARY',
     55                             '-DBORINGSSL_IMPLEMENTATION',
     56                             '-DOPENSSL_SMALL',
     57                             '-D_XOPEN_SOURCE=700',
     58                             '-Wno-unused-parameter'
     59                 }
     60             }
     61             ndk {
     62                 abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
     63             }
     64         }
     65         buildTypes {
     66             release {
     67                 minifyEnabled false
     68                 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
     69             }
     70         }
     71         sourceSets {
     72             main {
     73                 java {
     74                     srcDirs = [
     75                             "${rootDir}/common/src/main/java",
     76                             "src/main/java",
     77                     ]
     78                     excludes = [ 'org/conscrypt/Platform.java' ]
     79                 }
     80             }
     81         }
     82         lintOptions {
     83             lintConfig file('lint.xml')
     84         }
     85     }
     86 
     87     configurations {
     88         publicApiDocs
     89     }
     90 
     91     dependencies {
     92         implementation project(path: ':conscrypt-openjdk', configuration: 'platform')
     93         publicApiDocs project(':conscrypt-api-doclet')
     94         androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', {
     95             exclude module: 'support-annotations'
     96             exclude module: 'support-v4'
     97             exclude module: 'support-v13'
     98             exclude module: 'recyclerview-v7'
     99             exclude module: 'appcompat-v7'
    100             exclude module: 'design'
    101         })
    102         testImplementation project(':conscrypt-testing'),
    103                            libraries.junit
    104         compileOnly project(':conscrypt-android-stub'),
    105                     project(':conscrypt-libcore-stub')
    106 
    107         // Adds the constants module as a dependency so that we can include its generated source
    108         compileOnly project(':conscrypt-constants')
    109     }
    110 
    111     // Disable running the tests.
    112     tasks.withType(Test){
    113         enabled = false
    114     }
    115 
    116 } else {
    117     logger.warn('Android SDK has not been detected. The Android Platform module will not be built.')
    118 
    119     // Disable all tasks
    120     tasks.collect {
    121         it.enabled = false
    122     }
    123 }
    124