Compare commits

...

11 Commits

8 changed files with 110 additions and 80 deletions

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
### Changed ### Changed
- All publishing is enabled by default. Introduce `publishing.targets` variable to regulate what is added to the module.
### Deprecated ### Deprecated

View File

@ -211,7 +211,6 @@ publishing {
} }
} }
kotlin { kotlin {
jvmToolchain { jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(11)) languageVersion.set(JavaLanguageVersion.of(11))

View File

@ -1,26 +1,26 @@
[versions] [versions]
tools = "0.14.4-kotlin-1.8.20-RC" tools = "0.14.9-kotlin-1.9.0-RC-dev-1"
kotlin = "1.8.20-RC" kotlin = "1.9.0-RC"
atomicfu = "0.19.0" atomicfu = "0.20.2"
binary-compatibility-validator = "0.12.1" binary-compatibility-validator = "0.13.1"
changelog = "2.0.0" changelog = "2.0.0"
dokka = "1.7.20" dokka = "1.8.10"
kotlin-jupyter = "0.11.0-317" kotlin-jupyter = "0.11.0-360"
kotlinx-benchmark = "0.4.7" kotlinx-benchmark = "0.4.7"
kotlinx-cli = "0.3.5" kotlinx-cli = "0.3.5"
kotlinx-coroutines = "1.6.4" kotlinx-coroutines = "1.7.1"
kotlinx-datetime = "0.4.0" kotlinx-datetime = "0.4.0"
kotlinx-html = "0.8.0" kotlinx-html = "0.8.0"
kotlinx-knit = "0.4.0" kotlinx-knit = "0.4.0"
kotlinx-nodejs = "0.0.7" kotlinx-nodejs = "0.0.7"
kotlinx-serialization = "1.4.1" kotlinx-serialization = "1.5.1"
ktor = "2.2.3" ktor = "2.3.0"
xmlutil = "0.84.3" xmlutil = "0.86.0"
yamlkt = "0.12.0" yamlkt = "0.13.0"
jsBom = "1.0.0-pre.509" jsBom = "1.0.0-pre.546"
junit = "5.9.2" junit = "5.9.3"
compose = "1.3.0" compose = "1.4.0"
logback = "1.4.5" logback = "1.4.7"
[libraries] [libraries]
atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" } atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" }
@ -37,6 +37,8 @@ kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", v
kotlin-jupyter-gradle = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin", version.ref = "kotlin-jupyter" } kotlin-jupyter-gradle = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin", version.ref = "kotlin-jupyter" }
kotlin-js-wrappers = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version.ref = "jsBom" }
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" } kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
@ -79,13 +81,13 @@ xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", v
yamlkt = { module = "net.mamoe.yamlkt:yamlkt", version.ref = "yamlkt" } yamlkt = { module = "net.mamoe.yamlkt:yamlkt", version.ref = "yamlkt" }
logback-classic = {module = "ch.qos.logback:logback-classic", version.ref = "logback"} logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
[plugins] [plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
compose = {id = "org.jetbrains.compose", version.ref = "compose"} compose = { id = "org.jetbrains.compose", version.ref = "compose" }
gradle-common = { id = "space.kscience.gradle.common", version.ref = "tools" } gradle-common = { id = "space.kscience.gradle.common", version.ref = "tools" }
gradle-project = { id = "space.kscience.gradle.project", version.ref = "tools" } gradle-project = { id = "space.kscience.gradle.project", version.ref = "tools" }

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -13,6 +13,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension 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.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
@ -24,6 +25,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask import org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask
import space.kscience.gradle.internal.defaultKotlinJvmArgs import space.kscience.gradle.internal.defaultKotlinJvmArgs
import space.kscience.gradle.internal.fromJsDependencies import space.kscience.gradle.internal.fromJsDependencies
import space.kscience.gradle.internal.requestPropertyOrNull
import space.kscience.gradle.internal.useCommonDependency import space.kscience.gradle.internal.useCommonDependency
public enum class DependencyConfiguration { public enum class DependencyConfiguration {
@ -207,6 +209,7 @@ public open class KScienceExtension(public val project: Project) {
/** /**
* Mark this module as an application module. JVM application should be enabled separately * Mark this module as an application module. JVM application should be enabled separately
*/ */
@Deprecated("Use platform-specific applications")
public fun application() { public fun application() {
project.extensions.findByType<KotlinProjectExtension>()?.apply { project.extensions.findByType<KotlinProjectExtension>()?.apply {
explicitApi = null explicitApi = null
@ -285,21 +288,37 @@ public data class KScienceNativeTarget(
public val linuxX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.linuxX64) public val linuxX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.linuxX64)
public val mingwX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.mingwX64) public val mingwX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.mingwX64)
public val macosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.macosX64) public val macosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.macosX64)
public val macosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.macosX64) public val macosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.macosArm64)
public val iosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosX64) public val iosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosX64)
public val iosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosArm64) public val iosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosArm64)
public val iosSimulatorArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosSimulatorArm64) public val iosSimulatorArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosSimulatorArm64)
} }
} }
public class KScienceNativeConfiguration { public class KScienceNativeConfiguration(private val project: Project) {
internal companion object { internal companion object {
private fun defaultNativeTargets(): Map<KotlinNativePreset, KScienceNativeTarget> { private fun defaultNativeTargets(project: Project): Map<KotlinNativePreset, KScienceNativeTarget> {
val hostOs = System.getProperty("os.name") val hostOs = System.getProperty("os.name")
val targets = project.requestPropertyOrNull("publishing.targets")
return when { return when {
targets == "all" -> listOf(
KScienceNativeTarget.linuxX64,
KScienceNativeTarget.mingwX64,
KScienceNativeTarget.macosX64,
KScienceNativeTarget.macosArm64,
KScienceNativeTarget.iosX64,
KScienceNativeTarget.iosArm64,
KScienceNativeTarget.iosSimulatorArm64,
)
targets != null -> {
targets.split(",").map { KScienceNativeTarget(KotlinNativePreset.valueOf(it)) }
}
hostOs.startsWith("Windows") -> listOf( hostOs.startsWith("Windows") -> listOf(
KScienceNativeTarget.linuxX64, KScienceNativeTarget.linuxX64,
KScienceNativeTarget.mingwX64 KScienceNativeTarget.mingwX64
@ -314,6 +333,7 @@ public class KScienceNativeConfiguration {
) )
hostOs == "Linux" -> listOf(KScienceNativeTarget.linuxX64) hostOs == "Linux" -> listOf(KScienceNativeTarget.linuxX64)
else -> { else -> {
emptyList() emptyList()
} }
@ -322,7 +342,7 @@ public class KScienceNativeConfiguration {
} }
internal var targets: Map<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets() internal var targets: Map<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets(project)
/** /**
@ -405,12 +425,32 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
@OptIn(ExperimentalWasmDsl::class) @OptIn(ExperimentalWasmDsl::class)
public fun wasm(block: KotlinWasmTargetDsl.() -> Unit = {}) { public fun wasm(block: KotlinWasmTargetDsl.() -> Unit = {}) {
if (project.requestPropertyOrNull("kscience.wasm.disabled") == "true") {
project.logger.warn("Wasm target is disabled with 'kscience.wasm.disabled' property")
return
}
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
project.configure<KotlinMultiplatformExtension> { project.configure<KotlinMultiplatformExtension> {
wasm { wasm {
browser() browser {
testTask {
useKarma {
this.webpackConfig.experiments.add("topLevelAwait")
useChromeHeadlessWasmGc()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm"))
}
}
}
block() block()
} }
sourceSets {
getByName("wasmTest") {
dependencies {
implementation(kotlin("test"))
}
}
}
} }
} }
} }
@ -433,7 +473,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
binaries.executable() binaries.executable()
browser { browser {
webpackTask { webpackTask {
outputFileName = bundleName mainOutputFileName.set(bundleName)
} }
browserConfig() browserConfig()
} }
@ -441,8 +481,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
} }
jvm { jvm {
val processResourcesTaskName = val processResourcesTaskName =
compilations[org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.MAIN_COMPILATION_NAME] compilations[KotlinCompilation.MAIN_COMPILATION_NAME].processResourcesTaskName
.processResourcesTaskName
val jsBrowserDistribution = project.tasks.getByName("jsBrowserDistribution") val jsBrowserDistribution = project.tasks.getByName("jsBrowserDistribution")
@ -459,7 +498,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
* Enable all supported native targets * Enable all supported native targets
*/ */
public fun native(block: KScienceNativeConfiguration.() -> Unit = {}): Unit = with(project) { public fun native(block: KScienceNativeConfiguration.() -> Unit = {}): Unit = with(project) {
val nativeConfiguration = KScienceNativeConfiguration().apply(block) val nativeConfiguration = KScienceNativeConfiguration(this).apply(block)
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
configure<KotlinMultiplatformExtension> { configure<KotlinMultiplatformExtension> {
val nativeTargets: List<KotlinNativeTarget> = val nativeTargets: List<KotlinNativeTarget> =
@ -521,6 +560,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
} }
configure(nativeTargets) { configure(nativeTargets) {
compilations["main"]?.apply { compilations["main"]?.apply {
configure(kotlinSourceSets) { configure(kotlinSourceSets) {
dependsOn(nativeMain) dependsOn(nativeMain)

View File

@ -12,6 +12,9 @@ import org.jetbrains.changelog.ChangelogPlugin
import org.jetbrains.changelog.ChangelogPluginExtension import org.jetbrains.changelog.ChangelogPluginExtension
import org.jetbrains.dokka.gradle.AbstractDokkaTask import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.dokka.gradle.DokkaPlugin import org.jetbrains.dokka.gradle.DokkaPlugin
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.* import space.kscience.gradle.internal.*
/** /**
@ -88,9 +91,9 @@ public class KSciencePublishingExtension(public val project: Project) {
* *
* @param addToRelease publish packages in the `release` task to the Sonatype repository. * @param addToRelease publish packages in the `release` task to the Sonatype repository.
*/ */
public fun sonatype() { 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" }
project.addSonatypePublishing() project.addSonatypePublishing(sonatypeRoot)
} }
} }
@ -104,8 +107,8 @@ public open class KScienceProjectPlugin : Plugin<Project> {
apply<DokkaPlugin>() apply<DokkaPlugin>()
apply<BinaryCompatibilityValidatorPlugin>() apply<BinaryCompatibilityValidatorPlugin>()
allprojects{ allprojects {
repositories{ repositories {
mavenCentral() mavenCentral()
maven("https://repo.kotlin.link") maven("https://repo.kotlin.link")
maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev") maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev")
@ -250,9 +253,11 @@ public open class KScienceProjectPlugin : Plugin<Project> {
} }
} }
plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) { plugins.withType<YarnPlugin>() {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().lockFileDirectory = rootProject.configure<YarnRootExtension> {
rootDir.resolve("gradle") lockFileDirectory = rootDir.resolve("gradle")
yarnLockMismatchReport = YarnLockMismatchReport.WARNING
}
} }
} }

View File

@ -88,12 +88,18 @@ public class KScienceReadmeExtension(public val project: Project) {
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)
public val features: MutableList<Feature> = ArrayList() public val features: MutableList<Feature> = mutableListOf()
/**
* A plain readme feature with description
*/
public fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) { public fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
features += Feature(id, description(), ref, name) features += Feature(id, description(), ref, name)
} }
/**
* A readme feature with HTML description
*/
public fun featureWithHtml( public fun featureWithHtml(
id: String, id: String,
ref: String? = null, ref: String? = null,

View File

@ -27,19 +27,10 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
plugins.withId("org.jetbrains.kotlin.js") { plugins.withId("org.jetbrains.kotlin.js") {
val kotlin: KotlinJsProjectExtension = extensions.findByType()!! val kotlin: KotlinJsProjectExtension = extensions.findByType()!!
val sourcesJar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
kotlin.sourceSets.forEach {
from(it.kotlin)
}
}
publications.create<MavenPublication>("js") { publications.create<MavenPublication>("js") {
kotlin.targets.flatMap { it.components }.forEach { kotlin.targets.flatMap { it.components }.forEach {
from(it) from(it)
} }
artifact(sourcesJar)
} }
} }
@ -116,22 +107,18 @@ internal fun Project.addGithubPublishing(
githubOrg: String, githubOrg: String,
githubProject: String, githubProject: String,
) { ) {
if (requestPropertyOrNull("publishing.enabled") != "true") { val githubUser: String? = requestPropertyOrNull("publishing.github.user")
logger.info("Skipping github publishing because publishing is disabled") val githubToken: String? = requestPropertyOrNull("publishing.github.token")
return
}
if (requestPropertyOrNull("publishing.github") != "false") {
logger.info("Skipping github publishing because `publishing.github != true`")
return
}
val githubUser: String = requestProperty("publishing.github.user") if (githubUser == null || githubToken == null) {
val githubToken: String = requestProperty("publishing.github.token") logger.info("Skipping Github publishing because Github credentials are not defined")
return
}
allprojects { allprojects {
plugins.withId("maven-publish") { plugins.withId("maven-publish") {
configure<PublishingExtension> { configure<PublishingExtension> {
logger.info("Adding github publishing to project [${project.name}]") logger.info("Adding Github publishing to project [${project.name}]")
repositories.maven { repositories.maven {
name = "github" name = "github"
@ -148,23 +135,18 @@ internal fun Project.addGithubPublishing(
} }
internal fun Project.addSpacePublishing(spaceRepo: String) { internal fun Project.addSpacePublishing(spaceRepo: String) {
if (requestPropertyOrNull("publishing.enabled") != "true") { val spaceUser: String? = requestPropertyOrNull("publishing.space.user")
logger.info("Skipping space publishing because publishing is disabled") val spaceToken: String? = requestPropertyOrNull("publishing.space.token")
if (spaceUser == null || spaceToken == null) {
logger.info("Skipping Space publishing because Space credentials are not defined")
return return
} }
if (requestPropertyOrNull("publishing.space") == "false") {
logger.info("Skipping space publishing because `publishing.space == false`")
return
}
val spaceUser: String = requestProperty("publishing.space.user")
val spaceToken: String = requestProperty("publishing.space.token")
allprojects { allprojects {
plugins.withId("maven-publish") { plugins.withId("maven-publish") {
configure<PublishingExtension> { configure<PublishingExtension> {
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]") project.logger.info("Adding SPC Space publishing to project [${project.name}]")
repositories.maven { repositories.maven {
name = "space" name = "space"
@ -180,30 +162,25 @@ internal fun Project.addSpacePublishing(spaceRepo: String) {
} }
} }
internal fun Project.addSonatypePublishing() { internal fun Project.addSonatypePublishing(sonatypeRoot: String) {
if (requestPropertyOrNull("publishing.enabled") != "true") {
logger.info("Skipping sonatype publishing because publishing is disabled")
return
}
if (isInDevelopment) { if (isInDevelopment) {
logger.info("Sonatype publishing skipped for development version") logger.info("Sonatype publishing skipped for development version")
return return
} }
if (requestPropertyOrNull("publishing.sonatype") == "false") { val sonatypeUser: String? = requestPropertyOrNull("publishing.sonatype.user")
logger.info("Skipping sonatype publishing because `publishing.sonatype == false`") val sonatypePassword: String? = requestPropertyOrNull("publishing.sonatype.password")
if (sonatypeUser == null || sonatypePassword == null) {
logger.info("Skipping Sonatype publishing because Sonatype credentials are not defined")
return return
} }
val sonatypeUser: String = requestProperty("publishing.sonatype.user")
val sonatypePassword: String = requestProperty("publishing.sonatype.password")
allprojects { allprojects {
plugins.withId("maven-publish") { plugins.withId("maven-publish") {
configure<PublishingExtension> { configure<PublishingExtension> {
repositories.maven { repositories.maven {
val sonatypeRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2" val sonatypeRepo = "$sonatypeRoot/service/local/staging/deploy/maven2"
name = "sonatype" name = "sonatype"
url = uri(sonatypeRepo) url = uri(sonatypeRepo)