gradle-tools/build.gradle.kts

228 lines
6.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-02-16 22:58:16 +03:00
signing
2021-08-07 20:05:08 +03:00
`version-catalog`
2023-02-03 13:00:11 +03:00
alias(libs.plugins.changelog)
alias(libs.plugins.dokka)
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
}
kotlin.explicitApiWarning()
2019-06-28 16:22:11 +03:00
dependencies {
2021-08-06 05:41:03 +03:00
api(libs.kotlin.gradle)
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)
2023-02-03 13:00:11 +03:00
implementation("org.tomlj:tomlj:1.1.0")
2021-09-28 12:12:03 +03:00
// // nexus publishing plugin
// implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
2021-09-13 22:49:41 +03:00
2022-01-23 14:37:19 +03:00
implementation("org.freemarker:freemarker:2.3.31")
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
}
create("js") {
id = "space.kscience.gradle.js"
2019-07-21 17:40:08 +03:00
description = "Pre-configured JS project"
implementationClass = "space.kscience.gradle.KScienceJSPlugin"
2020-08-20 10:02:28 +03:00
}
2019-06-28 16:22:11 +03:00
}
}
2022-07-10 13:39:35 +03:00
tasks.create("version") {
group = "publishing"
2022-07-10 13:39:35 +03:00
val versionFile = project.buildDir.resolve("project-version.txt")
outputs.file(versionFile)
doLast {
versionFile.createNewFile()
versionFile.writeText(project.version.toString())
println(project.version)
}
}
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 {
val vcs = "https://github.com/mipt-npm/gradle-tools"
// 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 {
id.set("MIPT-NPM")
name.set("MIPT nuclear physics methods laboratory")
organization.set("MIPT")
organizationUrl.set("https://npm.mipt.ru")
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-03-12 12:15:20 +03:00
val spaceRepo = "https://maven.pkg.jetbrains.space/spc/p/sci/maven"
val spaceUser: String? = findProperty("publishing.space.user") as? String
val spaceToken: String? = findProperty("publishing.space.token") as? String
2023-03-12 12:15:20 +03:00
if (spaceUser != null && spaceToken != null) {
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
2021-02-17 10:14:16 +03:00
2023-03-12 12:15:20 +03:00
repositories.maven {
name = "space"
url = uri(spaceRepo)
2021-08-06 05:41:03 +03:00
2023-03-12 12:15:20 +03:00
credentials {
username = spaceUser
password = spaceToken
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)
2023-03-12 12:15:20 +03:00
credentials {
username = sonatypeUser
password = sonatypePassword
}
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-09-12 19:32:35 +03:00
2023-03-12 12:15:20 +03:00
kotlin {
jvmToolchain {
2023-02-03 13:00:11 +03:00
languageVersion.set(JavaLanguageVersion.of(11))
}
}
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>())
2021-09-12 19:32:35 +03:00
}