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