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,osx-aarch_64,linux-x86_64,windows-x86_64')).split(',') 7 classesDir = "${buildDir}/classes" 8 resourcesDir = "${buildDir}/resources" 9 sourcesDir = "${buildDir}/sources" 10} 11 12if (buildUberJar) { 13 apply plugin: libs.plugins.bnd.get().pluginId 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 duplicatesStrategy = DuplicatesStrategy.EXCLUDE 47 } 48 tasks.named("jar").configure { 49 dependsOn copySharedLibs 50 } 51 52 /** 53 * Copy the object files to the classes directory. 54 */ 55 def copyClasses = tasks.register("copyClasses", Copy) { 56 dependsOn configurations.uberJar 57 from { 58 configurations.uberJar.collect { 59 zipTree(it) 60 } 61 } 62 exclude '/META-INF/**' 63 into file(classesDir) 64 duplicatesStrategy = DuplicatesStrategy.EXCLUDE 65 } 66 tasks.named("jar").configure { 67 dependsOn copyClasses 68 } 69 70 def copySources = tasks.register("copySources", Copy) { 71 dependsOn ":conscrypt-openjdk:sourcesJar" 72 from { 73 project(":conscrypt-openjdk").sourceSets.main.java 74 } 75 into file(sourcesDir) 76 duplicatesStrategy = DuplicatesStrategy.EXCLUDE 77 } 78 tasks.named("sourcesJar").configure { 79 dependsOn copySources 80 } 81 82 // Note that this assumes that the version of BoringSSL for each 83 // artifact exactly matches the one on the current system. 84 jar.manifest { 85 attributes ('BoringSSL-Version': boringSslVersion, 86 'Automatic-Module-Name': 'org.conscrypt', 87 'Bundle-SymbolicName': 'org.conscrypt', 88 '-exportcontents': 'org.conscrypt.*') 89 } 90 91 apply from: "$rootDir/gradle/publishing.gradle" 92 publishing.publications.maven { 93 artifact sourcesJar 94 artifact javadocJar 95 artifact jar 96 } 97} else { 98 // Not building an uber jar - disable all tasks. 99 tasks.configureEach { 100 it.enabled = false 101 } 102} 103