|
| 1 | +// Ideally AGP should provide sources and javadoc integration for their components: |
| 2 | +// https://issuetracker.google.com/issues/145670440 |
| 3 | +tasks.register("sourcesJar", Jar) { |
| 4 | + classifier 'sources' |
| 5 | + from android.sourceSets.main.java.srcDirs |
| 6 | +} |
| 7 | + |
| 8 | +tasks.register("javadoc", Javadoc) { |
| 9 | + failOnError false |
| 10 | + source = android.sourceSets.main.java.srcDirs |
| 11 | + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) |
| 12 | +} |
| 13 | + |
| 14 | +tasks.register("javadocJar", Jar) { |
| 15 | + dependsOn javadoc |
| 16 | + classifier 'javadoc' |
| 17 | + from javadoc.destinationDir |
| 18 | +} |
| 19 | + |
| 20 | +// AGP creates the components in afterEvaluate, so we need to use it too |
| 21 | +// https://developer.android.com/studio/build/maven-publish-plugin |
| 22 | +afterEvaluate { |
| 23 | + publishing { |
| 24 | + publications { |
| 25 | + maven(MavenPublication) { |
| 26 | + from components.release |
| 27 | + |
| 28 | + artifact sourcesJar |
| 29 | + artifact javadocJar |
| 30 | + |
| 31 | + pom { |
| 32 | + name = 'Spyglass' |
| 33 | + description = 'Flexible library extending EditText to support mentions on Android.' |
| 34 | + url = 'https://github.com/linkedin/Spyglass' |
| 35 | + licenses { |
| 36 | + license { |
| 37 | + name = 'The Apache Software License, Version 2.0' |
| 38 | + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 39 | + } |
| 40 | + } |
| 41 | + developers { |
| 42 | + developer { |
| 43 | + id = 'com.linkedin' |
| 44 | + name = 'LinkedIn Corp' |
| 45 | + } |
| 46 | + } |
| 47 | + scm { |
| 48 | + connection = 'scm:git:git://github.com/linkedin/Spyglass.git' |
| 49 | + developerConnection = 'scm:git:ssh://github.com:linkedin/Spyglass.git' |
| 50 | + url = 'https://github.com/linkedin/Spyglass/tree/master' |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + repositories { |
| 55 | + def sonatypeUsername = System.getenv("SONATYPE_USER") |
| 56 | + def sonatypePassword = System.getenv("SONATYPE_PASSWORD") |
| 57 | + maven { |
| 58 | + name = "sonatypeSnapshot" |
| 59 | + url = "https://oss.sonatype.org/content/repositories/snapshots" |
| 60 | + credentials { |
| 61 | + username = sonatypeUsername |
| 62 | + password = sonatypePassword |
| 63 | + } |
| 64 | + } |
| 65 | + maven { |
| 66 | + name = "mavenCentral" |
| 67 | + url = "https://oss.sonatype.org/service/local/staging/deploy/maven2" |
| 68 | + credentials { |
| 69 | + username = sonatypeUsername |
| 70 | + password = sonatypePassword |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + // SPYGLASS_GPG_PRIVATE_KEY should contain the armoured private key that |
| 79 | + // starts with -----BEGIN PGP PRIVATE KEY BLOCK----- |
| 80 | + // It can be obtained with gpg --armour --export-secret-keys KEY_ID |
| 81 | + def signingKey = System.getenv("SPYGLASS_GPG_PRIVATE_KEY") |
| 82 | + def signingPassword = System.getenv("SPYGLASS_GPG_PRIVATE_KEY_PASSWORD") |
| 83 | + signing { |
| 84 | + required { signingKey != null && signingPassword != null } |
| 85 | + useInMemoryPgpKeys(signingKey, signingPassword) |
| 86 | + sign publishing.publications.maven |
| 87 | + } |
| 88 | +} |
0 commit comments