1apply plugin: 'maven-publish' 2apply plugin: 'signing' 3 4def isSnapshot = project.version.contains('SNAPSHOT') 5 6publishing { 7 publications { 8 maven(MavenPublication) { 9 pom { 10 afterEvaluate { 11 name = "$project.group:$project.name" as String 12 description = project.description 13 } 14 15 url = 'https://conscrypt.org/' 16 17 scm { 18 connection = 'scm:git:https://github.com/google/conscrypt.git' 19 developerConnection = 'scm:git:git@github.com:google/conscrypt.git' 20 url = 'https://github.com/google/conscrypt' 21 } 22 23 licenses { 24 license { 25 name = 'Apache 2' 26 url = 'https://www.apache.org/licenses/LICENSE-2.0' 27 } 28 } 29 30 developers { 31 developer { 32 id = 'conscrypt' 33 name = 'Conscrypt Contributors' 34 email = 'conscrypt@googlegroups.com' 35 url = 'https://conscrypt.org/' 36 organization = 'Google, Inc.' 37 organizationUrl = 'https://www.google.com' 38 } 39 } 40 } 41 } 42 } 43 44 repositories { 45 maven { 46 def snapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' 47 def stagingUrl = rootProject.hasProperty('repositoryId') ? \ 48 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' \ 49 + rootProject.repositoryId : \ 50 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' 51 url isSnapshot ? snapshotUrl : stagingUrl 52 credentials { 53 username = rootProject.findProperty('ossrhUsername') ?: '' 54 password = rootProject.findProperty('ossrhPassword') ?: '' 55 } 56 } 57 } 58} 59 60signing { 61 required false 62 sign publishing.publications.maven 63} 64 65signMavenPublication.doFirst { 66 publishing.publications.maven.artifacts.each { 67 if (it.file.absolutePath.endsWith('.jar') && it.classifier != 'sources' && it.classifier != 'javadoc') { 68 logger.info("Signing jar: ${it.file.absolutePath}") 69 signJar(it.file.absolutePath) 70 } 71 } 72} 73