1apply plugin: 'maven-publish' 2 3task javadocJar(type: Jar, dependsOn: javadoc) { 4 classifier = 'javadoc' 5 from 'build/javadoc' 6} 7 8task sourceJar(type: Jar) { 9 from sourceSets.main.allSource 10} 11 12publishing { 13 publications { 14 javaLibrary(MavenPublication) { 15 artifactId 'mockito-kotlin' 16 17 from components.java 18 19 artifact sourceJar { 20 classifier "sources" 21 } 22 23 artifact javadocJar 24 25 pom.withXml { 26 def root = asNode() 27 root.appendNode('name', 'Mockito-Kotlin') 28 root.appendNode('description', 'Using Mockito with Kotlin.') 29 root.appendNode('url', 'https://github.com/mockito/mockito-kotlin') 30 31 def scm = root.appendNode('scm') 32 scm.appendNode('url', 'scm:[email protected]:mockito/mockito-kotlin.git') 33 34 def licenses = root.appendNode('licenses') 35 def mitLicense = licenses.appendNode('license') 36 mitLicense.appendNode('name', 'MIT') 37 38 def developers = root.appendNode('developers') 39 def nhaarman = developers.appendNode('developer') 40 nhaarman.appendNode('id', 'nhaarman') 41 nhaarman.appendNode('name', 'Niek Haarman') 42 } 43 } 44 } 45 46 //useful for testing - running "publish" will create artifacts/pom in a local dir 47 repositories { maven { url = "$rootProject.buildDir/repo" } } 48} 49 50clean { 51 delete "$rootProject.buildDir/repo" 52} 53 54// Avoid generation of the module metadata so that we don't have to publish an additional file 55// and keep the build logic simple. 56tasks.withType(GenerateModuleMetadata) { 57 enabled = false 58} 59 60//fleshes out problems with Maven pom generation when building 61tasks.build.dependsOn('publishJavaLibraryPublicationToMavenLocal') 62 63apply plugin: 'signing' //https://docs.gradle.org/current/userguide/signing_plugin.html 64signing { 65 if (System.getenv("PGP_KEY")) { 66 useInMemoryPgpKeys(System.getenv("PGP_KEY"), System.getenv("PGP_PWD")) 67 sign publishing.publications.javaLibrary 68 } 69}