• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1buildscript {
2    repositories {
3        mavenCentral()
4        mavenLocal()
5        jcenter()
6    }
7    dependencies {
8        classpath libraries.android_tools
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 module: 'support-annotations'
104            exclude module: 'support-v4'
105            exclude module: 'support-v13'
106            exclude module: 'recyclerview-v7'
107            exclude module: 'appcompat-v7'
108            exclude module: 'design'
109        })
110        provided project(':conscrypt-android-stub')
111
112        // Adds the constants module as a dependency so that we can include its generated source
113        provided project(':conscrypt-constants')
114    }
115
116    task javadocs(type: Javadoc) {
117        source = android.sourceSets.main.java.srcDirs
118        classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + project(':conscrypt-android-stub').sourceSets.main.output
119        // TODO(nmittler): Fix the javadoc errors.
120        failOnError false
121        options {
122            encoding = 'UTF-8'
123            links "https://docs.oracle.com/javase/7/docs/api/"
124            doclet = "org.conscrypt.doclet.FilterDoclet"
125            docletpath = configurations.publicApiDocs.files as List
126            // Disable JavaDoc doclint on Java 8. It's annoying.
127            if (JavaVersion.current().isJava8Compatible()) {
128                addStringOption('Xdoclint:none', '-quiet')
129            }
130        }
131    }
132
133    task javadocsJar(type: Jar, dependsOn: javadocs) {
134        classifier = 'javadoc'
135        from javadocs.destinationDir
136    }
137
138    task sourcesJar(type: Jar) {
139        classifier = 'sources'
140        from android.sourceSets.main.java.srcDirs
141    }
142
143    artifacts {
144        archives sourcesJar
145        archives javadocsJar
146    }
147
148    uploadArchives.repositories.mavenDeployer {
149        beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
150        String stagingUrl
151        if (rootProject.hasProperty('repositoryId')) {
152            stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
153                    rootProject.repositoryId
154        } else {
155            stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
156        }
157        def configureAuth = {
158            if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
159                authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
160            }
161        }
162        repository(url: stagingUrl, configureAuth)
163        snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
164    }
165
166    [
167            install.repositories.mavenInstaller,
168            uploadArchives.repositories.mavenDeployer,
169    ]*.pom*.whenConfigured { pom ->
170        pom.project {
171            name "$project.group:$project.name"
172            description project.description
173            url 'https://conscrypt.org/'
174
175            scm {
176                connection 'scm:git:https://github.com/google/conscrypt.git'
177                developerConnection 'scm:git:git@github.com:google/conscrypt.git'
178                url 'https://github.com/google/conscrypt'
179            }
180
181            licenses {
182                license {
183                    name 'Apache 2'
184                    url 'https://www.apache.org/licenses/LICENSE-2.0'
185                }
186            }
187
188            developers {
189                developer {
190                    id "conscrypt"
191                    name "Conscrypt Contributors"
192                    email "conscrypt@googlegroups.com"
193                    url "https://conscrypt.org/"
194                    organization = "Google, Inc."
195                    organizationUrl "https://www.google.com"
196                }
197            }
198        }
199    }
200
201} else {
202    logger.warn('Android SDK has not been detected. The Android module will not be built.')
203
204    // Disable all tasks
205    tasks.collect {
206        it.enabled = false
207    }
208}
209