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
### Changed
- All publishing is enabled by default. Introduce `publishing.targets` variable to regulate what is added to the module.
### Deprecated

View File

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

View File

@ -1,26 +1,26 @@
[versions]
tools = "0.14.4-kotlin-1.8.20-RC"
kotlin = "1.8.20-RC"
atomicfu = "0.19.0"
binary-compatibility-validator = "0.12.1"
tools = "0.14.9-kotlin-1.9.0-RC-dev-1"
kotlin = "1.9.0-RC"
atomicfu = "0.20.2"
binary-compatibility-validator = "0.13.1"
changelog = "2.0.0"
dokka = "1.7.20"
kotlin-jupyter = "0.11.0-317"
dokka = "1.8.10"
kotlin-jupyter = "0.11.0-360"
kotlinx-benchmark = "0.4.7"
kotlinx-cli = "0.3.5"
kotlinx-coroutines = "1.6.4"
kotlinx-coroutines = "1.7.1"
kotlinx-datetime = "0.4.0"
kotlinx-html = "0.8.0"
kotlinx-knit = "0.4.0"
kotlinx-nodejs = "0.0.7"
kotlinx-serialization = "1.4.1"
ktor = "2.2.3"
xmlutil = "0.84.3"
yamlkt = "0.12.0"
jsBom = "1.0.0-pre.509"
junit = "5.9.2"
compose = "1.3.0"
logback = "1.4.5"
kotlinx-serialization = "1.5.1"
ktor = "2.3.0"
xmlutil = "0.86.0"
yamlkt = "0.13.0"
jsBom = "1.0.0-pre.546"
junit = "5.9.3"
compose = "1.4.0"
logback = "1.4.7"
[libraries]
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-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-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" }
logback-classic = {module = "ch.qos.logback:logback-classic", version.ref = "logback"}
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
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-project = { id = "space.kscience.gradle.project", version.ref = "tools" }

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
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
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.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
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 space.kscience.gradle.internal.defaultKotlinJvmArgs
import space.kscience.gradle.internal.fromJsDependencies
import space.kscience.gradle.internal.requestPropertyOrNull
import space.kscience.gradle.internal.useCommonDependency
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
*/
@Deprecated("Use platform-specific applications")
public fun application() {
project.extensions.findByType<KotlinProjectExtension>()?.apply {
explicitApi = null
@ -285,21 +288,37 @@ public data class KScienceNativeTarget(
public val linuxX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.linuxX64)
public val mingwX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.mingwX64)
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 iosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosArm64)
public val iosSimulatorArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosSimulatorArm64)
}
}
public class KScienceNativeConfiguration {
public class KScienceNativeConfiguration(private val project: Project) {
internal companion object {
private fun defaultNativeTargets(): Map<KotlinNativePreset, KScienceNativeTarget> {
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(
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(
KScienceNativeTarget.linuxX64,
KScienceNativeTarget.mingwX64
@ -314,6 +333,7 @@ public class KScienceNativeConfiguration {
)
hostOs == "Linux" -> listOf(KScienceNativeTarget.linuxX64)
else -> {
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)
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.configure<KotlinMultiplatformExtension> {
wasm {
browser()
browser {
testTask {
useKarma {
this.webpackConfig.experiments.add("topLevelAwait")
useChromeHeadlessWasmGc()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm"))
}
}
}
block()
}
sourceSets {
getByName("wasmTest") {
dependencies {
implementation(kotlin("test"))
}
}
}
}
}
}
@ -433,7 +473,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
binaries.executable()
browser {
webpackTask {
outputFileName = bundleName
mainOutputFileName.set(bundleName)
}
browserConfig()
}
@ -441,8 +481,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
}
jvm {
val processResourcesTaskName =
compilations[org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.MAIN_COMPILATION_NAME]
.processResourcesTaskName
compilations[KotlinCompilation.MAIN_COMPILATION_NAME].processResourcesTaskName
val jsBrowserDistribution = project.tasks.getByName("jsBrowserDistribution")
@ -459,7 +498,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
* Enable all supported native targets
*/
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") {
configure<KotlinMultiplatformExtension> {
val nativeTargets: List<KotlinNativeTarget> =
@ -521,6 +560,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
}
configure(nativeTargets) {
compilations["main"]?.apply {
configure(kotlinSourceSets) {
dependsOn(nativeMain)

View File

@ -12,6 +12,9 @@ import org.jetbrains.changelog.ChangelogPlugin
import org.jetbrains.changelog.ChangelogPluginExtension
import org.jetbrains.dokka.gradle.AbstractDokkaTask
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.*
/**
@ -88,9 +91,9 @@ public class KSciencePublishingExtension(public val project: Project) {
*
* @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" }
project.addSonatypePublishing()
project.addSonatypePublishing(sonatypeRoot)
}
}
@ -104,8 +107,8 @@ public open class KScienceProjectPlugin : Plugin<Project> {
apply<DokkaPlugin>()
apply<BinaryCompatibilityValidatorPlugin>()
allprojects{
repositories{
allprojects {
repositories {
mavenCentral()
maven("https://repo.kotlin.link")
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) {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().lockFileDirectory =
rootDir.resolve("gradle")
plugins.withType<YarnPlugin>() {
rootProject.configure<YarnRootExtension> {
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 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) {
features += Feature(id, description(), ref, name)
}
/**
* A readme feature with HTML description
*/
public fun featureWithHtml(
id: String,
ref: String? = null,

View File

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