gradle-tools/build.gradle.kts

197 lines
5.1 KiB
Plaintext
Raw 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`
2024-12-09 09:22:00 +03:00
// signing
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)
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 {
2021-08-06 05:41:03 +03:00
api(libs.kotlin.gradle)
2024-05-22 21:24:37 +03:00
api(libs.foojay.resolver)
2021-08-06 05:41:03 +03:00
implementation(libs.binary.compatibility.validator)
implementation(libs.changelog.gradle)
implementation(libs.dokka.gradle)
implementation(libs.kotlin.jupyter.gradle)
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
2021-08-07 20:05:08 +03:00
val sourcesJar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.named("main").get().allSource)
}
val javadocsJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
2023-03-12 12:15:20 +03:00
val emptyJavadocJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveBaseName.set("empty")
archiveClassifier.set("javadoc")
}
val emptySourcesJar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
archiveBaseName.set("empty")
}
2024-12-09 09:22:00 +03:00
mavenPublishing {
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
}
2024-12-09 09:22:00 +03:00
configure(com.vanniktech.maven.publish.VersionCatalog())
}
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
}
}