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-02-16 22:58:16 +03:00
|
|
|
signing
|
2021-08-07 20:05:08 +03:00
|
|
|
`version-catalog`
|
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
|
|
|
}
|
|
|
|
|
2022-07-29 14:46:22 +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
|
|
|
|
2022-07-29 14:46: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 {
|
2021-02-21 12:11:54 +03:00
|
|
|
create("project") {
|
2022-07-29 14:46:22 +03:00
|
|
|
id = "space.kscience.gradle.project"
|
2022-03-07 16:41:56 +03:00
|
|
|
description = "The root plugin for multi-module project infrastructure"
|
2022-07-29 14:46:22 +03:00
|
|
|
implementationClass = "space.kscience.gradle.KScienceProjectPlugin"
|
2020-09-10 11:38:57 +03:00
|
|
|
}
|
2020-11-27 15:10:15 +03:00
|
|
|
|
2021-02-21 12:11:54 +03:00
|
|
|
create("mpp") {
|
2022-07-29 14:46:22 +03:00
|
|
|
id = "space.kscience.gradle.mpp"
|
2019-06-28 16:22:11 +03:00
|
|
|
description = "Pre-configured multiplatform project"
|
2022-07-29 14:46:22 +03:00
|
|
|
implementationClass = "space.kscience.gradle.KScienceMPPlugin"
|
2019-06-28 16:22:11 +03:00
|
|
|
}
|
2019-07-21 17:40:08 +03:00
|
|
|
|
2021-02-21 12:11:54 +03:00
|
|
|
create("jvm") {
|
2022-07-29 14:46:22 +03:00
|
|
|
id = "space.kscience.gradle.jvm"
|
2019-07-21 17:40:08 +03:00
|
|
|
description = "Pre-configured JVM project"
|
2022-07-29 14:46:22 +03:00
|
|
|
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") {
|
2022-07-29 14:46:22 +03:00
|
|
|
group = "publishing"
|
2023-09-12 21:04:29 +03:00
|
|
|
val versionFileProvider = project.layout.buildDirectory.file("project-version.txt")
|
|
|
|
outputs.file(versionFileProvider)
|
2022-07-10 13:39:35 +03:00
|
|
|
doLast {
|
2023-09-12 21:04:29 +03:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
|
|
|
publishing {
|
2023-09-12 21:19:05 +03:00
|
|
|
val vcs = "https://github.com/SciProgCentre/gradle-tools"
|
2023-03-12 12:15:20 +03:00
|
|
|
|
|
|
|
// Process each publication we have in this project
|
|
|
|
publications {
|
|
|
|
create<MavenPublication>("catalog") {
|
|
|
|
from(components["versionCatalog"])
|
|
|
|
artifactId = "version-catalog"
|
|
|
|
|
|
|
|
pom {
|
|
|
|
name.set("version-catalog")
|
2021-08-07 20:05:08 +03:00
|
|
|
}
|
2023-03-12 12:15:20 +03:00
|
|
|
}
|
2019-06-28 16:22:11 +03:00
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
withType<MavenPublication> {
|
|
|
|
// thanks @vladimirsitnikv for the fix
|
|
|
|
artifact(if (name == "catalog") emptySourcesJar else sourcesJar)
|
|
|
|
artifact(if (name == "catalog") emptyJavadocJar else javadocsJar)
|
2019-06-28 16:22:11 +03:00
|
|
|
|
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
pom {
|
|
|
|
name.set(project.name)
|
|
|
|
description.set(project.description)
|
|
|
|
url.set(vcs)
|
2021-08-06 05:41:03 +03:00
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
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-02-16 22:58:16 +03:00
|
|
|
}
|
2023-03-12 12:15:20 +03:00
|
|
|
}
|
2021-08-06 05:41:03 +03:00
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
developers {
|
|
|
|
developer {
|
2023-09-12 21:19:05 +03:00
|
|
|
id.set("SPC")
|
|
|
|
name.set("Scientific Programming Centre")
|
|
|
|
organization.set("SPC")
|
|
|
|
organizationUrl.set("https://sciprog.center/")
|
2021-02-16 22:58:16 +03:00
|
|
|
}
|
|
|
|
}
|
2023-03-12 12:15:20 +03:00
|
|
|
|
|
|
|
scm {
|
|
|
|
url.set(vcs)
|
|
|
|
tag.set(project.version.toString())
|
|
|
|
}
|
2019-06-28 16:22:11 +03:00
|
|
|
}
|
|
|
|
}
|
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) {
|
2023-03-12 12:15:20 +03:00
|
|
|
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
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String
|
|
|
|
val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String
|
2021-02-16 18:19:22 +03:00
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
if (sonatypeUser != null && sonatypePassword != null) {
|
|
|
|
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
|
|
|
|
"https://oss.sonatype.org/content/repositories/snapshots"
|
|
|
|
} else {
|
|
|
|
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
|
|
|
}
|
2021-02-17 10:14:16 +03:00
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
repositories.maven {
|
|
|
|
name = "sonatype"
|
|
|
|
url = uri(sonatypeRepo)
|
2021-09-28 12:15:13 +03:00
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
credentials {
|
|
|
|
username = sonatypeUser
|
|
|
|
password = sonatypePassword
|
2021-02-21 12:11:54 +03:00
|
|
|
}
|
2023-03-12 12:15:20 +03:00
|
|
|
}
|
2021-02-17 10:14:16 +03:00
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
signing {
|
|
|
|
//useGpgCmd()
|
|
|
|
sign(publications)
|
2021-02-17 10:14:16 +03:00
|
|
|
}
|
2021-02-16 22:58:16 +03:00
|
|
|
}
|
2021-02-21 12:11:54 +03:00
|
|
|
}
|
2021-09-12 19:32:35 +03:00
|
|
|
|
2023-03-12 12:15:20 +03:00
|
|
|
kotlin {
|
2024-08-26 10:21:27 +03:00
|
|
|
explicitApiWarning()
|
|
|
|
jvmToolchain(17)
|
2022-03-07 16:41:56 +03:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|