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 apply plugin: 'biz.aQute.bnd.builder' 14 15 configurations { 16 uberJar 17 } 18 19 // Point the jar task to the copied classes and resources directories. 20 jar { 21 from classesDir 22 from resourcesDir 23 } 24 25 sourcesJar { 26 from sourcesDir 27 } 28 29 // Add the dependencies for the uber jar. 30 uberJarClassifiers.each { uberJarClassifier -> 31 dependencies.uberJar "${group}:conscrypt-openjdk:${version}:${uberJarClassifier}" 32 } 33 34 /** 35 * Copy the native libraries to the resources directory. 36 */ 37 def copySharedLibs = tasks.register("copySharedLibs", Copy) { 38 dependsOn configurations.uberJar 39 from { 40 configurations.uberJar.collect { 41 zipTree(it) 42 } 43 } 44 include '/META-INF/native/**' 45 into file(resourcesDir) 46 } 47 tasks.named("jar").configure { 48 dependsOn copySharedLibs 49 } 50 51 /** 52 * Copy the object files to the classes directory. 53 */ 54 def copyClasses = tasks.register("copyClasses", Copy) { 55 dependsOn configurations.uberJar 56 from { 57 configurations.uberJar.collect { 58 zipTree(it) 59 } 60 } 61 exclude '/META-INF/**' 62 into file(classesDir) 63 } 64 tasks.named("jar").configure { 65 dependsOn copyClasses 66 } 67 68 def copySources = tasks.register("copySources", Copy) { 69 dependsOn ":conscrypt-openjdk:sourcesJar" 70 from { 71 project(":conscrypt-openjdk").sourceSets.main.java 72 } 73 into file(sourcesDir) 74 } 75 tasks.named("sourcesJar").configure { 76 dependsOn copySources 77 } 78 79 // Note that this assumes that the version of BoringSSL for each 80 // artifact exactly matches the one on the current system. 81 jar.manifest { 82 attributes ('BoringSSL-Version': boringSslVersion, 83 'Automatic-Module-Name': 'org.conscrypt', 84 'Bundle-SymbolicName': 'org.conscrypt', 85 '-exportcontents': 'org.conscrypt.*') 86 } 87 88 apply from: "$rootDir/gradle/publishing.gradle" 89 publishing.publications.maven { 90 artifact sourcesJar 91 artifact javadocJar 92 artifact jar 93 } 94} else { 95 // Not building an uber jar - disable all tasks. 96 tasks.configureEach { 97 it.enabled = false 98 } 99} 100