Compare commits

..

1 Commits

Author SHA1 Message Date
36dae25531 Merge pull request '0.15.8-kotlin-2.1.0' (!51) from dev into master
Reviewed-on: #51
2024-12-09 09:49:36 +03:00
6 changed files with 129 additions and 62 deletions

43
.space.kts Normal file
View File

@ -0,0 +1,43 @@
import kotlin.io.path.readText
job("Build") {
gradlew("openjdk:11", "build")
}
job("Publish"){
startOn {
gitPush { enabled = false }
}
container("openjdk:11") {
env["SPACE_USER"] = Secrets("space_user")
env["SPACE_TOKEN"] = Secrets("space_token")
kotlinScript { api ->
val spaceUser = System.getenv("SPACE_USER")
val spaceToken = System.getenv("SPACE_TOKEN")
// write version to the build directory
api.gradlew("version")
//read version from build file
val version = java.nio.file.Path.of("build/project-version.txt").readText()
api.space().projects.automation.deployments.start(
project = api.projectIdentifier(),
targetIdentifier = TargetIdentifier.Key("gradle-tools"),
version = version,
// automatically update deployment status based on a status of a job
syncWithAutomationJob = true
)
try {
api.gradlew(
"publishAllPublicationsToSpaceRepository",
"-Ppublishing.space.user=\"$spaceUser\"",
"-Ppublishing.space.token=\"$spaceToken\"",
)
} catch (ex: Exception) {
println("Publish failed")
}
}
}
}

View File

@ -9,8 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
### Changed ### Changed
- Kotlin 2.1.0
- Publication to central via `com.vanniktech.maven.publish.base`
### Deprecated ### Deprecated

View File

@ -1,14 +1,15 @@
plugins { plugins {
`java-gradle-plugin` `java-gradle-plugin`
`kotlin-dsl` `kotlin-dsl`
`maven-publish` `maven-publish`
// signing
`version-catalog` `version-catalog`
alias(libs.plugins.maven.publish) alias(libs.plugins.maven.publish)
alias(libs.plugins.jetbrains.changelog) alias(libs.plugins.jetbrains.changelog)
alias(libs.plugins.jetbrains.dokka) alias(libs.plugins.jetbrains.dokka)
alias(libs.plugins.versions) alias(libs.plugins.versions)
alias(libs.plugins.versions.update) alias(libs.plugins.versions.update)
alias(libs.plugins.maven.publish.base)
} }
group = "space.kscience" group = "space.kscience"
@ -25,13 +26,12 @@ repositories {
} }
dependencies { dependencies {
api("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.asProvider().get()}") api(libs.kotlin.gradle)
api("org.gradle.toolchains:foojay-resolver:0.9.0") api(libs.foojay.resolver)
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.15.0-Beta.3") implementation(libs.binary.compatibility.validator)
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:${libs.versions.changelog.get()}") implementation(libs.changelog.gradle)
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${libs.versions.dokka.get()}") implementation(libs.dokka.gradle)
implementation("org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin:${libs.versions.kotlin.jupyter.get()}") implementation(libs.kotlin.jupyter.gradle)
implementation("com.vanniktech:gradle-maven-publish-plugin:0.30.0")
implementation(libs.kotlin.serialization) implementation(libs.kotlin.serialization)
implementation(libs.kotlinx.html) implementation(libs.kotlinx.html)
implementation(libs.tomlj) implementation(libs.tomlj)
@ -89,6 +89,30 @@ catalog.versionCatalog {
} }
//publishing the artifact //publishing the artifact
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)
}
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")
}
mavenPublishing { mavenPublishing {
configure( configure(
com.vanniktech.maven.publish.GradlePlugin( com.vanniktech.maven.publish.GradlePlugin(
@ -97,13 +121,8 @@ mavenPublishing {
) )
) )
publishing.publications.create<MavenPublication>("version-catalog") { project.publishing.publications.create("maven", MavenPublication::class.java) {
from(components["versionCatalog"]) from(project.components.getByName("versionCatalog"))
artifactId = "version-catalog"
pom {
name.set("version-catalog")
}
} }
val vcs = "https://git.sciprog.center/kscience/gradle-tools" val vcs = "https://git.sciprog.center/kscience/gradle-tools"

View File

@ -1,8 +1,8 @@
[versions] [versions]
# @pin # @pin
kotlin = "2.1.20-Beta1" kotlin = "2.1.0"
# @pin # @pin
tools = "0.16.0-kotlin-2.1.20-Beta1" tools = "0.15.8-kotlin-2.1.0"
atomicfu = "0.26.1" atomicfu = "0.26.1"
changelog = "2.2.1" changelog = "2.2.1"
compose = "1.7.1" compose = "1.7.1"
@ -28,10 +28,9 @@ yamlkt = "0.13.0"
[plugins] [plugins]
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.30.0" } maven-publish = { id = "com.vanniktech.maven.publish", version = "0.30.0" }
maven-publish-base = { id = "com.vanniktech.maven.publish.base", version = "0.30.0" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
compose-jb = { id = "org.jetbrains.compose", version.ref = "compose" } compose-jb = { id = "org.jetbrains.compose", version.ref = "compose" }
jetbrains-changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } jetbrains-changelog = "org.jetbrains.changelog:2.2.1"
jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlin" } kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlin" }
@ -61,8 +60,21 @@ versions-update = "nl.littlerobots.version-catalog-update:0.8.5"
[libraries] [libraries]
atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu" } atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu" }
atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" }
binary-compatibility-validator = "org.jetbrains.kotlinx:binary-compatibility-validator:0.15.0-Beta.3"
changelog-gradle = { module = "org.jetbrains.intellij.plugins:gradle-changelog-plugin", version.ref = "changelog" }
dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka" }
dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
foojay-resolver = "org.gradle.toolchains:foojay-resolver:0.9.0"
freemarker = "org.freemarker:freemarker:2.3.33" freemarker = "org.freemarker:freemarker:2.3.33"
gradle-changelog-plugin = { module = "org.jetbrains.intellij.plugins:gradle-changelog-plugin", version.ref = "changelog" }
kotlin-assignment-compiler-plugin-embeddable = { module = "org.jetbrains.kotlin:kotlin-assignment-compiler-plugin-embeddable", version.ref = "kotlin" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-js-wrappers = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version.ref = "jsBom" } kotlin-js-wrappers = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version.ref = "jsBom" }
kotlin-jupyter-api-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin", version.ref = "kotlin" }
kotlin-jupyter-gradle = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin", version.ref = "kotlin-jupyter" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kotlin-sam-with-receiver-compiler-plugin-embeddable = { module = "org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin-embeddable", version.ref = "kotlin" } kotlin-sam-with-receiver-compiler-plugin-embeddable = { module = "org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin-embeddable", version.ref = "kotlin" }
kotlin-scripting-compiler-embeddable = { module = "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable", version.ref = "kotlin" } kotlin-scripting-compiler-embeddable = { module = "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable", version.ref = "kotlin" }

View File

@ -1,7 +1,5 @@
package space.kscience.gradle package space.kscience.gradle
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishBasePlugin
import kotlinx.validation.ApiValidationExtension import kotlinx.validation.ApiValidationExtension
import kotlinx.validation.BinaryCompatibilityValidatorPlugin import kotlinx.validation.BinaryCompatibilityValidatorPlugin
import org.gradle.api.Plugin import org.gradle.api.Plugin
@ -18,6 +16,7 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
import space.kscience.gradle.internal.addPublishing import space.kscience.gradle.internal.addPublishing
import space.kscience.gradle.internal.addSonatypePublishing
import space.kscience.gradle.internal.setupPublication import space.kscience.gradle.internal.setupPublication
/** /**
@ -70,32 +69,11 @@ public class KSciencePublishingExtension(public val project: Project) {
/** /**
* Adds Sonatype Maven repository to publishing. * Adds Sonatype Maven repository to publishing.
*/
public fun sonatype(sonatypeRoot: String = "https://s01.oss.sonatype.org"): Unit = with(project) {
require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" }
if (isInDevelopment) {
logger.info("Sonatype publishing skipped for development version")
} else {
addPublishing("sonatype", "$sonatypeRoot/service/local/staging/deploy/maven2")
}
}
/**
* Add publishing to maven central "new" API
*/ */
public fun central(): Unit = with(project) { public fun sonatype(sonatypeRoot: String = "https://s01.oss.sonatype.org") {
require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" } require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" }
if (isInDevelopment) { project.addSonatypePublishing(sonatypeRoot)
logger.info("Maven central publishing skipped for development version")
} else {
allprojects {
plugins.withType<MavenPublishBasePlugin> {
extensions.configure<MavenPublishBaseExtension> {
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL)
}
}
}
}
} }
} }
@ -109,9 +87,6 @@ public open class KScienceProjectPlugin : Plugin<Project> {
apply<DokkaPlugin>() apply<DokkaPlugin>()
apply<BinaryCompatibilityValidatorPlugin>() apply<BinaryCompatibilityValidatorPlugin>()
val ksciencePublish = KSciencePublishingExtension(this)
extensions.add("ksciencePublish", ksciencePublish)
allprojects { allprojects {
repositories { repositories {
mavenCentral() mavenCentral()
@ -138,6 +113,8 @@ public open class KScienceProjectPlugin : Plugin<Project> {
} }
val rootReadmeExtension = KScienceReadmeExtension(this) val rootReadmeExtension = KScienceReadmeExtension(this)
val ksciencePublish = KSciencePublishingExtension(this)
extensions.add("ksciencePublish", ksciencePublish)
extensions.add("readme", rootReadmeExtension) extensions.add("readme", rootReadmeExtension)
//Add readme generators to individual subprojects //Add readme generators to individual subprojects

View File

@ -1,14 +1,15 @@
package space.kscience.gradle.internal package space.kscience.gradle.internal
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishBasePlugin
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPom import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.* import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import space.kscience.gradle.isInDevelopment
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
?: System.getenv(propertyName) ?: System.getenv(propertyName)
@ -19,8 +20,6 @@ internal fun Project.requestProperty(propertyName: String): String = requestProp
internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit = {}) = allprojects { internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit = {}) = allprojects {
plugins.withId("maven-publish") { plugins.withId("maven-publish") {
apply<MavenPublishBasePlugin>()
configure<PublishingExtension> { configure<PublishingExtension> {
plugins.withId("org.jetbrains.kotlin.jvm") { plugins.withId("org.jetbrains.kotlin.jvm") {
@ -65,12 +64,22 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
} }
} }
//apply signing if signing configuration is available if (requestPropertyOrNull("publishing.signing.id") != null || requestPropertyOrNull("signing.gnupg.keyName") != null) {
if (requestPropertyOrNull("signing.password") != null || requestPropertyOrNull("signing.secretKeyRingFile") != null) {
plugins.withType<MavenPublishBasePlugin> { if (!plugins.hasPlugin("signing")) {
extensions.configure<MavenPublishBaseExtension> { apply<SigningPlugin>()
signAllPublications() }
}
extensions.configure<SigningExtension>("signing") {
val signingId: String? = requestPropertyOrNull("publishing.signing.id")
if (!signingId.isNullOrBlank()) {
val signingKey: String = requestProperty("publishing.signing.key")
val signingPassphrase: String = requestProperty("publishing.signing.passPhrase")
// if a key is provided, use it
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
} // else use agent signing
sign(publications)
} }
} else { } else {
logger.warn("Signing information is not provided. Skipping artefact signing.") logger.warn("Signing information is not provided. Skipping artefact signing.")
@ -81,9 +90,9 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
internal fun Project.addPublishing( internal fun Project.addPublishing(
repositoryName: String, repositoryName: String,
urlString: String urlString:String
) { ){
require(repositoryName.matches("\\w*".toRegex())) { "Repository name must contain only letters or numbers" } require(repositoryName.matches("\\w*".toRegex())){"Repository name must contain only letters or numbers"}
val user: String? = requestPropertyOrNull("publishing.$repositoryName.user") val user: String? = requestPropertyOrNull("publishing.$repositoryName.user")
val token: String? = requestPropertyOrNull("publishing.$repositoryName.token") val token: String? = requestPropertyOrNull("publishing.$repositoryName.token")
@ -110,3 +119,12 @@ internal fun Project.addPublishing(
} }
} }
} }
internal fun Project.addSonatypePublishing(sonatypeRoot: String) {
if (isInDevelopment) {
logger.info("Sonatype publishing skipped for development version")
} else {
addPublishing("sonatype", "$sonatypeRoot/service/local/staging/deploy/maven2")
}
}