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.10' 16 } 17 } 18 19 subprojects { 20 def androidProject = (project.name == 'conscrypt-android') || (project.name == 'conscrypt-android-platform') 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 = normalizePath("$boringsslHome/include") 62 boringssl32BuildDir = normalizePath("$boringsslHome/build32") 63 boringssl64BuildDir = normalizePath("$boringsslHome/build64") 64 jdkHome = "$System.env.JAVA_HOME" 65 jdkIncludeDir = normalizePath("$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.19' 84 libraries = [ 85 roboelectric: 'org.robolectric:android-all:7.1.0_r7-robolectric-0', 86 87 // Test dependencies. 88 bouncycastle_apis: 'org.bouncycastle:bcpkix-jdk15on:1.56', 89 bouncycastle_provider: 'org.bouncycastle:bcprov-jdk15on:1.56', 90 junit : 'junit:junit:4.12', 91 mockito: 'org.mockito:mockito-core:1.9.5', 92 truth : 'com.google.truth:truth:0.28', 93 94 // Benchmark dependencies 95 jmh_core: "org.openjdk.jmh:jmh-core:${jmhVersion}", 96 jmh_generator_annprocess: "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}", 97 jmh_generator_asm: "org.openjdk.jmh:jmh-generator-asm:${jmhVersion}", 98 jmh_generator_bytecode: "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}", 99 jmh_generator_reflection: "org.openjdk.jmh:jmh-generator-reflection:${jmhVersion}", 100 netty_handler: 'io.netty:netty-handler:4.1.8.Final', 101 netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork26', 102 ] 103 } 104 105 repositories { 106 mavenCentral() 107 mavenLocal() 108 jcenter() 109 } 110 111 signing { 112 required false 113 sign configurations.archives 114 } 115 116 if (!androidProject) { 117 sourceCompatibility = JavaVersion.VERSION_1_8 118 targetCompatibility = JavaVersion.VERSION_1_8 119 120 [compileJava, compileTestJava].each() { 121 it.options.compilerArgs += ["-Xlint:all", "-Xlint:-options", '-Xmaxwarns', '9999999'] 122 it.options.encoding = "UTF-8" 123 if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) { 124 it.options.compilerArgs += ["-Werror"] 125 } 126 } 127 128 compileTestJava { 129 // serialVersionUID is basically guaranteed to be useless in our tests 130 options.compilerArgs += ["-Xlint:-serial"] 131 } 132 133 jar.manifest { 134 attributes('Implementation-Title': name, 135 'Implementation-Version': version, 136 'Built-By': System.getProperty('user.name'), 137 'Built-JDK': System.getProperty('java.version'), 138 'Source-Compatibility': sourceCompatibility, 139 'Target-Compatibility': targetCompatibility) 140 } 141 142 javadoc.options { 143 encoding = 'UTF-8' 144 links 'https://docs.oracle.com/javase/8/docs/api/' 145 } 146 147 // Disable JavaDoc doclint on Java 8. It's annoying. 148 if (JavaVersion.current().isJava8Compatible()) { 149 allprojects { 150 tasks.withType(Javadoc) { 151 options.addStringOption('Xdoclint:none', '-quiet') 152 } 153 } 154 } 155 156 task javadocJar(type: Jar) { 157 classifier = 'javadoc' 158 from javadoc 159 } 160 161 task sourcesJar(type: Jar) { 162 classifier = 'sources' 163 from sourceSets.main.allSource 164 } 165 166 artifacts { 167 archives sourcesJar 168 archives javadocJar 169 } 170 171 uploadArchives.repositories.mavenDeployer { 172 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 173 String stagingUrl 174 if (rootProject.hasProperty('repositoryId')) { 175 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + 176 rootProject.repositoryId 177 } else { 178 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' 179 } 180 def configureAuth = { 181 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { 182 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) 183 } 184 } 185 repository(url: stagingUrl, configureAuth) 186 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) 187 } 188 189 [ 190 install.repositories.mavenInstaller, 191 uploadArchives.repositories.mavenDeployer, 192 ]*.pom*.whenConfigured { pom -> 193 pom.project { 194 name "$project.group:$project.name" 195 description project.description 196 url 'https://conscrypt.org/' 197 198 scm { 199 connection 'scm:git:https://github.com/google/conscrypt.git' 200 developerConnection 'scm:git:git (a] github.com:google/conscrypt.git' 201 url 'https://github.com/google/conscrypt' 202 } 203 204 licenses { 205 license { 206 name 'Apache 2' 207 url 'https://www.apache.org/licenses/LICENSE-2.0' 208 } 209 } 210 211 developers { 212 developer { 213 id "conscrypt" 214 name "Conscrypt Contributors" 215 email "conscrypt (a] googlegroups.com" 216 url "https://conscrypt.org/" 217 organization = "Google, Inc." 218 organizationUrl "https://www.google.com" 219 } 220 } 221 } 222 } 223 224 // At a test failure, log the stack trace to the console so that we don't 225 // have to open the HTML in a browser. 226 test { 227 testLogging { 228 exceptionFormat = 'full' 229 showExceptions true 230 showCauses true 231 showStackTraces true 232 } 233 maxHeapSize = '1500m' 234 } 235 } 236 } 237 238 static String normalizePath(path) { 239 new File(path.toString()).absolutePath 240 } 241