1description = 'Conscrypt: OpenJdk UberJAR' 2 3ext { 4 buildUberJar = Boolean.parseBoolean(System.getProperty('org.conscrypt.openjdk.buildUberJar', 'false')) 5 uberJarClassifiers = (System.getProperty('org.conscrypt.openjdk.uberJarClassifiers', 6 'osx-x86_64,linux-x86_64,windows-x86,windows-x86_64')).split(',') 7 classesDir = "${buildDir}/classes" 8 resourcesDir = "${buildDir}/resources" 9 sourcesDir = "${buildDir}/sources" 10} 11 12if (buildUberJar) { 13 configurations { 14 uberJar 15 } 16 17 // Point the jar task to the copied classes and resources directories. 18 jar { 19 from classesDir 20 from resourcesDir 21 } 22 23 sourcesJar { 24 from sourcesDir 25 } 26 27 // Add the dependencies for the uber jar. 28 uberJarClassifiers.each { uberJarClassifier -> 29 dependencies.uberJar "${group}:conscrypt-openjdk:${version}:${uberJarClassifier}" 30 } 31 32 /** 33 * Copy the native libraries to the resources directory. 34 */ 35 task copySharedLibs(type: Copy, dependsOn: configurations.uberJar) { 36 from { 37 configurations.uberJar.collect { 38 zipTree(it) 39 } 40 } 41 include '/META-INF/native/**' 42 into file(resourcesDir) 43 } 44 jar.dependsOn copySharedLibs 45 46 /** 47 * Copy the object files to the classes directory. 48 */ 49 task copyClasses(type: Copy, dependsOn: configurations.uberJar) { 50 from { 51 configurations.uberJar.collect { 52 zipTree(it) 53 } 54 } 55 exclude '/META-INF/**' 56 into file(classesDir) 57 } 58 jar.dependsOn copyClasses 59 60 task copySources(type: Copy, dependsOn: ":conscrypt-openjdk:sourcesJar") { 61 from { 62 project(":conscrypt-openjdk").sourceSets.main.java 63 } 64 into file(sourcesDir) 65 } 66 sourcesJar.dependsOn copySources 67 68 // Note that this assumes that the version of BoringSSL for each 69 // artifact exactly matches the one on the current system. 70 jar.manifest { 71 attributes ('BoringSSL-Version': boringSslVersion, 72 'Automatic-Module-Name': 'org.conscrypt') 73 } 74} else { 75 // Not building an uber jar - disable all tasks. 76 tasks.collect { 77 it.enabled = false 78 } 79} 80 81