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