|
| 1 | +apply plugin: 'maven-publish' |
| 2 | +apply plugin: 'signing' |
| 3 | +if (project.hasProperty("kotlin")) { |
| 4 | + apply plugin: "org.jetbrains.dokka" |
| 5 | +} |
| 6 | + |
| 7 | +task androidSourcesJar(type: Jar) { |
| 8 | + archiveClassifier.set('sources') |
| 9 | + if (project.plugins.findPlugin("com.android.library")) { |
| 10 | + // For Android libraries |
| 11 | + from android.sourceSets.main.java.srcDirs |
| 12 | + if (project.hasProperty("kotlin")) { |
| 13 | + from android.sourceSets.main.kotlin.srcDirs |
| 14 | + } |
| 15 | + } else { |
| 16 | + // For pure Kotlin libraries, in case you have them |
| 17 | + from sourceSets.main.java.srcDirs |
| 18 | + if (project.hasProperty("kotlin")) { |
| 19 | + from sourceSets.main.kotlin.srcDirs |
| 20 | + } |
| 21 | + |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +if (project.hasProperty("kotlin")) { |
| 26 | + tasks.withType(dokkaHtmlPartial.getClass()).configureEach { |
| 27 | + pluginsMapConfiguration.set( |
| 28 | + ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""] |
| 29 | + ) |
| 30 | + } |
| 31 | + task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { |
| 32 | + archiveClassifier.set('javadoc') |
| 33 | + from dokkaJavadoc.outputDirectory |
| 34 | + } |
| 35 | +} else { |
| 36 | + |
| 37 | + task javadoc(type: Javadoc) { |
| 38 | + options.encoding "UTF-8" |
| 39 | + options.charSet 'UTF-8' |
| 40 | + source = android.sourceSets.main.java.srcDirs |
| 41 | + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) |
| 42 | + options.links("http://docs.oracle.com/javase/7/docs/api/"); |
| 43 | + options.linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference" |
| 44 | + exclude '**/BuildConfig.java' |
| 45 | + exclude '**/R.java' |
| 46 | + failOnError = false |
| 47 | + } |
| 48 | + task javadocJar(type: Jar, dependsOn: javadoc) { |
| 49 | + classifier = 'javadoc' |
| 50 | + from javadoc.destinationDir |
| 51 | + } |
| 52 | + |
| 53 | + tasks.withType(Javadoc) { |
| 54 | + options.addStringOption('Xdoclint:none', '-quiet') |
| 55 | + options.addStringOption('encoding', 'UTF-8') |
| 56 | + options.addStringOption('charSet ', 'UTF-8') |
| 57 | + options { |
| 58 | + encoding "UTF-8" |
| 59 | + charSet 'UTF-8' |
| 60 | + links "http://docs.oracle.com/javase/7/docs/api" |
| 61 | + } |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | + |
| 66 | +artifacts { |
| 67 | + archives androidSourcesJar |
| 68 | + archives javadocJar |
| 69 | +} |
| 70 | + |
| 71 | +group = PUBLISH_GROUP_ID |
| 72 | +version = PUBLISH_VERSION |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +afterEvaluate { |
| 79 | + publishing { |
| 80 | + publications { |
| 81 | + release(MavenPublication) { |
| 82 | + groupId PUBLISH_GROUP_ID |
| 83 | + artifactId PUBLISH_ARTIFACT_ID |
| 84 | + version PUBLISH_VERSION |
| 85 | + // Two artifacts, the `aar` (or `jar`) and the sources |
| 86 | + if (project.plugins.findPlugin("com.android.library")) { |
| 87 | + from components.release |
| 88 | + } else { |
| 89 | + from components.java |
| 90 | + } |
| 91 | + artifact androidSourcesJar |
| 92 | + artifact javadocJar |
| 93 | + |
| 94 | + // Mostly self-explanatory metadata |
| 95 | + pom { |
| 96 | + name = POM_NAME |
| 97 | + description = POM_DESCRIPTION |
| 98 | + url = POM_URL |
| 99 | + licenses { |
| 100 | + license { |
| 101 | + name = POM_LICENCE_NAME |
| 102 | + url = POM_LICENCE_URL |
| 103 | + } |
| 104 | + } |
| 105 | + developers { |
| 106 | + developer { |
| 107 | + id = POM_DEVELOPER_ID |
| 108 | + name = POM_DEVELOPER_NAME |
| 109 | + email = POM_DEVELOPER_EMAIL |
| 110 | + } |
| 111 | + // Add all other devs here... |
| 112 | + } |
| 113 | + |
| 114 | + // Version control info - if you're using GitHub, follow the |
| 115 | + // format as seen here |
| 116 | + scm { |
| 117 | + connection = POM_SCM_CONNECTION |
| 118 | + developerConnection = POM_SCM_DEV_CONNECTION |
| 119 | + url = POM_SCM_URL |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | + } |
| 124 | + } |
| 125 | +} |
| 126 | + |
| 127 | +ext["signing.keyId"] = rootProject.ext["signing.keyId"] |
| 128 | +ext["signing.password"] = rootProject.ext["signing.password"] |
| 129 | +ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] |
| 130 | +signing { |
| 131 | + sign publishing.publications |
| 132 | +} |
| 133 | + |
0 commit comments