aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: ba425e9585eaf4d5103a108fafa1a5c3cdc4a4c5 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
plugins {
    id "com.jfrog.bintray" version "1.4"
}

allprojects {
    buildscript {
        repositories {
            mavenCentral()
            jcenter()
            maven {
                url "https://dl.bintray.com/kotlin/kotlin-eap"
            }
            maven {
                url "https://dl.bintray.com/kotlin/kotlin-dev"
            }
        }
    }

    repositories {
        mavenCentral()
        maven {
            url "https://dl.bintray.com/kotlin/kotlin-eap"
        }
        maven {
            url "https://dl.bintray.com/kotlin/kotlin-dev"
        }
    }
}

apply plugin: 'maven-publish'

task updatePom << {
    def parser = new XmlParser()
    def pomFile = new File("maven-plugin/pom.xml")
    def pom = parser.parse(pomFile)
    pom.version[0].setValue(dokka_version)
    pom.properties.kotlinVersion[0].setValue(kotlin_version)
    pomFile.setText(groovy.xml.XmlUtil.serialize(pom))
}

task buildMavenPlugin << {
    def process = "mvn clean package".execute(null, new File("maven-plugin"))
    process.waitFor()
    def mvnOutput = process.text
    def exitValue = process.exitValue()
    if (exitValue != 0) {
        throw new IOException("Failed to run Maven command: exit value $exitValue, output $mvnOutput")
    }
}

task prepareMavenPluginUpload << {
    def uploadDir = new File("maven-plugin/upload")
    uploadDir.delete()
    uploadDir.mkdirs()
    def releaseFileName = "dokka-maven-plugin-${dokka_version}"
    new File("maven-plugin/target/${releaseFileName}.jar").renameTo(new File(uploadDir, "${releaseFileName}.jar"))
    new File(uploadDir, "${releaseFileName}.pom").bytes = new File("maven-plugin/pom.xml").bytes
}

buildMavenPlugin.dependsOn(updatePom)

bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')

    pkg {
        repo = dokka_eap.toBoolean() ? 'kotlin-eap' : 'dokka'
        name = 'dokka'
        userOrg = 'kotlin'
        desc = 'Dokka, the Kotlin documentation tool'
        vcsUrl = 'https://github.com/kotlin/dokka.git'
        licenses = ['Apache-2.0']
        version {
            name = dokka_version
        }
    }

    filesSpec {
        from 'maven-plugin/upload'
        into "/kotlin/${dokka_eap.toBoolean() ? 'kotlin-eap' : 'dokka'}/dokka/${dokka_version}/org/jetbrains/dokka/dokka-maven-plugin/${dokka_version}"
    }
}