gradle-tools/build.gradle.kts

205 lines
6.2 KiB
Plaintext
Raw Normal View History

2019-06-28 16:22:11 +03:00
plugins {
2021-08-07 20:05:08 +03:00
alias(libs.plugins.changelog)
alias(libs.plugins.dokka)
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`
2019-06-28 16:22:11 +03:00
}
2020-08-20 10:02:28 +03:00
group = "ru.mipt.npm"
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 DataForge and kscience 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
}
2021-08-06 05:41:03 +03:00
java.targetCompatibility = JavaVersion.VERSION_11
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.atomicfu.gradle)
implementation(libs.binary.compatibility.validator)
implementation(libs.changelog.gradle)
implementation(libs.dokka.gradle)
implementation(libs.kotlin.jupyter.gradle)
implementation(libs.kotlin.serialization)
2021-09-13 22:49:41 +03:00
implementation("org.tomlj:tomlj:1.0.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
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("common") {
id = "ru.mipt.npm.gradle.common"
2020-11-25 12:16:09 +03:00
description = "The generalized kscience plugin that works in conjunction with any kotlin plugin"
implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin"
}
create("project") {
id = "ru.mipt.npm.gradle.project"
2020-09-22 16:21:09 +03:00
description = "The root plugin for multimodule project infrastructure"
2020-09-25 09:55:01 +03:00
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
2020-09-10 11:38:57 +03:00
}
create("mpp") {
id = "ru.mipt.npm.gradle.mpp"
2019-06-28 16:22:11 +03:00
description = "Pre-configured multiplatform project"
2020-08-20 10:02:28 +03:00
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
2019-06-28 16:22:11 +03:00
}
2019-07-21 17:40:08 +03:00
create("jvm") {
id = "ru.mipt.npm.gradle.jvm"
2019-07-21 17:40:08 +03:00
description = "Pre-configured JVM project"
2020-08-20 10:02:28 +03:00
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
2019-07-21 17:40:08 +03:00
}
create("js") {
id = "ru.mipt.npm.gradle.js"
2019-07-21 17:40:08 +03:00
description = "Pre-configured JS project"
2020-08-20 10:02:28 +03:00
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
}
create("native") {
id = "ru.mipt.npm.gradle.native"
2020-08-20 10:02:28 +03:00
description = "Additional native targets to be use alongside mpp"
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
}
2020-09-30 20:43:02 +03:00
create("node") {
id = "ru.mipt.npm.gradle.node"
2020-09-30 20:43:02 +03:00
description = "Additional nodejs target to be use alongside mpp"
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
}
2019-06-28 16:22:11 +03:00
}
}
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)
}
afterEvaluate {
publishing {
val vcs = "https://github.com/mipt-npm/gradle-tools"
2021-02-16 22:58:16 +03:00
2021-08-07 20:05:08 +03:00
// Process each publication we have in this project
publications {
create<MavenPublication>("catalog") {
from(components["versionCatalog"])
this.artifactId = "version-catalog"
2021-02-16 22:58:16 +03:00
2021-08-07 20:05:08 +03:00
pom {
name.set("version-catalog")
}
}
2019-06-28 16:22:11 +03:00
2021-08-07 20:05:08 +03:00
withType<MavenPublication> {
artifact(sourcesJar)
artifact(javadocsJar)
2019-06-28 16:22:11 +03:00
pom {
description.set(project.description)
url.set(vcs)
2019-06-28 16:22:11 +03:00
licenses {
license {
name.set("The Apache Software License, Version 2.0")
2021-08-06 05:41:03 +03:00
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
2021-08-06 05:41:03 +03:00
developers {
developer {
id.set("MIPT-NPM")
name.set("MIPT nuclear physics methods laboratory")
organization.set("MIPT")
2021-08-06 05:41:03 +03:00
organizationUrl.set("https://npm.mipt.ru")
}
2021-02-16 22:58:16 +03:00
}
2021-08-06 05:41:03 +03:00
scm {
url.set(vcs)
tag.set(project.version.toString())
2021-02-16 22:58:16 +03:00
}
}
2019-06-28 16:22:11 +03:00
}
}
2021-08-06 05:41:03 +03:00
val spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
2021-03-07 09:22:48 +03:00
val spaceUser: String? = project.findProperty("publishing.space.user") as? String
val spaceToken: String? = project.findProperty("publishing.space.token") as? String
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
2021-08-06 05:41:03 +03:00
repositories.maven {
name = "space"
url = uri(spaceRepo)
credentials {
username = spaceUser
password = spaceToken
}
2021-02-17 10:14:16 +03:00
}
}
2021-03-07 09:22:48 +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
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
if (plugins.findPlugin("signing") == null) {
apply<SigningPlugin>()
}
2021-02-17 10:14:16 +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
tasks.processResources.configure {
2021-09-13 22:49:41 +03:00
duplicatesStrategy = org.gradle.api.file.DuplicatesStrategy.INCLUDE
2021-09-12 19:32:35 +03:00
from("gradle/libs.versions.toml")
}