Compare commits
17 Commits
master
...
beta/2.2.0
Author | SHA1 | Date | |
---|---|---|---|
3af28c3065 | |||
5a86f9c6ee | |||
7d50f5963c | |||
9544237613 | |||
95785ab5dd | |||
86e5196173 | |||
d969f14229 | |||
3506100873 | |||
3b2d609751 | |||
1698a86940 | |||
abbfe65308 | |||
093d9a628b | |||
7dc90b929d | |||
d12497ebe2 | |||
7ea16f713b | |||
e364f811af | |||
e1c946cd8f |
43
.space.kts
43
.space.kts
@ -1,43 +0,0 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
CHANGELOG.md
11
CHANGELOG.md
@ -7,17 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
- kotlinx-io dependency in version catalog
|
||||
|
||||
### Changed
|
||||
- Use the new jvm executable option for full-stack instead of gradle application plugin.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- `application` option
|
||||
|
||||
### Fixed
|
||||
- Fix readme generation
|
||||
|
||||
### Security
|
||||
|
||||
## 0.16.0-kotlin-2.1.0 - 2025-01-02
|
||||
|
||||
### Changed
|
||||
|
||||
- Kotlin 2.1.0
|
||||
- Publication to central via `com.vanniktech.maven.publish.base`
|
||||
|
||||
## 0.15.4-kotlin-2.0.0 - 2024-06-04
|
||||
|
||||
### Added
|
||||
|
@ -1,15 +1,14 @@
|
||||
|
||||
plugins {
|
||||
`java-gradle-plugin`
|
||||
`kotlin-dsl`
|
||||
`maven-publish`
|
||||
// signing
|
||||
`version-catalog`
|
||||
alias(libs.plugins.maven.publish)
|
||||
alias(libs.plugins.jetbrains.changelog)
|
||||
alias(libs.plugins.jetbrains.dokka)
|
||||
alias(libs.plugins.versions)
|
||||
alias(libs.plugins.versions.update)
|
||||
alias(libs.plugins.maven.publish.base)
|
||||
}
|
||||
|
||||
group = "space.kscience"
|
||||
@ -26,12 +25,13 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.kotlin.gradle)
|
||||
api(libs.foojay.resolver)
|
||||
implementation(libs.binary.compatibility.validator)
|
||||
implementation(libs.changelog.gradle)
|
||||
implementation(libs.dokka.gradle)
|
||||
implementation(libs.kotlin.jupyter.gradle)
|
||||
api("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.asProvider().get()}")
|
||||
api("org.gradle.toolchains:foojay-resolver:0.9.0")
|
||||
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.17.0")
|
||||
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:${libs.versions.changelog.get()}")
|
||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${libs.versions.dokka.get()}")
|
||||
implementation("org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin:${libs.versions.kotlin.jupyter.get()}")
|
||||
implementation("com.vanniktech:gradle-maven-publish-plugin:0.30.0")
|
||||
implementation(libs.kotlin.serialization)
|
||||
implementation(libs.kotlinx.html)
|
||||
implementation(libs.tomlj)
|
||||
@ -71,7 +71,7 @@ gradlePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.create("version") {
|
||||
tasks.register("version") {
|
||||
group = "publishing"
|
||||
val versionFileProvider = project.layout.buildDirectory.file("project-version.txt")
|
||||
outputs.file(versionFileProvider)
|
||||
@ -89,40 +89,21 @@ catalog.versionCatalog {
|
||||
}
|
||||
|
||||
//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 {
|
||||
configure(
|
||||
com.vanniktech.maven.publish.GradlePlugin(
|
||||
javadocJar = com.vanniktech.maven.publish.JavadocJar.Dokka("dokkaHtml"),
|
||||
javadocJar = com.vanniktech.maven.publish.JavadocJar.Dokka("dokkaGenerate"),
|
||||
sourcesJar = true,
|
||||
)
|
||||
)
|
||||
|
||||
project.publishing.publications.create("maven", MavenPublication::class.java) {
|
||||
from(project.components.getByName("versionCatalog"))
|
||||
publishing.publications.create<MavenPublication>("version-catalog") {
|
||||
from(components["versionCatalog"])
|
||||
artifactId = "version-catalog"
|
||||
|
||||
pom {
|
||||
name.set("version-catalog")
|
||||
}
|
||||
}
|
||||
|
||||
val vcs = "https://git.sciprog.center/kscience/gradle-tools"
|
||||
|
@ -1,3 +1,5 @@
|
||||
kotlin.code.style=official
|
||||
|
||||
nl.littlerobots.vcu.resolver=true
|
||||
nl.littlerobots.vcu.resolver=true
|
||||
|
||||
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
|
@ -1,40 +1,44 @@
|
||||
[versions]
|
||||
# @pin
|
||||
kotlin = "2.1.0"
|
||||
kotlin = "2.2.0-Beta1"
|
||||
# @pin
|
||||
tools = "0.15.8-kotlin-2.1.0"
|
||||
atomicfu = "0.26.1"
|
||||
tools = "0.17.1-kotlin-2.2.0-Beta1"
|
||||
atomicfu = "0.27.0"
|
||||
changelog = "2.2.1"
|
||||
compose = "1.7.1"
|
||||
dokka = "2.0.0-Beta"
|
||||
jsBom = "1.0.0-pre.847"
|
||||
compose = "1.7.3"
|
||||
dokka = "2.0.0"
|
||||
jsBom = "2025.3.17"
|
||||
junit = "5.10.2"
|
||||
kotlin-jupyter = "0.12.0-352"
|
||||
kotlin-jupyter = "0.12.0-388"
|
||||
kotlinx-benchmark = "0.4.13"
|
||||
kotlinx-cli = "0.3.6"
|
||||
kotlinx-coroutines = "1.9.0"
|
||||
kotlinx-datetime = "0.6.1"
|
||||
kotlinx-html = "0.11.0"
|
||||
kotlinx-coroutines = "1.10.1"
|
||||
kotlinx-datetime = "0.6.2"
|
||||
kotlinx-html = "0.12.0"
|
||||
kotlinx-knit = "0.5.0"
|
||||
kotlinx-nodejs = "0.0.7"
|
||||
kotlinx-serialization = "1.7.3"
|
||||
kover = "0.8.3"
|
||||
ktor = "3.0.2"
|
||||
ksp = "2.1.0-1.0.29"
|
||||
logback = "1.5.12"
|
||||
slf4j = "2.0.16"
|
||||
kotlinx-serialization = "1.8.0"
|
||||
kotlinx-io = "0.7.0"
|
||||
kover = "0.9.1"
|
||||
ktor = "3.1.1"
|
||||
ksp = "2.1.10-1.0.31"
|
||||
logback = "1.5.18"
|
||||
slf4j = "2.0.17"
|
||||
xmlutil = "0.90.3"
|
||||
yamlkt = "0.13.0"
|
||||
opensavvy-resources = "0.4.0"
|
||||
|
||||
[plugins]
|
||||
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.30.0" }
|
||||
maven-publish = "com.vanniktech.maven.publish:0.31.0"
|
||||
maven-publish-base = "com.vanniktech.maven.publish.base:0.31.0"
|
||||
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
compose-jb = { id = "org.jetbrains.compose", version.ref = "compose" }
|
||||
jetbrains-changelog = "org.jetbrains.changelog:2.2.1"
|
||||
jetbrains-changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
|
||||
jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||
kotlin-gradle = { id = "org.jetbrains.kotlin:kotlin-gradle-plugin", 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-dsl = "org.gradle.kotlin.kotlin-dsl:5.1.2"
|
||||
kotlin-dsl = "org.gradle.kotlin.kotlin-dsl:5.2.0"
|
||||
kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" }
|
||||
kotlin-jupyter-api = { id = "org.jetbrains.kotlin.jupyter.api", version.ref = "kotlin-jupyter" }
|
||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
@ -55,26 +59,15 @@ kscience-mpp = { id = "space.kscience.gradle.mpp", version.ref = "tools" }
|
||||
kscience-project = { id = "space.kscience.gradle.project", version.ref = "tools" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
|
||||
versions = "com.github.ben-manes.versions:0.51.0"
|
||||
opensavvy-resources-producer = { id = "dev.opensavvy.resources.producer:dev.opensavvy.resources.producer.gradle.plugin", version.ref = "opensavvy-resources" }
|
||||
opensavvy-resources-consumer = { id = "dev.opensavvy.resources.producer:dev.opensavvy.resources.consumer.gradle.plugin", version.ref = "opensavvy-resources" }
|
||||
versions = "com.github.ben-manes.versions:0.52.0"
|
||||
versions-update = "nl.littlerobots.version-catalog-update:0.8.5"
|
||||
|
||||
[libraries]
|
||||
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"
|
||||
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" }
|
||||
freemarker = "org.freemarker:freemarker:2.3.34"
|
||||
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-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" }
|
||||
@ -107,6 +100,9 @@ kotlinx-serialization-hocon = { module = "org.jetbrains.kotlinx:kotlinx-serializ
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-browser = "org.jetbrains.kotlinx:kotlinx-browser:0.3"
|
||||
kotlinx-io-core = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinx-io" }
|
||||
kotlinx-io-bytestring = { module = "org.jetbrains.kotlinx:kotlinx-io-bytestring", version.ref = "kotlinx-io" }
|
||||
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
|
||||
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
|
||||
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -2,7 +2,6 @@ package space.kscience.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.plugins.ApplicationPlugin
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Copy
|
||||
@ -12,10 +11,8 @@ import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
@ -54,7 +51,7 @@ public val Project.isInDevelopment: Boolean
|
||||
|
||||
private const val defaultJdkVersion = 17
|
||||
|
||||
public abstract class KScienceExtension @Inject constructor(public val project: Project): ExtensionAware {
|
||||
public abstract class KScienceExtension @Inject constructor(public val project: Project) : ExtensionAware {
|
||||
|
||||
public val jdkVersionProperty: Property<Int> = project.objects.property<Int>().apply {
|
||||
set(defaultJdkVersion)
|
||||
@ -105,36 +102,6 @@ public abstract class KScienceExtension @Inject constructor(public val project:
|
||||
SerializationTargets(sourceSet, configuration).block()
|
||||
}
|
||||
|
||||
public fun useKtor(version: String = KScienceVersions.ktorVersion): Unit = with(project) {
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
sourceSets.findByName("commonMain")?.apply {
|
||||
dependencies {
|
||||
api(project.dependencies.platform("io.ktor:ktor-bom:$version"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
configure<KotlinJvmProjectExtension> {
|
||||
sourceSets.findByName("main")?.apply {
|
||||
dependencies {
|
||||
api(project.dependencies.platform("io.ktor:ktor-bom:$version"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||
configure<KotlinJsProjectExtension> {
|
||||
sourceSets.findByName("main")?.apply {
|
||||
dependencies {
|
||||
api(project.dependencies.platform("io.ktor:ktor-bom:$version"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply jupyter plugin and add entry point for the jupyter library.
|
||||
* If left empty applies a plugin without declaring library producers
|
||||
@ -194,47 +161,13 @@ public abstract class KScienceExtension @Inject constructor(public val project:
|
||||
): Unit = dependencies(defaultSourceSet.key, dependencyBlock)
|
||||
|
||||
|
||||
/**
|
||||
* Mark this module as an application module. JVM application should be enabled separately
|
||||
*/
|
||||
@Deprecated("Use platform-specific applications")
|
||||
public fun application() {
|
||||
project.extensions.findByType<KotlinProjectExtension>()?.apply {
|
||||
explicitApi = null
|
||||
}
|
||||
|
||||
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
project.apply<ApplicationPlugin>()
|
||||
}
|
||||
|
||||
project.extensions.findByType<KotlinJsProjectExtension>()?.apply {
|
||||
js(IR) {
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
|
||||
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
targets.withType<KotlinJsTargetDsl> {
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
targets.withType<KotlinNativeTarget> {
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
targets.withType<KotlinWasmJsTargetDsl> {
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add context receivers to this project and all subprojects
|
||||
*/
|
||||
public fun useContextReceivers() {
|
||||
project.tasks.withType<KotlinCompile> {
|
||||
compilerOptions{
|
||||
freeCompilerArgs.add("-Xcontext-receivers")
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll("-Xcontext-parameters")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -287,13 +220,9 @@ public class KScienceNativeConfiguration(private val project: Project) {
|
||||
|
||||
|
||||
internal companion object {
|
||||
private fun defaultNativeTargets(project: Project): Map<KotlinNativePreset, KScienceNativeTarget> {
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
val targets = project.requestPropertyOrNull("publishing.targets")
|
||||
|
||||
return when {
|
||||
targets == "all" -> listOf(
|
||||
private fun defaultNativeTargets(project: Project): Set<KScienceNativeTarget> =
|
||||
when (val targets = project.requestPropertyOrNull("publishing.targets")) {
|
||||
null -> setOf(
|
||||
KScienceNativeTarget.linuxX64,
|
||||
KScienceNativeTarget.mingwX64,
|
||||
KScienceNativeTarget.macosX64,
|
||||
@ -303,48 +232,28 @@ public class KScienceNativeConfiguration(private val project: Project) {
|
||||
KScienceNativeTarget.iosSimulatorArm64,
|
||||
)
|
||||
|
||||
targets != null -> {
|
||||
targets.split(",").map { KScienceNativeTarget(KotlinNativePreset.valueOf(it)) }
|
||||
else -> targets.split(",").mapTo(HashSet()) {
|
||||
KScienceNativeTarget(KotlinNativePreset.valueOf(it))
|
||||
}
|
||||
|
||||
hostOs.startsWith("Windows") -> listOf(
|
||||
KScienceNativeTarget.linuxX64,
|
||||
KScienceNativeTarget.mingwX64
|
||||
)
|
||||
|
||||
hostOs == "Mac OS X" -> listOf(
|
||||
KScienceNativeTarget.macosX64,
|
||||
KScienceNativeTarget.macosArm64,
|
||||
KScienceNativeTarget.iosX64,
|
||||
KScienceNativeTarget.iosArm64,
|
||||
KScienceNativeTarget.iosSimulatorArm64,
|
||||
)
|
||||
|
||||
hostOs == "Linux" -> listOf(KScienceNativeTarget.linuxX64)
|
||||
|
||||
else -> {
|
||||
emptyList()
|
||||
}
|
||||
}.associateBy { it.preset }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal var targets: Map<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets(project)
|
||||
internal var targets: Set<KScienceNativeTarget> = defaultNativeTargets(project)
|
||||
|
||||
|
||||
/**
|
||||
* Replace all targets
|
||||
*/
|
||||
public fun setTargets(vararg target: KScienceNativeTarget) {
|
||||
targets = target.associateBy { it.preset }
|
||||
targets = target.toSet()
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a native target
|
||||
*/
|
||||
public fun target(target: KScienceNativeTarget) {
|
||||
targets += target.preset to target
|
||||
targets += target
|
||||
}
|
||||
|
||||
public fun target(
|
||||
@ -364,7 +273,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
|
||||
project.configure<KotlinMultiplatformExtension> {
|
||||
jvm {
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
compilerOptions{
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll(defaultKotlinJvmArgs)
|
||||
}
|
||||
block()
|
||||
@ -458,7 +367,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
|
||||
) {
|
||||
js {
|
||||
browser {
|
||||
commonWebpackConfig{
|
||||
commonWebpackConfig {
|
||||
outputFileName = bundleName
|
||||
}
|
||||
browserConfig()
|
||||
@ -485,6 +394,32 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executable fullstack application
|
||||
*/
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
public fun fullStackApplication(
|
||||
mainClassName: String,
|
||||
bundleName: String = "js/bundle.js",
|
||||
development: Boolean = false,
|
||||
jvmConfig: KotlinJvmTarget.() -> Unit = {},
|
||||
jsConfig: KotlinJsTargetDsl.() -> Unit = {},
|
||||
browserConfig: KotlinJsBrowserDsl.() -> Unit = {},
|
||||
): Unit = fullStack(
|
||||
bundleName = bundleName,
|
||||
development = development,
|
||||
jvmConfig = {
|
||||
binaries {
|
||||
executable {
|
||||
mainClass.set(mainClassName)
|
||||
}
|
||||
}
|
||||
jvmConfig()
|
||||
},
|
||||
jsConfig = jsConfig,
|
||||
browserConfig = browserConfig
|
||||
)
|
||||
|
||||
/**
|
||||
* Enable all supported native targets
|
||||
*/
|
||||
@ -492,7 +427,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
|
||||
val nativeConfiguration = KScienceNativeConfiguration(this).apply(block)
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
nativeConfiguration.targets.values.forEach { nativeTarget ->
|
||||
nativeConfiguration.targets.forEach { nativeTarget ->
|
||||
when (nativeTarget.preset) {
|
||||
KotlinNativePreset.linuxX64 -> linuxX64(
|
||||
nativeTarget.targetName,
|
||||
@ -537,7 +472,7 @@ public abstract class KScienceMppExtension @Inject constructor(project: Project)
|
||||
}
|
||||
|
||||
|
||||
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension():T {
|
||||
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension(): T {
|
||||
// extensions.findByType<T>()?.let { return it }
|
||||
// return constructor(this).also {
|
||||
// extensions.add("kscience", it)
|
||||
|
@ -16,7 +16,7 @@ import space.kscience.gradle.internal.defaultKotlinJvmArgs
|
||||
public open class KScienceJVMPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
|
||||
logger.warn("KSCience JVM plugin is deprecated. Use MPP.")
|
||||
logger.warn("KScience JVM plugin is deprecated. Use MPP.")
|
||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm")) {
|
||||
plugins.apply("org.jetbrains.kotlin.jvm")
|
||||
} else {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
import com.vanniktech.maven.publish.MavenPublishBaseExtension
|
||||
import com.vanniktech.maven.publish.MavenPublishBasePlugin
|
||||
import kotlinx.validation.ApiValidationExtension
|
||||
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
||||
import org.gradle.api.Plugin
|
||||
@ -16,7 +18,6 @@ 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.YarnRootExtension
|
||||
import space.kscience.gradle.internal.addPublishing
|
||||
import space.kscience.gradle.internal.addSonatypePublishing
|
||||
import space.kscience.gradle.internal.setupPublication
|
||||
|
||||
/**
|
||||
@ -69,11 +70,32 @@ public class KSciencePublishingExtension(public val project: Project) {
|
||||
|
||||
/**
|
||||
* Adds Sonatype Maven repository to publishing.
|
||||
|
||||
*/
|
||||
public fun sonatype(sonatypeRoot: String = "https://s01.oss.sonatype.org") {
|
||||
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" }
|
||||
project.addSonatypePublishing(sonatypeRoot)
|
||||
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) {
|
||||
require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" }
|
||||
if (isInDevelopment) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,6 +109,9 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
apply<DokkaPlugin>()
|
||||
apply<BinaryCompatibilityValidatorPlugin>()
|
||||
|
||||
val ksciencePublish = KSciencePublishingExtension(this)
|
||||
extensions.add("ksciencePublish", ksciencePublish)
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -113,8 +138,6 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
val rootReadmeExtension = KScienceReadmeExtension(this)
|
||||
val ksciencePublish = KSciencePublishingExtension(this)
|
||||
extensions.add("ksciencePublish", ksciencePublish)
|
||||
extensions.add("readme", rootReadmeExtension)
|
||||
|
||||
//Add readme generators to individual subprojects
|
||||
@ -122,11 +145,11 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
val readmeExtension = KScienceReadmeExtension(this)
|
||||
extensions.add("readme", readmeExtension)
|
||||
|
||||
tasks.create("generateReadme") {
|
||||
tasks.register("generateReadme") {
|
||||
group = "documentation"
|
||||
description = "Generate a README file if stub is present"
|
||||
|
||||
inputs.property("extension", readmeExtension)
|
||||
inputs.property("features", readmeExtension.features)
|
||||
|
||||
if (readmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(readmeExtension.readmeTemplate)
|
||||
@ -153,7 +176,7 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
// }
|
||||
}
|
||||
|
||||
val generateReadme by tasks.creating {
|
||||
val generateReadme by tasks.registering{
|
||||
group = "documentation"
|
||||
description = "Generate a README file and a feature matrix if stub is present"
|
||||
|
||||
@ -163,7 +186,13 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
inputs.property("extension", rootReadmeExtension)
|
||||
inputs.property("features", rootReadmeExtension.features)
|
||||
|
||||
subprojects.forEach { subproject->
|
||||
subproject.extensions.findByType<KScienceReadmeExtension>()?.let {
|
||||
inputs.property("features-${subproject.name}", it.features)
|
||||
}
|
||||
}
|
||||
|
||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(rootReadmeExtension.readmeTemplate)
|
||||
@ -217,7 +246,7 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
|
||||
tasks.create("version") {
|
||||
tasks.register("version") {
|
||||
group = "publishing"
|
||||
val versionFileProvider = project.layout.buildDirectory.file("project-version.txt")
|
||||
outputs.file(versionFileProvider)
|
||||
|
@ -12,10 +12,8 @@ import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.intellij.lang.annotations.Language
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
import java.io.StringWriter
|
||||
import kotlin.collections.component1
|
||||
import kotlin.collections.component2
|
||||
import kotlin.collections.set
|
||||
|
||||
public enum class Maturity {
|
||||
PROTOTYPE,
|
||||
@ -71,14 +69,14 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
private val fmLoader = StringTemplateLoader().apply {
|
||||
putTemplate(
|
||||
"artifact",
|
||||
this@KScienceReadmeExtension.javaClass.getResource("/templates/ARTIFACT-TEMPLATE.md")!!.readText()
|
||||
KScienceReadmeExtension::class.java.getResource("/templates/ARTIFACT-TEMPLATE.md")!!.readText()
|
||||
)
|
||||
if (readmeTemplate.exists()) {
|
||||
putTemplate("readme", readmeTemplate.readText())
|
||||
} else if (useDefaultReadmeTemplate) {
|
||||
putTemplate(
|
||||
"readme",
|
||||
this@KScienceReadmeExtension.javaClass.getResource("/templates/README-TEMPLATE.md")!!.readText()
|
||||
KScienceReadmeExtension::class.java.getResource("/templates/README-TEMPLATE.md")!!.readText()
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -88,7 +86,7 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
templateLoader = fmLoader
|
||||
}
|
||||
|
||||
public data class Feature(val id: String, val description: String, val ref: String?, val name: String = id)
|
||||
public data class Feature(val id: String, val description: String, val ref: String?, val name: String = id): Serializable
|
||||
|
||||
public val features: MutableList<Feature> = mutableListOf()
|
||||
|
||||
@ -99,7 +97,7 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
id: String,
|
||||
@Language("File") ref: String? = null,
|
||||
name: String = id,
|
||||
description: () -> String,
|
||||
@Language("markdown") description: () -> String,
|
||||
) {
|
||||
features += Feature(id, description(), ref, name)
|
||||
}
|
||||
@ -177,7 +175,7 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
*/
|
||||
internal fun featuresString(itemPrefix: String = " - ", pathPrefix: String = ""): String = buildString {
|
||||
features.forEach {
|
||||
appendLine("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description}")
|
||||
appendLine("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description.lines().firstOrNull() ?: ""}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
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.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPom
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
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 space.kscience.gradle.isInDevelopment
|
||||
|
||||
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
||||
?: System.getenv(propertyName)
|
||||
@ -20,12 +19,14 @@ internal fun Project.requestProperty(propertyName: String): String = requestProp
|
||||
|
||||
internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit = {}) = allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
apply<MavenPublishBasePlugin>()
|
||||
|
||||
configure<PublishingExtension> {
|
||||
|
||||
plugins.withId("org.jetbrains.kotlin.jvm") {
|
||||
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
|
||||
|
||||
val sourcesJar by tasks.creating(Jar::class) {
|
||||
val sourcesJar by tasks.registering(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
kotlin.sourceSets.forEach {
|
||||
from(it.kotlin)
|
||||
@ -54,32 +55,22 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
|
||||
}
|
||||
|
||||
plugins.withId("org.jetbrains.dokka") {
|
||||
val dokkaJar by tasks.creating(Jar::class) {
|
||||
val dokkaJar by tasks.registering(Jar::class) {
|
||||
group = "documentation"
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.findByName("dokkaHtml"))
|
||||
from(tasks.findByName("dokkaGenerate"))
|
||||
}
|
||||
publications.withType<MavenPublication> {
|
||||
artifact(dokkaJar)
|
||||
}
|
||||
}
|
||||
|
||||
if (requestPropertyOrNull("publishing.signing.id") != null || requestPropertyOrNull("signing.gnupg.keyName") != null) {
|
||||
|
||||
if (!plugins.hasPlugin("signing")) {
|
||||
apply<SigningPlugin>()
|
||||
}
|
||||
|
||||
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)
|
||||
//apply signing if signing configuration is available
|
||||
if (requestPropertyOrNull("signing.password") != null || requestPropertyOrNull("signing.secretKeyRingFile") != null) {
|
||||
plugins.withType<MavenPublishBasePlugin> {
|
||||
extensions.configure<MavenPublishBaseExtension> {
|
||||
signAllPublications()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.warn("Signing information is not provided. Skipping artefact signing.")
|
||||
@ -90,9 +81,9 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
|
||||
|
||||
internal fun Project.addPublishing(
|
||||
repositoryName: String,
|
||||
urlString:String
|
||||
){
|
||||
require(repositoryName.matches("\\w*".toRegex())){"Repository name must contain only letters or numbers"}
|
||||
urlString: String
|
||||
) {
|
||||
require(repositoryName.matches("\\w*".toRegex())) { "Repository name must contain only letters or numbers" }
|
||||
val user: String? = requestPropertyOrNull("publishing.$repositoryName.user")
|
||||
val token: String? = requestPropertyOrNull("publishing.$repositoryName.token")
|
||||
|
||||
@ -119,12 +110,3 @@ 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")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user