gradle-tools/build.gradle.kts

187 lines
5.3 KiB
Plaintext
Raw Permalink Normal View History

2019-06-28 16:22:11 +03:00
plugins {
2020-09-05 14:17:04 +03:00
`java-gradle-plugin`
2019-06-28 16:22:11 +03:00
`kotlin-dsl`
`maven-publish`
2021-08-07 20:05:08 +03:00
`version-catalog`
2024-12-09 09:22:00 +03:00
alias(libs.plugins.maven.publish)
2024-05-25 21:50:51 +03:00
alias(libs.plugins.jetbrains.changelog)
alias(libs.plugins.jetbrains.dokka)
2024-07-25 09:48:40 +03:00
alias(libs.plugins.versions)
alias(libs.plugins.versions.update)
2024-12-19 20:45:45 +03:00
alias(libs.plugins.maven.publish.base)
2019-06-28 16:22:11 +03:00
}
group = "space.kscience"
2021-08-07 20:05:08 +03:00
version = libs.versions.tools.get()
2021-02-16 18:19:22 +03:00
description = "Build tools for kotlin for science projects"
2019-06-28 16:22:11 +03:00
2021-08-06 05:41:03 +03:00
changelog.version.set(project.version.toString())
2021-04-26 19:17:11 +03:00
2019-06-28 16:22:11 +03:00
repositories {
2021-04-14 18:18:53 +03:00
mavenCentral()
2019-06-28 16:22:11 +03:00
gradlePluginPortal()
2021-02-19 21:25:05 +03:00
maven("https://repo.kotlin.link")
2019-06-28 16:22:11 +03:00
}
dependencies {
2024-12-19 20:45:45 +03:00
api("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.asProvider().get()}")
api("org.gradle.toolchains:foojay-resolver:0.9.0")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.15.0-Beta.3")
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:${libs.versions.changelog.get()}")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${libs.versions.dokka.get()}")
implementation("org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin:${libs.versions.kotlin.jupyter.get()}")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.30.0")
2022-06-12 14:46:28 +03:00
implementation(libs.kotlin.serialization)
2021-11-04 12:59:13 +03:00
implementation(libs.kotlinx.html)
2024-05-22 21:24:37 +03:00
implementation(libs.tomlj)
2021-09-28 12:12:03 +03:00
// // nexus publishing plugin
2024-05-22 21:24:37 +03:00
// implementation("io.github.gradle-nexus:publish-plugin:_")
2021-09-13 22:49:41 +03:00
2024-05-22 21:24:37 +03:00
implementation(libs.freemarker)
2022-01-23 14:37:19 +03:00
2021-09-13 22:49:41 +03:00
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
2019-06-28 16:22:11 +03:00
}
2021-09-12 19:32:35 +03:00
//declaring exported plugins
2021-08-06 05:41:03 +03:00
gradlePlugin {
2019-06-28 16:22:11 +03:00
plugins {
create("project") {
id = "space.kscience.gradle.project"
description = "The root plugin for multi-module project infrastructure"
implementationClass = "space.kscience.gradle.KScienceProjectPlugin"
2020-09-10 11:38:57 +03:00
}
create("mpp") {
id = "space.kscience.gradle.mpp"
2019-06-28 16:22:11 +03:00
description = "Pre-configured multiplatform project"
implementationClass = "space.kscience.gradle.KScienceMPPlugin"
2019-06-28 16:22:11 +03:00
}
2019-07-21 17:40:08 +03:00
create("jvm") {
id = "space.kscience.gradle.jvm"
2019-07-21 17:40:08 +03:00
description = "Pre-configured JVM project"
implementationClass = "space.kscience.gradle.KScienceJVMPlugin"
2019-07-21 17:40:08 +03:00
}
2019-06-28 16:22:11 +03:00
}
}
2022-07-10 13:39:35 +03:00
tasks.create("version") {
group = "publishing"
val versionFileProvider = project.layout.buildDirectory.file("project-version.txt")
outputs.file(versionFileProvider)
2022-07-10 13:39:35 +03:00
doLast {
val versionFile = versionFileProvider.get().asFile
2022-07-10 13:39:35 +03:00
versionFile.createNewFile()
versionFile.writeText(project.version.toString())
}
}
2021-09-12 19:32:35 +03:00
//publishing version catalog
catalog.versionCatalog {
from(files("gradle/libs.versions.toml"))
}
//publishing the artifact
2024-12-09 09:22:00 +03:00
mavenPublishing {
2024-12-09 09:47:28 +03:00
configure(
com.vanniktech.maven.publish.GradlePlugin(
javadocJar = com.vanniktech.maven.publish.JavadocJar.Dokka("dokkaHtml"),
sourcesJar = true,
)
)
2024-12-19 20:45:45 +03:00
publishing.publications.create<MavenPublication>("version-catalog") {
from(components["versionCatalog"])
artifactId = "version-catalog"
pom {
name.set("version-catalog")
}
2024-12-09 09:47:28 +03:00
}
2024-12-09 09:22:00 +03:00
val vcs = "https://git.sciprog.center/kscience/gradle-tools"
2023-03-12 12:15:20 +03:00
2024-12-09 09:22:00 +03:00
pom {
name.set(project.name)
description.set(project.description)
url.set(vcs)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
2021-08-07 20:05:08 +03:00
}
2023-03-12 12:15:20 +03:00
}
2019-06-28 16:22:11 +03:00
2024-12-09 09:22:00 +03:00
developers {
developer {
id.set("SPC")
name.set("Scientific Programming Centre")
organization.set("SPC")
organizationUrl.set("https://sciprog.center/")
2019-06-28 16:22:11 +03:00
}
}
2024-12-09 09:22:00 +03:00
scm {
url.set(vcs)
tag.set(project.version.toString())
}
2023-03-12 12:15:20 +03:00
}
2019-06-28 16:22:11 +03:00
2023-09-12 21:19:05 +03:00
val spaceRepo = "https://maven.sciprog.center/kscience"
val spcUser: String? = findProperty("publishing.spc.user") as? String
val spcToken: String? = findProperty("publishing.spc.token") as? String
2021-02-17 10:14:16 +03:00
2023-09-12 21:19:05 +03:00
if (spcUser != null && spcToken != null) {
2024-12-09 09:22:00 +03:00
publishing.repositories.maven {
2023-09-12 21:19:05 +03:00
name = "spc"
2023-03-12 12:15:20 +03:00
url = uri(spaceRepo)
2021-08-06 05:41:03 +03:00
2023-03-12 12:15:20 +03:00
credentials {
2023-09-12 21:19:05 +03:00
username = spcUser
password = spcToken
2021-02-17 10:14:16 +03:00
}
}
2023-03-12 12:15:20 +03:00
}
2021-02-17 10:14:16 +03:00
2024-12-09 09:22:00 +03:00
val centralUser: String? = project.findProperty("mavenCentralUsername") as? String
val centralPassword: String? = project.findProperty("mavenCentralPassword") as? String
2024-12-09 09:22:00 +03:00
if (centralUser != null && centralPassword != null) {
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
2021-02-16 22:58:16 +03:00
}
}
2021-09-12 19:32:35 +03:00
2023-03-12 12:15:20 +03:00
kotlin {
explicitApiWarning()
jvmToolchain(17)
}
2021-09-12 19:32:35 +03:00
tasks.processResources.configure {
2021-11-04 12:59:13 +03:00
duplicatesStrategy = DuplicatesStrategy.INCLUDE
2021-09-12 19:32:35 +03:00
from("gradle/libs.versions.toml")
2023-03-12 12:15:20 +03:00
}
// Workaround for https://github.com/gradle/gradle/issues/15568
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(tasks.withType<Sign>())
2024-05-22 21:24:37 +03:00
}
versionCatalogUpdate {
2024-07-25 09:48:40 +03:00
sortByKey.set(false)
2024-05-22 21:24:37 +03:00
keep {
keepUnusedVersions = true
keepUnusedPlugins = true
keepUnusedLibraries = true
}
}