aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt
blob: 175bbd0bd43d6e321fe3313e361fb69583029c3d (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
package org.jetbrains

import org.gradle.api.Project
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository

fun Project.configureDistMaven() { // TODO: This can probably be written cleaner
    val repoLocation = uri(file("${rootProject.buildDir}/dist-maven"))
    var distMaven: MavenArtifactRepository? = null
    pluginManager.withPlugin("maven-publish") {
        this@configureDistMaven.extensions.findByType(PublishingExtension::class.java)?.repositories {
            distMaven = maven {
                name = "distMaven"
                url = repoLocation
            }
        }
    }
    tasks.register("publishToDistMaven") {
        group = "publishing"
        description = "Publishes all Maven publications to Maven repository 'distMaven'"
        dependsOn(tasks.withType(PublishToMavenRepository::class.java).matching {
            it.repository == distMaven
        })
    }
}