aboutsummaryrefslogtreecommitdiff
path: root/gradle/publishing.gradle
blob: e9e43720b1ae516db35a53a3aaab39dc570f3589 (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
/*
 * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

// Configures publishing of Maven artifacts to Bintray

apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

// todo: figure out how we can check it in a generic way
def isMultiplatform = project.name == 'atomicfu'

if (!isMultiplatform) {
    // Regular java modules need 'java-library' plugin for proper publication
    apply plugin: 'java-library'

    // MPP projects pack their sources automtically, java libraries need to explicitly pack them
    task sourcesJar(type: Jar) {
        archiveClassifier = 'sources'
        from "src/main/kotlin"
    }
}

// empty xxx-javadoc.jar
task javadocJar(type: Jar) {
    archiveClassifier = 'javadoc'
}

publishing {
    repositories { // this: closure
        PublishingKt.configureMavenPublication(delegate, project)
    }
    
    if (!isMultiplatform) {
        // Configure java publications for non-MPP projects
        publications {
            // plugin configures its own publication pluginMaven
            if (project.name == 'atomicfu-gradle-plugin') {
                pluginMaven(MavenPublication) {
                    artifact sourcesJar
                }
            } else {
                maven(MavenPublication) {
                    from components.java
                    artifact sourcesJar

                    if (project.name.endsWith("-maven-plugin")) {
                        pom.packaging = 'maven-plugin'
                    }
                }
            }
        }
    }

    publications.all {
        PublishingKt.configureMavenCentralMetadata(pom, project)
        PublishingKt.signPublicationIfKeyPresent(project, it)

        // add empty javadocs
        if (it.name != "kotlinMultiplatform") { // The root module gets the JVM's javadoc JAR
            it.artifact(javadocJar)
        }
    }
}