Home | History | Annotate | Download | only in conscrypt
      1 buildscript {
      2     repositories {
      3         mavenCentral()
      4         mavenLocal()
      5         jcenter()
      6         maven {
      7             url 'https://plugins.gradle.org/m2/'
      8         }
      9     }
     10     dependencies {
     11         // Add dependency for build script,
     12         // so we can access Git from our
     13         // build script.
     14         classpath 'org.ajoberstar:grgit:1.1.0'
     15         classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.9'
     16     }
     17 }
     18 
     19 subprojects {
     20     def androidProject = project.name == 'conscrypt-android'
     21     if (!androidProject) {
     22         apply plugin: 'java'
     23         apply plugin: 'cpp'
     24 
     25         model {
     26             toolChains {
     27                 visualCpp(VisualCpp) {
     28                     // Temporary hack for https://github.com/gradle/gradle/issues/929
     29                     installDir "file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2014.0"
     30                     windowsSdkDir "file:///C:/Program%20Files%20(x86)/Windows%20Kits/8.1"
     31                 }
     32                 // Prefer Clang over Gcc (order here matters!)
     33                 clang(Clang)
     34                 gcc(Gcc)
     35             }
     36         }
     37     }
     38     apply plugin: "maven"
     39     apply plugin: "signing"
     40     apply plugin: "idea"
     41     apply plugin: "jacoco"
     42     apply plugin: "net.ltgt.errorprone"
     43 
     44     group = "org.conscrypt"
     45     description = 'Conscrypt is an alternate Java Security Provider that uses BoringSSL'
     46     version = "1.1.0-SNAPSHOT"
     47 
     48     ext {
     49         os = org.gradle.internal.os.OperatingSystem.current();
     50         if (os.isLinux()) {
     51             osName = "linux"
     52         } else if (os.isMacOsX()) {
     53             osName = "osx"
     54         } else if (os.isWindows()) {
     55             osName = "windows"
     56         } else {
     57             throw new GradleException("Unsupported os: " + os.name)
     58         }
     59 
     60         boringsslHome = "$System.env.BORINGSSL_HOME"
     61         boringsslIncludeDir = "$boringsslHome/include"
     62         boringssl32BuildDir = "$boringsslHome/build32"
     63         boringssl64BuildDir = "$boringsslHome/build64"
     64         jdkHome = "$System.env.JAVA_HOME"
     65         jdkIncludeDir = "$jdkHome/include"
     66         // Needs to be binary compatible with androidMinSdkVersion
     67         androidMinJavaVersion = JavaVersion.VERSION_1_7
     68 
     69         build32Bit = file("$boringssl32BuildDir").exists()
     70         build64Bit = file("$boringssl64BuildDir").exists()
     71 
     72         // Ensure the environment is configured properly.
     73         assert file("$boringsslHome").exists()
     74         assert file("$boringsslIncludeDir").exists()
     75         assert build32Bit || build64Bit
     76         assert file("$jdkHome").exists()
     77         assert file("$jdkIncludeDir").exists()
     78 
     79         // Get the commit hash for BoringSSL.
     80         boringSslGit = org.ajoberstar.grgit.Grgit.open(file("$boringsslHome"))
     81         boringSslVersion = boringSslGit.head().id
     82 
     83         jmhVersion = '1.17.4'
     84         libraries = [
     85                 roboelectric: 'org.robolectric:android-all:5.0.0_r2-robolectric-1',
     86 
     87                 // Test dependencies.
     88                 guava : 'com.google.guava:guava:19.0',
     89                 junit  : 'junit:junit:4.12',
     90                 mockito: 'org.mockito:mockito-core:1.9.5',
     91                 truth  : 'com.google.truth:truth:0.28',
     92                 bouncycastle_provider: 'org.bouncycastle:bcprov-jdk15on:1.55',
     93                 bouncycastle_apis: 'org.bouncycastle:bcpkix-jdk15on:1.55',
     94 
     95                 // Benchmark dependencies
     96                 jmh_core: "org.openjdk.jmh:jmh-core:${jmhVersion}",
     97                 jmh_generator_annprocess: "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}",
     98                 jmh_generator_asm: "org.openjdk.jmh:jmh-generator-asm:${jmhVersion}",
     99                 jmh_generator_bytecode: "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}",
    100                 jmh_generator_reflection: "org.openjdk.jmh:jmh-generator-reflection:${jmhVersion}",
    101                 netty_handler: 'io.netty:netty-handler:4.1.8.Final',
    102                 netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork26',
    103         ]
    104     }
    105 
    106     repositories {
    107         mavenCentral()
    108         mavenLocal()
    109         jcenter()
    110     }
    111 
    112     signing {
    113         required false
    114         sign configurations.archives
    115     }
    116 
    117     if (!androidProject) {
    118         sourceCompatibility = JavaVersion.VERSION_1_8
    119         targetCompatibility = JavaVersion.VERSION_1_8
    120 
    121         [compileJava, compileTestJava].each() {
    122             it.options.compilerArgs += ["-Xlint:all", "-Xlint:-options", '-Xmaxwarns', '9999999']
    123             it.options.encoding = "UTF-8"
    124             if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
    125                 it.options.compilerArgs += ["-Werror"]
    126             }
    127         }
    128 
    129         compileTestJava {
    130             // serialVersionUID is basically guaranteed to be useless in our tests
    131             options.compilerArgs += ["-Xlint:-serial"]
    132         }
    133 
    134         jar.manifest {
    135             attributes('Implementation-Title': name,
    136                     'Implementation-Version': version,
    137                     'Built-By': System.getProperty('user.name'),
    138                     'Built-JDK': System.getProperty('java.version'),
    139                     'Source-Compatibility': sourceCompatibility,
    140                     'Target-Compatibility': targetCompatibility)
    141         }
    142 
    143         javadoc.options {
    144             encoding = 'UTF-8'
    145             links 'https://docs.oracle.com/javase/8/docs/api/'
    146         }
    147 
    148         // Disable JavaDoc doclint on Java 8. It's annoying.
    149         if (JavaVersion.current().isJava8Compatible()) {
    150             allprojects {
    151                 tasks.withType(Javadoc) {
    152                     options.addStringOption('Xdoclint:none', '-quiet')
    153                 }
    154             }
    155         }
    156 
    157         task javadocJar(type: Jar) {
    158             classifier = 'javadoc'
    159             from javadoc
    160         }
    161 
    162         task sourcesJar(type: Jar) {
    163             classifier = 'sources'
    164             from sourceSets.main.allSource
    165         }
    166 
    167         artifacts {
    168             archives sourcesJar
    169             archives javadocJar
    170         }
    171 
    172         uploadArchives.repositories.mavenDeployer {
    173             beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
    174             String stagingUrl
    175             if (rootProject.hasProperty('repositoryId')) {
    176                 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
    177                         rootProject.repositoryId
    178             } else {
    179                 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
    180             }
    181             def configureAuth = {
    182                 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
    183                     authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
    184                 }
    185             }
    186             repository(url: stagingUrl, configureAuth)
    187             snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
    188         }
    189 
    190         [
    191                 install.repositories.mavenInstaller,
    192                 uploadArchives.repositories.mavenDeployer,
    193         ]*.pom*.whenConfigured { pom ->
    194             pom.project {
    195                 name "$project.group:$project.name"
    196                 description project.description
    197                 url 'https://conscrypt.org/'
    198 
    199                 scm {
    200                     connection 'scm:git:https://github.com/google/conscrypt.git'
    201                     developerConnection 'scm:git:git (a] github.com:google/conscrypt.git'
    202                     url 'https://github.com/google/conscrypt'
    203                 }
    204 
    205                 licenses {
    206                     license {
    207                         name 'Apache 2'
    208                         url 'https://www.apache.org/licenses/LICENSE-2.0'
    209                     }
    210                 }
    211 
    212                 developers {
    213                     developer {
    214                         id "conscrypt"
    215                         name "Conscrypt Contributors"
    216                         email "conscrypt (a] googlegroups.com"
    217                         url "https://conscrypt.org/"
    218                         organization = "Google, Inc."
    219                         organizationUrl "https://www.google.com"
    220                     }
    221                 }
    222             }
    223         }
    224 
    225         // At a test failure, log the stack trace to the console so that we don't
    226         // have to open the HTML in a browser.
    227         test {
    228             testLogging {
    229                 exceptionFormat = 'full'
    230                 showExceptions true
    231                 showCauses true
    232                 showStackTraces true
    233             }
    234             maxHeapSize = '1500m'
    235         }
    236     }
    237 }
    238