aboutsummaryrefslogtreecommitdiff
path: root/gradle/publishing.gradle
blob: 6bb5f1a24dc66292a6efa708922257443be201fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
apply plugin: 'maven-publish'

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from 'build/javadoc'
}

task sourceJar(type: Jar) {
    from sourceSets.main.allSource
}

publishing {
    publications {
        javaLibrary(MavenPublication) {
            artifactId 'mockito-kotlin'

            from components.java

            artifact sourceJar {
                classifier "sources"
            }

            artifact javadocJar

            pom.withXml {
                def root = asNode()
                root.appendNode('name', 'Mockito-Kotlin')
                root.appendNode('description', 'Using Mockito with Kotlin.')
                root.appendNode('url', 'https://github.com/mockito/mockito-kotlin')

                def scm = root.appendNode('scm')
                scm.appendNode('url', 'scm:git@github.com:mockito/mockito-kotlin.git')

                def licenses = root.appendNode('licenses')
                def mitLicense = licenses.appendNode('license')
                mitLicense.appendNode('name', 'MIT')

                def developers = root.appendNode('developers')
                def nhaarman = developers.appendNode('developer')
                nhaarman.appendNode('id', 'nhaarman')
                nhaarman.appendNode('name', 'Niek Haarman')
            }
        }
    }

    //useful for testing - running "publish" will create artifacts/pom in a local dir
    repositories { maven { url = "$rootProject.buildDir/repo" } }
}

clean {
    delete "$rootProject.buildDir/repo"
}

// Avoid generation of the module metadata so that we don't have to publish an additional file
// and keep the build logic simple.
tasks.withType(GenerateModuleMetadata) {
    enabled = false
}

//fleshes out problems with Maven pom generation when building
tasks.build.dependsOn('publishJavaLibraryPublicationToMavenLocal')

apply plugin: 'signing' //https://docs.gradle.org/current/userguide/signing_plugin.html
signing {
    if (System.getenv("PGP_KEY")) {
        useInMemoryPgpKeys(System.getenv("PGP_KEY"), System.getenv("PGP_PWD"))
        sign publishing.publications.javaLibrary
    }
}