1description = 'Conscrypt: OpenJdk UberJAR' 2 3Directory buildTop = layout.buildDirectory.get() 4ext { 5 buildUberJar = Boolean.parseBoolean(System.getProperty('org.conscrypt.openjdk.buildUberJar', 'false')) 6 uberJarClassifiers = (System.getProperty('org.conscrypt.openjdk.uberJarClassifiers', 7 'osx-x86_64,osx-aarch_64,linux-x86_64,windows-x86_64')).split(',') 8 classesDir = buildTop.dir('classes') 9 resourcesDir = buildTop.dir('resources') 10 sourcesDir = buildTop.dir('sources') 11 javadocDir = buildTop.dir('docs/javadoc') 12} 13 14if (buildUberJar) { 15 apply plugin: libs.plugins.bnd.get().pluginId 16 17 configurations { 18 uberJar 19 } 20 21 // Point the jar task to the copied classes and resources directories. 22 jar { 23 from classesDir 24 from resourcesDir 25 from javadocDir 26 } 27 28 sourcesJar { 29 from sourcesDir 30 } 31 32 // Add the dependencies for the uber jar. 33 uberJarClassifiers.each { uberJarClassifier -> 34 dependencies.uberJar "${group}:conscrypt-openjdk:${version}:${uberJarClassifier}" 35 } 36 37 /** 38 * Copy the native libraries to the resources directory. 39 */ 40 def copySharedLibs = tasks.register("copySharedLibs", Copy) { 41 dependsOn configurations.uberJar 42 from { 43 configurations.uberJar.collect { 44 zipTree(it) 45 } 46 } 47 include '/META-INF/native/**' 48 into file(resourcesDir) 49 duplicatesStrategy = DuplicatesStrategy.EXCLUDE 50 } 51 tasks.named("jar").configure { 52 dependsOn copySharedLibs 53 } 54 55 /** 56 * Copy the object files to the classes directory. 57 */ 58 def copyClasses = tasks.register("copyClasses", Copy) { 59 dependsOn configurations.uberJar 60 from { 61 configurations.uberJar.collect { 62 zipTree(it) 63 } 64 } 65 exclude '/META-INF/**' 66 into file(classesDir) 67 duplicatesStrategy = DuplicatesStrategy.EXCLUDE 68 } 69 tasks.named("jar").configure { 70 dependsOn copyClasses 71 } 72 73 def copySources = tasks.register("copySources", Copy) { 74 dependsOn copyJavadocs 75 dependsOn ":conscrypt-constants:runGen" 76 from project(":conscrypt-openjdk").sourceSets.main.java 77 into file(sourcesDir) 78 duplicatesStrategy = DuplicatesStrategy.EXCLUDE 79 } 80 tasks.named("sourcesJar").configure { 81 dependsOn copySources 82 } 83 84 def copyJavadocs = tasks.register("copyJavadocs", Copy) { 85 dependsOn ':conscrypt-openjdk:javadoc' 86 from project(':conscrypt-openjdk').layout.buildDirectory 87 include('docs/**/*') 88 into layout.buildDirectory 89 duplicatesStrategy = DuplicatesStrategy.EXCLUDE 90 } 91 tasks.named('javadocJar').configure { 92 dependsOn copyJavadocs 93 } 94 tasks.named('jar').configure { 95 dependsOn copyJavadocs 96 } 97 98 // Note that this assumes that the version of BoringSSL for each 99 // artifact exactly matches the one on the current system. 100 jar.manifest { 101 attributes ('BoringSSL-Version': boringSslVersion, 102 'Automatic-Module-Name': 'org.conscrypt', 103 'Bundle-SymbolicName': 'org.conscrypt', 104 '-exportcontents': 'org.conscrypt.*') 105 } 106 107 apply from: "$rootDir/gradle/publishing.gradle" 108 publishing.publications.maven { 109 artifact sourcesJar 110 artifact javadocJar 111 artifact jar 112 } 113} else { 114 // Not building an uber jar - disable all tasks. 115 tasks.configureEach { 116 it.enabled = false 117 } 118} 119