Compare commits

..

66 Commits

Author SHA1 Message Date
4106fe27a9 Patch changelog 2023-03-12 13:00:21 +03:00
b7c0d808b7 Fix dokka publishing 2023-03-12 12:58:50 +03:00
e535fdc6f5 Fix publishing for gradle 8 2023-03-12 12:15:20 +03:00
d0079ba307 Make selective native targets... again 2023-02-26 22:03:57 +03:00
a6755e33f5 Fix repositories handling 2023-02-26 21:00:42 +03:00
185b5514c3 Roll back serialization version for compatibility 2023-02-18 18:56:15 +03:00
1e3018275d Customizeable jdk version 2023-02-12 11:32:46 +03:00
4bfd042f96 Kotlin 1.8.20-Beta 2023-02-11 14:28:45 +03:00
979e819c9a Update changelog 2023-02-03 19:30:32 +03:00
1b179e0b05 Easier dependency handling for kscience 2023-02-03 19:28:29 +03:00
a78a4f6118 Use kotlin 1.8.10 2023-02-03 14:11:03 +03:00
a26c7f6df0 Make target configuration optional 2023-02-03 13:15:17 +03:00
99e3e1ea85 Make signing optional 2023-02-03 13:12:10 +03:00
b4fb5c515a Move to manual target configuration 2023-02-03 13:00:11 +03:00
54e862681f Show only modules with a readme extension in main readme 2023-01-12 11:20:03 +03:00
e2a342751d 1.8.0 2022-12-31 12:32:53 +03:00
6de53f5c0a
Merge remote-tracking branch 'space/dev' into dev 2022-11-23 12:28:17 +03:00
a46ca7ddb8
1.8.0-Beta 2022-11-18 11:55:36 +03:00
SPC-code
26a31ed771
Merge pull request #50 from SciProgCentre/commandertvis/fix-ios
Fix a wrong iOS target
2022-11-06 15:09:55 +03:00
Iaroslav Postovalov
680719ac56
Fix a wrong iOS target 2022-11-06 13:05:36 +04:00
c9440e7fc9
Merge remote-tracking branch 'space/dev' into dev 2022-11-02 18:34:40 +03:00
0e06801d5f
Update versions 2022-11-02 18:34:17 +03:00
Iaroslav Postovalov
b4b66a101d Support two more Apple targets 2022-10-22 23:42:30 +04:00
8b14d5bed5
Update sonatype repo 2022-10-22 18:46:30 +03:00
b541fde58a
Revert back to single maven repo structure 2022-10-05 12:14:33 +03:00
a27c1953b3
Move to Kotlin 1.7.20 2022-10-04 20:41:20 +03:00
8a2c0b6e7d
Move to Kotlin 1.7.20 2022-10-04 18:42:21 +03:00
5d3eeaeeee
Move to Kotlin 1.7.20 2022-10-04 14:00:47 +03:00
5dacf9c9d6
Remove old plugins make native configurable inside kscience block. 2022-09-04 20:46:25 +03:00
b4f494e58a
Revert native plugin configuration 2022-08-24 19:02:19 +03:00
8df651bead
Warn on native plugin usage 2022-08-24 18:53:21 +03:00
c77f74c94b
Github org and project switch places 2022-08-24 18:42:36 +03:00
362d7a4042
Remove jdk-release 2022-08-24 18:24:02 +03:00
187b8e8076
Add public dev flag 2022-08-23 16:55:08 +03:00
aafcb06a1e
manual pom config 2022-08-23 16:31:44 +03:00
5d0324bc7b
Universal native configuration 2022-08-20 19:42:19 +03:00
f6e27eebdd
Migrate to new package and Kotlin 1.7.20-Beta 2022-07-29 14:46:22 +03:00
1c80eeb2c7
Try to catch project version 2022-07-10 13:39:35 +03:00
3565a03d57
Update deploy script 2022-07-10 12:58:51 +03:00
adfd6641cc
Update deploy script 2022-07-10 12:42:14 +03:00
a5618726bf update publishing script 2022-07-10 09:01:20 +00:00
Alexander Nozik
7d130dbecb
Merge pull request #47 from mipt-npm/dev
0.11.8 up versions
2022-07-10 11:55:28 +03:00
0f1e42ab36 Merge SCI-MR-159: add deploy script 2022-07-10 08:49:01 +00:00
be1767f090
0.11.8 up versions 2022-07-10 11:46:20 +03:00
c236320855 Merge MIPT-NPM-MR-26: 0.11.8-kotlin-1.7.10 2022-07-10 08:36:03 +00:00
97b0aa9d02
0.11.8 up versions 2022-07-10 10:25:52 +03:00
64b15356e7
Up version 2022-06-14 19:22:49 +03:00
Alexander Nozik
2665d208b1
Merge pull request #46 from mipt-npm/dev
Fix coroutines issue
2022-06-12 14:47:33 +03:00
f283d4d454
Fix coroutines issue 2022-06-12 14:46:28 +03:00
Alexander Nozik
39c7ac024f
Merge pull request #45 from mipt-npm/dev
0.11.6
2022-06-12 11:19:29 +03:00
89bc45cd1c
patch changelog 2022-06-12 11:18:02 +03:00
0ba70aba5c
0.11.6. Remove atomicfu from the plugin 2022-06-12 11:15:11 +03:00
0bea2d34a5
roll back atomicfu to 0.17.2 2022-06-12 10:44:03 +03:00
af891a2149
remove kotlin-jvm plugin from build 2022-06-10 20:18:00 +03:00
Alexander Nozik
53c399d542
Merge pull request #44 from mipt-npm/dev
0.11.5-kotlin-1.7.0
2022-06-09 19:44:46 +03:00
8ba91f805e
Patch changelog 2022-06-09 19:44:30 +03:00
19f3d1ba5d
Update versions 2022-06-09 19:41:46 +03:00
90880fc10f
To Kotlin 1.7.0 2022-06-09 19:38:15 +03:00
eed0f274c7
Fix explicit api application 2022-05-17 10:13:17 +03:00
e3ecfb54c9
Remove context receivers by default. 2022-05-15 12:59:49 +03:00
6526a486f9
Explicit API relaxation 2022-04-19 10:44:44 +03:00
07bde0e593
Merge remote-tracking branch 'origin/dev' into dev 2022-04-13 16:47:13 +03:00
368ed94c52
0.11.4 2022-04-13 16:47:00 +03:00
Alexander Nozik
277ab651f8
Merge pull request #43 from mipt-npm/dev
Update publish.yml
2022-04-12 12:12:27 +03:00
Alexander Nozik
a9b35eb466
Update publish.yml 2022-04-12 12:12:11 +03:00
6e9ef8326b
Merge remote-tracking branch 'origin/master' into dev 2022-04-12 10:51:56 +03:00
30 changed files with 1207 additions and 1090 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

@ -1,46 +1,104 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## Unreleased
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
## 0.14.4-kotlin-1.8.20-RC - 2023-03-12
### Added
- Easier dependency handling in `kscience` block
- Customizable base jdk version
### Changed
- MPP does not use JVM and JS(IR) targets anymore. They could be turned manually via `js()`, `jvm()` or `fullStack()`
- Signing is not applied if signingId is not provided
### Removed
- FX plugins
- Unnecessary library shortcuts (html and datetime)
- deploy/release tasks
### Fixed
- Gradle 8 compatibility
- Dokka publication
- issues with test sourcesets
## 0.13.4-kotlin-1.8.0 - 2022-12-31
### Added
- Public `isInDevelopment` project flag
### Changed
- Require manual pom config for publications
- Kotlin 1.8.0
- Versions update
- Project group changed to `space.kscience`
- Moved `yarn.lock` to `gradle` directory
### Deprecated
- FX configuration
### Removed
- Xjdk-release flag because it is broken until https://youtrack.jetbrains.com/issue/KT-52823
- Use CSS loader in JS by default
## 0.11.6-kotlin-1.7.0
### Changed
- Coroutines tests are applied only when explicit `useCoroutines` is used.
### Removed
- Atomicfu support inside the plugin
### Fixed
- Rollback coroutines to 1.6.1
## 0.11.5-kotlin-1.7.0
### Added
- Coroutine tests as default dependency for tests
- Context receiver flag
### Changed
- Separate release tasks for each target
- Kotlin 1.6.20
- Context receivers enabled
- Ktor 2.0
### Deprecated
- Kotlin 1.7.0
- Ktor 2.0.1
- ExplicitAPI does not override existing value
### Removed
- Ktor specific artifacts from version catalog
### Fixed
- Moved signing out of sonatype block
### Security
## 0.11.1-kotlin-1.6.10
## [0.11.1-kotlin-1.6.10]
### Added
- Default templates for README and ARTIFACT
### Changed
- Replaced Groovy templates by FreeMarker
### Deprecated
### Removed
### Fixed
- JS publication sources jar
### Security
## 0.10.9-kotlin-1.6.10
## [0.10.9-kotlin-1.6.10]
### Added
- html builders for readme
@ -52,24 +110,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- remove `nativeMain` dependency from `nativeTest`
## [0.10.4]
## 0.10.4
### Changed
- Kotlin 1.6
### Fixed
- Some issues with opt-ins
## [0.10.2]
## 0.10.2
### Added
- Experimental automatic JS project bundling in MPP
### Changed
- Remove vcs requirement for Space publication
### Fixed
-Release task (#19)
## 0.10.0
## [0.10.0]
### Added
- Lazy readme properties
- BOM for kotlin-wrappers on JS
@ -82,7 +140,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- bson support
## [0.9.5]
## 0.9.5
### Added
- Disable API validation for snapshots
- `-Xjvm-default=all` on JVM
@ -99,7 +158,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Removed unnecessary `afterEvaluate` for compatibility with gradle 7.0
## [0.9.0]
## 0.9.0
### Added
- Skip sonatype publishing for dev versions
@ -113,7 +173,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Bintray publishing
## [0.8.4]
## 0.8.4
### Added
- Adaptive support for host OS in native
- CSS support for JS targets
@ -127,7 +188,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Release task
- Readme generation for multi-module project
## [0.8.1]
## 0.8.1
### Added
- Ktor version to versions
- Add sonatype publishing
@ -147,7 +209,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix publishing load order for sonatype
- Fix root project readme
## [0.7.4]
## 0.7.4
### Added
- Changelog plugin automatically applied to `project`.
- Feature matrix and Readme generation task for a `project` plugin.
@ -173,16 +236,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- `useDokka` method. Documentation jar should be added manually if needed.
## [0.6.0]
## 0.6.0
### Added
- Migrate to kotlin 1.4.0
- Separate Native (current platform) and nodeJs plugins.
- Add `application()` toggle in plugin configuration to produce binaries on JS and applicaion plugin on jvm.
- Add `publish` to expose publishing configuration.
### Changed
-Publishing in bintray now is automatic.
## 0.5.2
## [0.5.2]
### Added
- Copy resources for jvm modules and jvm source sets in mpp.

View File

@ -1,28 +1,28 @@
[![Maven Central](https://img.shields.io/maven-central/v/ru.mipt.npm.gradle.project/ru.mipt.npm.gradle.project.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22ru.mipt.npm.gradle.project%22%20AND%20a:%22ru.mipt.npm.gradle.project.gradle.plugin%22)
[![Maven Central](https://img.shields.io/maven-central/v/space.kscience.gradle.project/space.kscience.gradle.project.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22space.kscience.gradle.project%22%20AND%20a:%22space.kscience.gradle.project.gradle.plugin%22)
# KScience build tools
A collection of gradle plugins for building and publish in *kscience* and *dataforge* projects.
## ru.mipt.npm.gradle.common
## space.kscience.gradle.common
A primary plugin. When used with kotlin-jvm, kotlin-js or kotlin-mulitplatform configures the project for appropriate target.
## ru.mipt.npm.gradle.project
## space.kscience.gradle.project
Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool.
## ru.mipt.npm.gradle.mpp
`= kotlin("multiplatform") + ru.mipt.npm.gradle.common`
## space.kscience.gradle.mpp
`= kotlin("multiplatform") + space.kscience.gradle.common`
Includes JVM-IR and JS-IR-Browser targets.
## ru.mipt.npm.gradle.jvm
`= kotlin("jvm") + ru.mipt.npm.gradle.common`
## space.kscience.gradle.jvm
`= kotlin("jvm") + space.kscience.gradle.common`
## ru.mipt.npm.gradle.js
`= kotlin("js") + ru.mipt.npm.gradle.common`
## space.kscience.gradle.js
`= kotlin("js") + space.kscience.gradle.common`
## ru.mipt.npm.gradle.native
add default native targets to `ru.mipt.npm.gradle.mpp`
## space.kscience.gradle.native
add default native targets to `space.kscience.gradle.mpp`
## ru.mipt.npm.gradle.node
add node target to `ru.mipt.npm.gradle.mpp`
## space.kscience.gradle.node
add node target to `space.kscience.gradle.mpp`

View File

@ -1,17 +1,17 @@
plugins {
alias(libs.plugins.changelog)
alias(libs.plugins.dokka)
`java-gradle-plugin`
`kotlin-dsl`
`maven-publish`
signing
`version-catalog`
alias(libs.plugins.changelog)
alias(libs.plugins.dokka)
}
group = "ru.mipt.npm"
group = "space.kscience"
version = libs.versions.tools.get()
description = "Build tools for DataForge and kscience projects"
description = "Build tools for kotlin for science projects"
changelog.version.set(project.version.toString())
@ -21,20 +21,17 @@ repositories {
maven("https://repo.kotlin.link")
}
java.targetCompatibility = JavaVersion.VERSION_11
kotlin.explicitApiWarning()
dependencies {
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)
implementation(libs.kotlinx.html)
implementation("org.tomlj:tomlj:1.0.0")
implementation("org.tomlj:tomlj:1.1.0")
// // nexus publishing plugin
// implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
@ -51,53 +48,45 @@ tasks.test {
gradlePlugin {
plugins {
create("common") {
id = "ru.mipt.npm.gradle.common"
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"
id = "space.kscience.gradle.project"
description = "The root plugin for multi-module project infrastructure"
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
implementationClass = "space.kscience.gradle.KScienceProjectPlugin"
}
create("mpp") {
id = "ru.mipt.npm.gradle.mpp"
id = "space.kscience.gradle.mpp"
description = "Pre-configured multiplatform project"
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
implementationClass = "space.kscience.gradle.KScienceMPPlugin"
}
create("jvm") {
id = "ru.mipt.npm.gradle.jvm"
id = "space.kscience.gradle.jvm"
description = "Pre-configured JVM project"
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
implementationClass = "space.kscience.gradle.KScienceJVMPlugin"
}
create("js") {
id = "ru.mipt.npm.gradle.js"
id = "space.kscience.gradle.js"
description = "Pre-configured JS project"
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
implementationClass = "space.kscience.gradle.KScienceJSPlugin"
}
}
}
create("native") {
id = "ru.mipt.npm.gradle.native"
description = "Additional native targets to be use alongside mpp"
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
}
create("node") {
id = "ru.mipt.npm.gradle.node"
description = "Additional nodejs target to be use alongside mpp"
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
}
tasks.create("version") {
group = "publishing"
val versionFile = project.buildDir.resolve("project-version.txt")
outputs.file(versionFile)
doLast {
versionFile.createNewFile()
versionFile.writeText(project.version.toString())
println(project.version)
}
}
//publishing version catalog
@Suppress("UnstableApiUsage")
catalog.versionCatalog {
from(files("gradle/libs.versions.toml"))
}
@ -115,7 +104,18 @@ val javadocsJar by tasks.creating(Jar::class) {
from(tasks.dokkaHtml)
}
afterEvaluate {
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")
}
publishing {
val vcs = "https://github.com/mipt-npm/gradle-tools"
@ -131,8 +131,10 @@ afterEvaluate {
}
withType<MavenPublication> {
artifact(sourcesJar)
artifact(javadocsJar)
// thanks @vladimirsitnikv for the fix
artifact(if (name == "catalog") emptySourcesJar else sourcesJar)
artifact(if (name == "catalog") emptyJavadocJar else javadocsJar)
pom {
name.set(project.name)
@ -164,9 +166,9 @@ afterEvaluate {
}
}
val spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
val spaceUser: String? = project.findProperty("publishing.space.user") as? String
val spaceToken: String? = project.findProperty("publishing.space.token") as? String
val spaceRepo = "https://maven.pkg.jetbrains.space/spc/p/sci/maven"
val spaceUser: String? = findProperty("publishing.space.user") as? String
val spaceToken: String? = findProperty("publishing.space.token") as? String
if (spaceUser != null && spaceToken != null) {
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
@ -202,23 +204,26 @@ afterEvaluate {
}
}
if (plugins.findPlugin("signing") == null) {
apply<SigningPlugin>()
}
signing {
//useGpgCmd()
sign(publications)
}
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
tasks.processResources.configure {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from("gradle/libs.versions.toml")
}
// Workaround for https://github.com/gradle/gradle/issues/15568
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(tasks.withType<Sign>())
}

View File

@ -1,25 +1,26 @@
[versions]
tools = "0.11.3-kotlin-1.6.20"
kotlin = "1.6.20"
atomicfu = "0.17.1"
binary-compatibility-validator = "0.8.0"
changelog = "1.3.1"
dokka = "1.6.10"
kotlin-jupyter = "0.11.0-71"
kotlinx-benchmark = "0.4.2"
kotlinx-cli = "0.3.4"
kotlinx-collections-immutable = "0.3.5"
kotlinx-coroutines = "1.6.1"
kotlinx-datetime = "0.3.2"
kotlinx-html = "0.7.3"
kotlinx-knit = "0.3.0"
tools = "0.14.4-kotlin-1.8.20-RC"
kotlin = "1.8.20-RC"
atomicfu = "0.19.0"
binary-compatibility-validator = "0.12.1"
changelog = "2.0.0"
dokka = "1.7.20"
kotlin-jupyter = "0.11.0-317"
kotlinx-benchmark = "0.4.7"
kotlinx-cli = "0.3.5"
kotlinx-coroutines = "1.6.4"
kotlinx-datetime = "0.4.0"
kotlinx-html = "0.8.0"
kotlinx-knit = "0.4.0"
kotlinx-nodejs = "0.0.7"
kotlinx-serialization = "1.3.2"
ktor = "2.0.0"
xmlutil = "0.84.1"
yamlkt = "0.10.2"
jsBom = "0.0.1-pre.313-kotlin-1.6.10"
junit = "5.8.2"
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"
[libraries]
atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" }
@ -38,8 +39,6 @@ kotlin-jupyter-gradle = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-grad
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinx-collections-immutable" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-debug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "kotlinx-coroutines" }
@ -73,60 +72,6 @@ kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-seria
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktor" }
ktor-client-apache = { module = "io.ktor:ktor-client-apache", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
ktor-client-auth-basic = { module = "io.ktor:ktor-client-auth-basic", version.ref = "ktor" }
ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" }
ktor-client-encoding = { module = "io.ktor:ktor-client-encoding", version.ref = "ktor" }
ktor-client-json = { module = "io.ktor:ktor-client-json", version.ref = "ktor" }
ktor-client-gson = { module = "io.ktor:ktor-client-gson", version.ref = "ktor" }
ktor-client-jackson = { module = "io.ktor:ktor-client-jackson", version.ref = "ktor" }
ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
ktor-client-logging = { module = "io.ktor:ktor-client-loggin", version.ref = "ktor" }
ktor-client-tracing = { module = "io.ktor:ktor-client-tracing", version.ref = "ktor" }
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
ktor-client-jetty = { module = "io.ktor:ktor-client-jetty", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-auth-jwt = { module = "io.ktor:ktor-auth-jwt", version.ref = "ktor" }
ktor-auth-ldap = { module = "io.ktor:ktor-auth-ldap", version.ref = "ktor" }
ktor-auth = { module = "io.ktor:ktor-auth", version.ref = "ktor" }
ktor-freemaker = { module = "io.ktor:ktor-freemaker", version.ref = "ktor" }
ktor-gson = { module = "io.ktor:ktor-gson", version.ref = "ktor" }
ktor-html-builder = { module = "io.ktor:ktor-html-builder", version.ref = "ktor" }
ktor-jackson = { module = "io.ktor:ktor-jackson", version.ref = "ktor" }
ktor-locations = { module = "io.ktor:ktor-locations", version.ref = "ktor" }
ktor-metrics-micrometer = { module = "io.ktor:ktor-metrics-micrometer", version.ref = "ktor" }
ktor-metrics = { module = "io.ktor:ktor-metrics", version.ref = "ktor" }
ktor-mustache = { module = "io.ktor:ktor-mustache", version.ref = "ktor" }
ktor-pebble = { module = "io.ktor:ktor-pebble", version.ref = "ktor" }
ktor-serialization = { module = "io.ktor:ktor-serialization", version.ref = "ktor" }
ktor-server-sessions = { module = "io.ktor:ktor-server-sessions", version.ref = "ktor" }
ktor-thymeleaf = { module = "io.ktor:ktor-thymeleaf", version.ref = "ktor" }
ktor-velocity = { module = "io.ktor:ktor-velocity", version.ref = "ktor" }
ktor-webjars = { module = "io.ktor:ktor-webjars", version.ref = "ktor" }
ktor-websockets = { module = "io.ktor:ktor-websockets", version.ref = "ktor" }
ktor-http = { module = "io.ktor:ktor-http", version.ref = "ktor" }
ktor-http-cio = { module = "io.ktor:ktor-http-cio", version.ref = "ktor" }
ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor" }
ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" }
ktor-network-tls = { module = "io.ktor:ktor-network-tls", version.ref = "ktor" }
ktor-network-tls-certificates = { module = "io.ktor:ktor-network-tls-certificates", version.ref = "ktor" }
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
ktor-server-jetty = { module = "io.ktor:ktor-server-jetty", version.ref = "ktor" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
ktor-server-servlet = { module = "io.ktor:ktor-server-servlet", version.ref = "ktor" }
ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
ktor-server-tomcat = { module = "io.ktor:ktor-server-tomcat", version.ref = "ktor" }
ktor-test-dispatcher = { module = "io.ktor:ktor-test-dispatcher", version.ref = "ktor" }
ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor" }
xmlutil-core = { module = "io.github.pdvrieze.xmlutil:core", version.ref = "xmlutil" }
xmlutil-ktor = { module = "io.github.pdvrieze.xmlutil:ktor", version.ref = "xmlutil" }
@ -134,18 +79,21 @@ 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"}
[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"}
gradle-common = { id = "ru.mipt.npm.gradle.common", version.ref = "tools" }
gradle-project = { id = "ru.mipt.npm.gradle.project", version.ref = "tools" }
gradle-mpp = { id = "ru.mipt.npm.gradle.mpp", version.ref = "tools" }
gradle-jvm = { id = "ru.mipt.npm.gradle.jvm", version.ref = "tools" }
gradle-js = { id = "ru.mipt.npm.gradle.js", version.ref = "tools" }
gradle-native = { id = "ru.mipt.npm.gradle.native", version.ref = "tools" }
gradle-node = { id = "ru.mipt.npm.gradle.node", version.ref = "tools" }
gradle-common = { id = "space.kscience.gradle.common", version.ref = "tools" }
gradle-project = { id = "space.kscience.gradle.project", version.ref = "tools" }
gradle-mpp = { id = "space.kscience.gradle.mpp", version.ref = "tools" }
gradle-jvm = { id = "space.kscience.gradle.jvm", version.ref = "tools" }
gradle-js = { id = "space.kscience.gradle.js", version.ref = "tools" }
gradle-native = { id = "space.kscience.gradle.native", version.ref = "tools" }
gradle-node = { id = "space.kscience.gradle.node", version.ref = "tools" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlin" }

View File

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

View File

@ -1,11 +0,0 @@
package ru.mipt.npm.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
@Suppress("UNUSED_VARIABLE")
public open class KScienceCommonPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.configureKScience(
KotlinVersion(1, 6, 10)
)
}

View File

@ -1,188 +0,0 @@
package ru.mipt.npm.gradle
import kotlinx.atomicfu.plugin.gradle.AtomicFUGradlePlugin
import org.gradle.api.Project
import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask
import ru.mipt.npm.gradle.internal.defaultPlatform
import ru.mipt.npm.gradle.internal.useCommonDependency
import ru.mipt.npm.gradle.internal.useFx
public enum class FXModule(public val artifact: String, public vararg val dependencies: FXModule) {
BASE("javafx-base"),
GRAPHICS("javafx-graphics", BASE),
CONTROLS("javafx-controls", GRAPHICS, BASE),
FXML("javafx-fxml", BASE),
MEDIA("javafx-media", GRAPHICS, BASE),
SWING("javafx-swing", GRAPHICS, BASE),
WEB("javafx-web", CONTROLS, GRAPHICS, BASE)
}
public enum class FXPlatform(public val id: String) {
WINDOWS("win"),
LINUX("linux"),
MAC("mac")
}
public enum class DependencyConfiguration {
API,
IMPLEMENTATION,
COMPILE_ONLY,
}
public enum class DependencySourceSet(public val setName: String, public val suffix: String) {
MAIN("main", "Main"),
TEST("test", "Test")
}
public class KScienceExtension(public val project: Project) {
/**
* Use coroutines-core with default version or [version]
*/
public fun useCoroutines(
version: String = KScienceVersions.coroutinesVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
): Unit = project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
/**
* Use kotlinx-atomicfu plugin and library
*/
public fun useAtomic(
version: String = KScienceVersions.atomicVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION,
): Unit = project.run {
apply<AtomicFUGradlePlugin>()
useCommonDependency(
"org.jetbrains.kotlinx:atomicfu:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
}
/**
* Use core serialization library and configure targets
*/
public fun useSerialization(
version: String = KScienceVersions.serializationVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
block: SerializationTargets.() -> Unit = {},
): Unit = project.run {
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
val artifactName = if (version.startsWith("0")) {
"kotlinx-serialization-runtime"
} else {
"kotlinx-serialization-core"
}
useCommonDependency(
"org.jetbrains.kotlinx:$artifactName:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
SerializationTargets(sourceSet, configuration).block()
}
/**
* Add platform-specific JavaFX dependencies with given list of [FXModule]s
*/
public fun useFx(
vararg modules: FXModule,
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
version: String = "11",
platform: FXPlatform = defaultPlatform,
): Unit = project.useFx(modules.toList(), configuration, version, platform)
/**
* Add dependency on kotlinx-html library
*/
public fun useHtml(
version: String = KScienceVersions.htmlVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
): Unit = project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-html:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
/**
* Use kotlinx-datetime library with default version or [version]
*/
public fun useDateTime(
version: String = KScienceVersions.dateTimeVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
): Unit = project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-datetime:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
/**
* Apply jupyter plugin
*/
@Deprecated("Use jupyterLibrary")
public fun useJupyter() {
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
}
/**
* Apply jupyter plugin and add entry point for the jupyter library.
* If left empty applies a plugin without declaring library producers
*/
public fun jupyterLibrary(vararg pluginClasses: String) {
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
project.tasks.named("processJupyterApiResources", JupyterApiResourcesTask::class.java) {
libraryProducers = pluginClasses.toList()
}
}
/**
* Mark this module as an application module. JVM application should be enabled separately
*/
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 {
binaries.executable()
}
}
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
js {
binaries.executable()
}
targets.withType<KotlinNativeTarget> {
binaries.executable()
}
}
}
}
internal fun Project.registerKScienceExtension() {
if (extensions.findByType<KScienceExtension>() == null) {
extensions.add("kscience", KScienceExtension(this))
}
}

View File

@ -1,17 +0,0 @@
package ru.mipt.npm.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
public open class KScienceJSPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (!plugins.hasPlugin("org.jetbrains.kotlin.js")) {
plugins.apply("org.jetbrains.kotlin.js")
} else {
logger.info("Kotlin JS plugin is already present")
}
apply<KScienceCommonPlugin>()
}
}

View File

@ -1,16 +0,0 @@
package ru.mipt.npm.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
public open class KScienceJVMPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm"))
plugins.apply("org.jetbrains.kotlin.jvm")
else
logger.info("Kotlin JVM plugin is already present")
apply<KScienceCommonPlugin>()
}
}

View File

@ -1,20 +0,0 @@
package ru.mipt.npm.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.hasPlugin
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
public open class KScienceMPPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (!plugins.hasPlugin(KotlinMultiplatformPlugin::class)) {
//apply<KotlinMultiplatformPlugin>() for some reason it does not work
plugins.apply("org.jetbrains.kotlin.multiplatform")
} else {
logger.info("Kotlin MPP plugin is already present")
}
apply<KScienceCommonPlugin>()
}
}

View File

@ -1,59 +0,0 @@
package ru.mipt.npm.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
public class KScienceNativePlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
//Apply multiplatform plugin is not applied, apply it
if (!plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
plugins.apply("org.jetbrains.kotlin.multiplatform")
}
if (!plugins.hasPlugin(KScienceCommonPlugin::class)) {
logger.info("KScience plugin is not resolved. Adding it automatically")
apply<KScienceCommonPlugin>()
}
configure<KotlinMultiplatformExtension> {
val nativeTargets = setOf(
linuxX64(),
mingwX64(),
macosX64(),
iosX64(),
iosArm64()
)
sourceSets {
val commonMain = findByName("commonMain")!!
val commonTest = findByName("commonTest")!!
val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by creating {
//should NOT depend on nativeMain because automatic dependency by plugin
dependsOn(commonTest)
}
configure(nativeTargets) {
compilations["main"]?.apply {
configure(kotlinSourceSets) {
dependsOn(nativeMain)
}
}
compilations["test"]?.apply {
configure(kotlinSourceSets) {
dependsOn(nativeTest)
}
}
}
}
}
}
}

View File

@ -1,57 +0,0 @@
package ru.mipt.npm.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.findPlugin
import org.gradle.kotlin.dsl.invoke
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
/**
* Create a separate target for node
*/
public class KScienceNodePlugin : Plugin<Project> {
override fun apply(target: Project): Unit = target.run {
//Apply multiplatform plugin is not applied, apply it
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
plugins.apply("org.jetbrains.kotlin.multiplatform")
}
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
logger.info("KScience plugin is not resolved. Adding it automatically")
apply<KScienceCommonPlugin>()
}
configure<KotlinMultiplatformExtension> {
js(name = "node", compiler = IR) {
nodejs()
}
sourceSets {
val commonMain = findByName("commonMain")!!
val commonTest = findByName("commonTest")!!
val jsCommonMain = create("jsCommonMain").apply {
dependsOn(commonMain)
}
val jsCommonTest = create("jsCommonTest").apply {
dependsOn(commonTest)
}
findByName("jsMain")?.dependsOn(jsCommonMain)
findByName("jsTest")?.dependsOn(jsCommonTest)
findByName("nodeMain")?.apply {
dependsOn(jsCommonMain)
dependencies {
api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}")
}
}
findByName("nodeTest")?.dependsOn(jsCommonMain)
}
}
}
}

View File

@ -1,169 +0,0 @@
package ru.mipt.npm.gradle
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.*
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import ru.mipt.npm.gradle.internal.applyRepos
import ru.mipt.npm.gradle.internal.applySettings
import ru.mipt.npm.gradle.internal.fromJsDependencies
private val defaultJvmArgs: List<String> = listOf("-Xjvm-default=all", "-Xlambdas=indy", "-Xcontext-receivers")
public fun Project.configureKScience(
kotlinVersion: KotlinVersion
){
//Common configuration
registerKScienceExtension()
repositories.applyRepos()
//Configuration for K-JVM plugin
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
//logger.info("Applying KScience configuration for JVM project")
configure<KotlinJvmProjectExtension> {
explicitApiWarning()
sourceSets.all {
languageSettings.applySettings(kotlinVersion)
}
sourceSets["test"].apply {
dependencies {
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
}
}
}
tasks.withType<KotlinJvmCompile> {
kotlinOptions {
jvmTarget = KScienceVersions.JVM_TARGET.toString()
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
}
}
extensions.findByType<JavaPluginExtension>()?.apply {
targetCompatibility = KScienceVersions.JVM_TARGET
}
tasks.withType<Test> {
useJUnitPlatform()
}
}
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
//logger.info("Applying KScience configuration for JS project")
configure<KotlinJsProjectExtension> {
explicitApiWarning()
js(IR) {
browser {
commonWebpackConfig {
cssSupport.enabled = true
}
}
}
sourceSets.all {
languageSettings.applySettings(kotlinVersion)
}
sourceSets["main"].apply {
dependencies {
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
}
}
sourceSets["test"].apply {
dependencies {
implementation(kotlin("test-js"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
}
}
}
(tasks.findByName("processResources") as? Copy)?.apply {
fromJsDependencies("runtimeClasspath")
}
}
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
configure<KotlinMultiplatformExtension> {
explicitApiWarning()
jvm {
compilations.all {
kotlinOptions {
jvmTarget = KScienceVersions.JVM_TARGET.toString()
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
}
}
}
js(IR) {
browser {
commonWebpackConfig {
cssSupport.enabled = true
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
}
}
val jsMain by getting
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
sourceSets.all {
languageSettings.applySettings(kotlinVersion)
}
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
fromJsDependencies("jsRuntimeClasspath")
}
extensions.findByType<JavaPluginExtension>()?.apply {
targetCompatibility = KScienceVersions.JVM_TARGET
}
tasks.withType<Test> {
useJUnitPlatform()
}
}
}
// apply dokka for all projects
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
apply<DokkaPlugin>()
}
}

View File

@ -1,103 +0,0 @@
package ru.mipt.npm.gradle.internal
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.tasks.Copy
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByName
import org.gradle.kotlin.dsl.maven
import org.gradle.language.jvm.tasks.ProcessResources
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
internal fun LanguageSettingsBuilder.applySettings(
kotlinVersion: KotlinVersion
) {
val versionString = "${kotlinVersion.major}.${kotlinVersion.minor}"
languageVersion = versionString
apiVersion = versionString
progressiveMode = true
optIn("kotlin.RequiresOptIn")
optIn("kotlin.ExperimentalUnsignedTypes")
optIn("kotlin.ExperimentalStdlibApi")
optIn("kotlin.time.ExperimentalTime")
optIn("kotlin.contracts.ExperimentalContracts")
optIn("kotlin.js.ExperimentalJsExport")
}
internal fun RepositoryHandler.applyRepos() {
mavenCentral()
maven("https://repo.kotlin.link")
}
internal fun Copy.fromJsDependencies(configurationName: String) = project.run {
val configuration = configurations[configurationName]
?: error("Configuration with name $configurationName could not be resolved.")
val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map {
it.dependencyProject
}
projectDeps.forEach { dep ->
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
dep.tasks.findByName("jsProcessResources")?.let { task ->
dependsOn(task)
from(task)
}
}
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
dep.tasks.findByName("processResources")?.let { task ->
dependsOn(task)
from(task)
}
}
}
}
internal fun KotlinMultiplatformExtension.bundleJsBinaryAsResource(bundleName: String = "js/bundle.js") {
js {
binaries.executable()
browser {
webpackTask {
outputFileName = bundleName
}
}
}
jvm {
val processResourcesTaskName =
compilations[org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.MAIN_COMPILATION_NAME]
.processResourcesTaskName
val jsBrowserDistribution = project.tasks.getByName("jsBrowserDistribution")
project.tasks.getByName<ProcessResources>(processResourcesTaskName) {
duplicatesStrategy = DuplicatesStrategy.WARN
dependsOn(jsBrowserDistribution)
from(jsBrowserDistribution)
}
}
}
//
//internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate {
// val projectDeps = configuration.allDependencies
// .filterIsInstance<ProjectDependency>()
// .map { it.dependencyProject }
//
// projectDeps.forEach { dep ->
// dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
// dep.tasks.findByName("jvmProcessResources")?.let { task ->
// dependsOn(task)
// from(task)
// }
// }
// dep.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
// dep.tasks.findByName("processResources")?.let { task ->
// dependsOn(task)
// from(task)
// }
// }
// }
//}

View File

@ -1,61 +0,0 @@
package ru.mipt.npm.gradle.internal
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.Project
import org.gradle.kotlin.dsl.findByType
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import ru.mipt.npm.gradle.DependencyConfiguration
import ru.mipt.npm.gradle.FXModule
import ru.mipt.npm.gradle.FXPlatform
internal val defaultPlatform: FXPlatform = when {
Os.isFamily(Os.FAMILY_WINDOWS) -> FXPlatform.WINDOWS
Os.isFamily(Os.FAMILY_MAC) -> FXPlatform.MAC
Os.isFamily(Os.FAMILY_UNIX) -> FXPlatform.LINUX
else -> error("Platform not recognized")
}
private fun KotlinDependencyHandler.addFXDependencies(
modules: List<FXModule>,
configuration: DependencyConfiguration,
version: String = "14",
platform: FXPlatform = defaultPlatform
) {
modules.flatMap { it.dependencies.toList() + it }.distinct().forEach {
val notation = "org.openjfx:${it.artifact}:$version:${platform.id}"
when (configuration) {
DependencyConfiguration.API -> api(notation)
DependencyConfiguration.IMPLEMENTATION -> implementation(notation)
DependencyConfiguration.COMPILE_ONLY -> compileOnly(notation)
}
}
}
internal fun Project.useFx(
modules: List<FXModule>,
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
version: String = "14",
platform: FXPlatform = defaultPlatform
): Unit = afterEvaluate {
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
sourceSets.findByName("jvmMain")?.apply {
dependencies {
addFXDependencies(modules, configuration = configuration, version = version, platform = platform)
}
}
}
}
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
extensions.findByType<KotlinJvmProjectExtension>()?.apply {
sourceSets.findByName("main")?.apply {
dependencies {
addFXDependencies(modules, configuration = configuration, version = version, platform = platform)
}
}
}
}
}

View File

@ -0,0 +1,548 @@
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.provider.Property
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.testing.Test
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.*
import org.gradle.language.jvm.tasks.ProcessResources
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.KotlinDependencyHandler
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.KotlinJsBrowserDsl
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinWasmTargetDsl
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
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.useCommonDependency
public enum class DependencyConfiguration {
API,
IMPLEMENTATION,
COMPILE_ONLY,
}
public enum class DependencySourceSet(public val setName: String, public val suffix: String) {
MAIN("main", "Main"),
TEST("test", "Test")
}
/**
* Check if this project version has a development tag (`development` property to true, "dev" in the middle or "SNAPSHOT" in the end).
*/
public val Project.isInDevelopment: Boolean
get() = findProperty("development") == true
|| "dev" in version.toString()
|| version.toString().endsWith("SNAPSHOT")
private const val defaultJdkVersion = 11
public open class KScienceExtension(public val project: Project) {
public val jdkVersionProperty: Property<Int> = project.objects.property<Int>().apply {
set(defaultJdkVersion)
}
public var jdkVersion: Int by jdkVersionProperty
/**
* Use coroutines-core with default version or [version]
*/
public fun useCoroutines(
version: String = KScienceVersions.coroutinesVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
) {
project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-coroutines-test:$version",
dependencySourceSet = DependencySourceSet.TEST,
dependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
)
}
/**
* Use core serialization library and configure targets
*/
public fun useSerialization(
version: String = KScienceVersions.serializationVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
block: SerializationTargets.() -> Unit = {},
): Unit = project.run {
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
val artifactName = if (version.startsWith("0")) {
"kotlinx-serialization-runtime"
} else {
"kotlinx-serialization-core"
}
useCommonDependency(
"org.jetbrains.kotlinx:$artifactName:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
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(platform("io.ktor:ktor-bom:$version"))
}
}
}
}
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
configure<KotlinJvmProjectExtension> {
sourceSets.findByName("main")?.apply {
dependencies {
api(platform("io.ktor:ktor-bom:$version"))
}
}
}
}
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
configure<KotlinJsProjectExtension> {
sourceSets.findByName("main")?.apply {
dependencies {
api(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
*/
public fun jupyterLibrary(vararg pluginClasses: String) {
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
project.tasks.named("processJupyterApiResources", JupyterApiResourcesTask::class.java) {
libraryProducers = pluginClasses.toList()
}
}
/**
* Apply common dependencies for different kind of targets
*/
public fun dependencies(sourceSet: String? = null, dependencyBlock: KotlinDependencyHandler.() -> Unit) {
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
project.configure<KotlinJvmProjectExtension> {
sourceSets.getByName(sourceSet ?: "main") {
dependencies(dependencyBlock)
}
}
}
project.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
project.configure<KotlinJsProjectExtension> {
sourceSets.getByName(sourceSet ?: "main") {
dependencies(dependencyBlock)
}
}
}
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
project.configure<KotlinMultiplatformExtension> {
sourceSets.getByName(sourceSet ?: "commonMain") {
dependencies(dependencyBlock)
}
}
}
}
public fun testDependencies(sourceSet: String? = null, dependencyBlock: KotlinDependencyHandler.() -> Unit) {
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
project.configure<KotlinJvmProjectExtension> {
sourceSets.getByName(sourceSet ?: "test") {
dependencies(dependencyBlock)
}
}
}
project.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
project.configure<KotlinJsProjectExtension> {
sourceSets.getByName(sourceSet ?: "test") {
dependencies(dependencyBlock)
}
}
}
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
project.configure<KotlinMultiplatformExtension> {
sourceSets.getByName(sourceSet ?: "commonTest") {
dependencies(dependencyBlock)
}
}
}
}
public class DefaultSourceSet(public val key: String)
public fun dependencies(
defaultSourceSet: DefaultSourceSet,
dependencyBlock: KotlinDependencyHandler.() -> Unit,
): Unit = dependencies(defaultSourceSet.key, dependencyBlock)
/**
* Mark this module as an application module. JVM application should be enabled separately
*/
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<KotlinWasmTargetDsl> {
binaries.executable()
}
}
}
/**
* Add context receivers to this project and all subprojects
*/
public fun useContextReceivers() {
project.tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + "-Xcontext-receivers"
}
}
}
public operator fun DefaultSourceSet.invoke(dependencyBlock: KotlinDependencyHandler.() -> Unit) {
dependencies(this, dependencyBlock)
}
public val commonMain: DefaultSourceSet get() = DefaultSourceSet("commonMain")
public val commonTest: DefaultSourceSet get() = DefaultSourceSet("commonTest")
public val jvmMain: DefaultSourceSet get() = DefaultSourceSet("jvmMain")
public val jvmTest: DefaultSourceSet get() = DefaultSourceSet("jvmTest")
public val jsMain: DefaultSourceSet get() = DefaultSourceSet("jsMain")
public val jsTest: DefaultSourceSet get() = DefaultSourceSet("jsTest")
public val nativeMain: DefaultSourceSet get() = DefaultSourceSet("nativeMain")
public val nativeTest: DefaultSourceSet get() = DefaultSourceSet("nativeTest")
public val wasmMain: DefaultSourceSet get() = DefaultSourceSet("wasmMain")
public val wasmTest: DefaultSourceSet get() = DefaultSourceSet("wasmTest")
}
public enum class KotlinNativePreset {
linuxX64,
mingwX64,
macosX64,
macosArm64,
iosX64,
iosArm64,
iosSimulatorArm64,
}
public data class KScienceNativeTarget(
val preset: KotlinNativePreset,
val targetName: String = preset.name,
val targetConfiguration: KotlinNativeTarget.() -> Unit = { },
) {
public companion object {
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 iosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosX64)
public val iosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosArm64)
public val iosSimulatorArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosSimulatorArm64)
}
}
public class KScienceNativeConfiguration {
internal companion object {
private fun defaultNativeTargets(): Map<KotlinNativePreset, KScienceNativeTarget> {
val hostOs = System.getProperty("os.name")
return when {
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()
/**
* Replace all targets
*/
public fun setTargets(vararg target: KScienceNativeTarget) {
targets = target.associateBy { it.preset }
}
/**
* Add a native target
*/
public fun target(target: KScienceNativeTarget) {
targets += target.preset to target
}
public fun target(
preset: KotlinNativePreset,
targetName: String = preset.name,
targetConfiguration: KotlinNativeTarget.() -> Unit = { },
): Unit = target(KScienceNativeTarget(preset, targetName, targetConfiguration))
}
public open class KScienceMppExtension(project: Project) : KScienceExtension(project) {
/**
* Enable jvm target
*/
public fun jvm(block: KotlinJvmTarget.() -> Unit = {}) {
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
project.configure<KotlinMultiplatformExtension> {
jvm {
compilations.all {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + defaultKotlinJvmArgs
}
}
block()
}
sourceSets {
getByName("jvmTest") {
dependencies {
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
}
}
}
jvmToolchain {
languageVersion.set(jdkVersionProperty.map { JavaLanguageVersion.of(it) })
}
}
project.tasks.withType<Test> {
useJUnitPlatform()
}
}
}
/**
* Enable JS-IR (browser) target.
*/
public fun js(block: KotlinJsTargetDsl.() -> Unit = {}) {
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
project.configure<KotlinMultiplatformExtension> {
js(IR) {
browser()
block()
}
sourceSets {
getByName("jsTest") {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
(project.tasks.findByName("jsProcessResources") as? Copy)?.apply {
fromJsDependencies("jsRuntimeClasspath")
}
}
}
@OptIn(ExperimentalWasmDsl::class)
public fun wasm(block: KotlinWasmTargetDsl.() -> Unit = {}) {
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
project.configure<KotlinMultiplatformExtension> {
wasm {
browser()
block()
}
}
}
}
public fun jvmAndJs() {
jvm()
js()
}
/**
* Jvm and Js source sets including copy of Js bundle into JVM resources
*/
public fun fullStack(
bundleName: String = "js/bundle.js",
jvmConfig: KotlinJvmTarget.() -> Unit = {},
jsConfig: KotlinJsTargetDsl.() -> Unit = {},
browserConfig: KotlinJsBrowserDsl.() -> Unit = {},
) {
js {
binaries.executable()
browser {
webpackTask {
outputFileName = bundleName
}
browserConfig()
}
jsConfig()
}
jvm {
val processResourcesTaskName =
compilations[org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.MAIN_COMPILATION_NAME]
.processResourcesTaskName
val jsBrowserDistribution = project.tasks.getByName("jsBrowserDistribution")
project.tasks.getByName<ProcessResources>(processResourcesTaskName) {
duplicatesStrategy = DuplicatesStrategy.WARN
dependsOn(jsBrowserDistribution)
from(jsBrowserDistribution)
}
jvmConfig()
}
}
/**
* Enable all supported native targets
*/
public fun native(block: KScienceNativeConfiguration.() -> Unit = {}): Unit = with(project) {
val nativeConfiguration = KScienceNativeConfiguration().apply(block)
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
configure<KotlinMultiplatformExtension> {
val nativeTargets: List<KotlinNativeTarget> =
nativeConfiguration.targets.values.map { nativeTarget ->
when (nativeTarget.preset) {
KotlinNativePreset.linuxX64 -> linuxX64(
nativeTarget.targetName,
nativeTarget.targetConfiguration
)
KotlinNativePreset.mingwX64 -> mingwX64(
nativeTarget.targetName,
nativeTarget.targetConfiguration
)
KotlinNativePreset.macosX64 -> macosX64(
nativeTarget.targetName,
nativeTarget.targetConfiguration
)
KotlinNativePreset.macosArm64 -> macosArm64(
nativeTarget.targetName,
nativeTarget.targetConfiguration
)
KotlinNativePreset.iosX64 -> iosX64(
nativeTarget.targetName,
nativeTarget.targetConfiguration
)
KotlinNativePreset.iosArm64 -> iosArm64(
nativeTarget.targetName,
nativeTarget.targetConfiguration
)
KotlinNativePreset.iosSimulatorArm64 -> iosSimulatorArm64(
nativeTarget.targetName,
nativeTarget.targetConfiguration
)
// else -> {
// logger.error("Native preset ${nativeTarget.preset} not recognised.")
// null
// }
}
}
sourceSets {
val commonMain by getting
val commonTest by getting
val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by creating {
//should NOT depend on nativeMain because automatic dependency by plugin
dependsOn(commonTest)
}
configure(nativeTargets) {
compilations["main"]?.apply {
configure(kotlinSourceSets) {
dependsOn(nativeMain)
}
}
compilations["test"]?.apply {
configure(kotlinSourceSets) {
dependsOn(nativeTest)
}
}
}
}
}
}
}
}
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension(constructor: (Project) -> T): T {
extensions.findByType<T>()?.let { return it }
return constructor(this).also {
extensions.add("kscience", it)
}
}

View File

@ -0,0 +1,56 @@
package space.kscience.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.Copy
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.get
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import space.kscience.gradle.internal.applySettings
import space.kscience.gradle.internal.fromJsDependencies
public open class KScienceJSPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (!plugins.hasPlugin("org.jetbrains.kotlin.js")) {
plugins.apply("org.jetbrains.kotlin.js")
} else {
logger.info("Kotlin JS plugin is already present")
}
registerKScienceExtension(::KScienceExtension)
//logger.info("Applying KScience configuration for JS project")
configure<KotlinJsProjectExtension> {
js(IR) { browser { } }
sourceSets.all {
languageSettings.applySettings()
}
sourceSets["main"].apply {
dependencies {
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
}
}
sourceSets["test"].apply {
dependencies {
implementation(kotlin("test-js"))
}
}
if (explicitApi == null) explicitApiWarning()
}
(tasks.findByName("processResources") as? Copy)?.apply {
fromJsDependencies("runtimeClasspath")
}
// apply dokka for all projects
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
apply<DokkaPlugin>()
}
}
}

View File

@ -0,0 +1,61 @@
package space.kscience.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.testing.Test
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.withType
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import space.kscience.gradle.internal.applySettings
import space.kscience.gradle.internal.defaultKotlinJvmArgs
public open class KScienceJVMPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm")) {
plugins.apply("org.jetbrains.kotlin.jvm")
} else {
logger.info("Kotlin JVM plugin is already present")
}
val extension = registerKScienceExtension(::KScienceExtension)
//logger.info("Applying KScience configuration for JVM project")
configure<KotlinJvmProjectExtension> {
sourceSets.all {
languageSettings.applySettings()
}
sourceSets["test"].apply {
dependencies {
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
}
}
if (explicitApi == null) explicitApiWarning()
jvmToolchain {
languageVersion.set(extension.jdkVersionProperty.map { JavaLanguageVersion.of(it) })
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + defaultKotlinJvmArgs
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
// apply dokka for all projects
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
apply<DokkaPlugin>()
}
}
}

View File

@ -0,0 +1,54 @@
package space.kscience.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.hasPlugin
import org.gradle.kotlin.dsl.invoke
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
import space.kscience.gradle.internal.applySettings
public open class KScienceMPPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (!plugins.hasPlugin(KotlinMultiplatformPlugin::class)) {
//apply<KotlinMultiplatformPlugin>() for some reason it does not work
plugins.apply("org.jetbrains.kotlin.multiplatform")
} else {
logger.info("Kotlin MPP plugin is already present")
}
registerKScienceExtension(::KScienceMppExtension)
configure<KotlinMultiplatformExtension> {
sourceSets {
getByName("commonMain"){
dependencies {
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
}
}
getByName("commonTest"){
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
}
sourceSets.all {
languageSettings.applySettings()
}
if (explicitApi == null) explicitApiWarning()
}
// apply dokka for all projects
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
apply<DokkaPlugin>()
}
}
}

View File

@ -1,35 +1,24 @@
package ru.mipt.npm.gradle
package space.kscience.gradle
import kotlinx.validation.ApiValidationExtension
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.Sign
import org.jetbrains.changelog.ChangelogPlugin
import org.jetbrains.changelog.ChangelogPluginExtension
import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.dokka.gradle.DokkaPlugin
import ru.mipt.npm.gradle.internal.*
import space.kscience.gradle.internal.*
/**
* Simplifies adding repositories for Maven publishing, responds for releasing tasks for projects.
*/
public class KSciencePublishingExtension(public val project: Project) {
private var isVcsInitialized = false
internal val repositoryNames = mutableSetOf<String>()
@Deprecated("Use git function and report an issue if other VCS is used.")
public fun vcs(vcsUrl: String) {
if (!isVcsInitialized) {
project.setupPublication {
url.set(vcsUrl)
scm { url.set(vcsUrl) }
}
isVcsInitialized = true
}
}
/**
* Configures Git repository (sources) for the publication.
@ -38,16 +27,23 @@ public class KSciencePublishingExtension(public val project: Project) {
* @param connectionUrl URL of the Git repository.
* @param developerConnectionUrl URL of the Git repository for developers.
*/
public fun git(vcsUrl: String, connectionUrl: String? = null, developerConnectionUrl: String? = connectionUrl) {
public fun pom(
vcsUrl: String,
connectionUrl: String? = null,
developerConnectionUrl: String? = connectionUrl,
connectionPrefix: String = "scm:git:",
pomConfig: MavenPom.() -> Unit,
) {
if (!isVcsInitialized) {
project.setupPublication {
url.set(vcsUrl)
scm {
url.set(vcsUrl)
connectionUrl?.let { connection.set("scm:git:$it") }
developerConnectionUrl?.let { developerConnection.set("scm:git:$it") }
connectionUrl?.let { connection.set("$connectionPrefix$it") }
developerConnectionUrl?.let { developerConnection.set("$connectionPrefix$it") }
}
pomConfig()
}
isVcsInitialized = true
@ -59,22 +55,16 @@ public class KSciencePublishingExtension(public val project: Project) {
*
* @param githubProject the GitHub project.
* @param githubOrg the GitHub user or organization.
* @param addToRelease publish packages in the `release` task to the GitHub repository.
* @param deploy publish packages in the `deploy` task to the GitHub repository.
*/
public fun github(
githubOrg: String,
githubProject: String,
githubOrg: String = "mipt-npm",
addToRelease: Boolean = project.requestPropertyOrNull("publishing.github") == "true",
deploy: Boolean = project.requestPropertyOrNull("publishing.github") == "true",
) {
// Automatically initialize VCS using GitHub
if (!isVcsInitialized) {
git("https://github.com/$githubOrg/${githubProject}", "https://github.com/$githubOrg/${githubProject}.git")
}
if (addToRelease) {
if (deploy) {
try {
project.addGithubPublishing(githubOrg, githubProject)
repositoryNames += "github"
} catch (t: Throwable) {
project.logger.error("Failed to set up github publication", t)
}
@ -85,15 +75,12 @@ public class KSciencePublishingExtension(public val project: Project) {
* Adds Space Packages Maven repository to publishing.
*
* @param spaceRepo the repository URL.
* @param addToRelease publish packages in the `release` task to the Space repository.
* @param deploy publish packages in the `deploy` task to the Space repository.
*/
public fun space(
spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven",
addToRelease: Boolean = project.requestPropertyOrNull("publishing.space") != "false",
spaceRepo: String,
) {
project.addSpacePublishing(spaceRepo)
if (addToRelease) repositoryNames += "space"
}
/**
@ -101,13 +88,9 @@ public class KSciencePublishingExtension(public val project: Project) {
*
* @param addToRelease publish packages in the `release` task to the Sonatype repository.
*/
public fun sonatype(
addToRelease: Boolean = (project.requestPropertyOrNull("publishing.sonatype") != "false"),
) {
require(isVcsInitialized) { "The project vcs is not set up use 'git' method to do so" }
public fun sonatype() {
require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" }
project.addSonatypePublishing()
if (addToRelease) repositoryNames += "sonatype"
}
}
@ -121,8 +104,21 @@ public open class KScienceProjectPlugin : Plugin<Project> {
apply<DokkaPlugin>()
apply<BinaryCompatibilityValidatorPlugin>()
allprojects{
repositories{
mavenCentral()
maven("https://repo.kotlin.link")
maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev")
}
// Workaround for https://github.com/gradle/gradle/issues/15568
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(tasks.withType<Sign>())
}
}
afterEvaluate {
if (isSnapshot()) {
if (isInDevelopment) {
configure<ApiValidationExtension> {
validationDisabled = true
}
@ -142,6 +138,8 @@ public open class KScienceProjectPlugin : Plugin<Project> {
subprojects {
val readmeExtension = KScienceReadmeExtension(this)
extensions.add("readme", readmeExtension)
@Suppress("UNUSED_VARIABLE")
val generateReadme by tasks.creating {
group = "documentation"
description = "Generate a README file if stub is present"
@ -204,11 +202,10 @@ public open class KScienceProjectPlugin : Plugin<Project> {
val modulesString = buildString {
subprojects.forEach { subproject ->
val name = subproject.name
// val name = subproject.name
subproject.extensions.findByType<KScienceReadmeExtension>()?.let { ext ->
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
val ext = subproject.extensions.findByType<KScienceReadmeExtension>()
appendLine("\n### [$name]($path)")
if (ext != null) {
appendLine("\n### [$path]($path)")
appendLine("> ${ext.description}")
appendLine(">\n> **Maturity**: ${ext.maturity}")
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
@ -234,49 +231,32 @@ public open class KScienceProjectPlugin : Plugin<Project> {
dependsOn(generateReadme)
}
val releaseAll by tasks.creating {
group = RELEASE_GROUP
description = "Publish development or production release based on version suffix"
dependsOn(generateReadme)
}
allprojects {
afterEvaluate {
ksciencePublish.repositoryNames.forEach { repositoryName ->
val repositoryNameCapitalized = repositoryName.capitalize()
val pattern = "publish(?<publication>.*)PublicationTo${repositoryNameCapitalized}Repository"
.toRegex()
tasks.withType<PublishToMavenRepository>().toList().forEach forEachPublication@ {
val matchResult = pattern.matchEntire(it.name) ?: return@forEachPublication
val publicationName = matchResult.groups["publication"]!!.value.capitalize()
val releaseTaskName = "release$publicationName"
val targetReleaseTask = rootProject.tasks.findByName(releaseTaskName) ?: rootProject.tasks.create(releaseTaskName) {
group = RELEASE_GROUP
description = "Publish platform release artifact for $publicationName to all repositories"
}
releaseAll.dependsOn(targetReleaseTask)
targetReleaseTask.dependsOn(it)
}
}
tasks.create("version") {
group = "publishing"
val versionFile = project.buildDir.resolve("project-version.txt")
outputs.file(versionFile)
doLast {
versionFile.createNewFile()
versionFile.writeText(project.version.toString())
println(project.version)
}
}
// Disable API validation for snapshots
if (isSnapshot()) {
if (isInDevelopment) {
extensions.findByType<ApiValidationExtension>()?.apply {
validationDisabled = true
logger.warn("API validation is disabled for snapshot or dev version")
}
}
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")
}
}
public companion object {
public const val RELEASE_GROUP: String = "release"
public const val DEPLOY_GROUP: String = "deploy"
}
}

View File

@ -1,4 +1,4 @@
package ru.mipt.npm.gradle
package space.kscience.gradle
import freemarker.cache.StringTemplateLoader
import freemarker.template.Configuration
@ -90,11 +90,6 @@ public class KScienceReadmeExtension(public val project: Project) {
public val features: MutableList<Feature> = ArrayList()
@Deprecated("Use lambda builder instead.")
public fun feature(id: String, description: String, ref: String? = null, name: String = id) {
features += Feature(id, description, ref, name)
}
public fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
features += Feature(id, description(), ref, name)
}

View File

@ -1,7 +1,6 @@
package ru.mipt.npm.gradle
package space.kscience.gradle
import org.gradle.api.JavaVersion
import org.tomlj.Toml
/**
@ -24,8 +23,6 @@ public object KScienceVersions {
public val jsBom: String get() = toml.getString("versions.jsBom")!!
internal val junit: String get() = toml.getString("versions.junit")!!
public val JVM_TARGET: JavaVersion = JavaVersion.VERSION_11
public object Serialization {
public val xmlVersion: String get() = toml.getString("versions.xmlutil")!!
public val yamlKtVersion: String get() = toml.getString("versions.yamlkt")!!

View File

@ -1,7 +1,7 @@
package ru.mipt.npm.gradle
package space.kscience.gradle
import org.gradle.api.Project
import ru.mipt.npm.gradle.internal.useCommonDependency
import space.kscience.gradle.internal.useCommonDependency
public class SerializationTargets(
public val sourceSet: DependencySourceSet,

View File

@ -0,0 +1,54 @@
package space.kscience.gradle.internal
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.tasks.Copy
import org.gradle.kotlin.dsl.get
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
import space.kscience.gradle.KScienceVersions
internal val defaultKotlinJvmArgs: List<String> =
listOf("-Xjvm-default=all", "-Xlambdas=indy"/* "-Xjdk-release=${KScienceVersions.JVM_TARGET}"*/)
internal fun resolveKotlinVersion(): KotlinVersion {
val (major, minor, patch) = KScienceVersions.kotlinVersion.split(".", "-")
return KotlinVersion(major.toInt(), minor.toInt(), patch.toInt())
}
internal fun LanguageSettingsBuilder.applySettings(
kotlinVersion: KotlinVersion = resolveKotlinVersion(),
) {
val versionString = "${kotlinVersion.major}.${kotlinVersion.minor}"
languageVersion = versionString
apiVersion = versionString
progressiveMode = true
optIn("kotlin.RequiresOptIn")
optIn("kotlin.ExperimentalUnsignedTypes")
optIn("kotlin.ExperimentalStdlibApi")
optIn("kotlin.time.ExperimentalTime")
optIn("kotlin.contracts.ExperimentalContracts")
optIn("kotlin.js.ExperimentalJsExport")
}
internal fun Copy.fromJsDependencies(configurationName: String) = project.run {
val configuration = configurations[configurationName]
?: error("Configuration with name $configurationName could not be resolved.")
val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map {
it.dependencyProject
}
projectDeps.forEach { dep ->
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
dep.tasks.findByName("jsProcessResources")?.let { task ->
dependsOn(task)
from(task)
}
}
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
dep.tasks.findByName("processResources")?.let { task ->
dependsOn(task)
from(task)
}
}
}
}

View File

@ -1,4 +1,4 @@
package ru.mipt.npm.gradle.internal
package space.kscience.gradle.internal
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
@ -6,8 +6,8 @@ import org.gradle.kotlin.dsl.invoke
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import ru.mipt.npm.gradle.DependencyConfiguration
import ru.mipt.npm.gradle.DependencySourceSet
import space.kscience.gradle.DependencyConfiguration
import space.kscience.gradle.DependencySourceSet
internal fun Project.useDependency(
vararg pairs: Pair<String, String>,

View File

@ -1,4 +1,4 @@
package ru.mipt.npm.gradle.internal
package space.kscience.gradle.internal
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
@ -10,6 +10,8 @@ import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets
import space.kscience.gradle.isInDevelopment
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
?: System.getenv(propertyName)
@ -31,8 +33,9 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
from(it.kotlin)
}
}
publications.create<MavenPublication>("js") {
kotlin.js().components.forEach {
kotlin.targets.flatMap { it.components }.forEach {
from(it)
}
@ -60,37 +63,12 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
}
}
val dokkaJar by tasks.creating(Jar::class) {
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.findByName("dokkaHtml"))
}
// Process each publication we have in this project
publications.withType<MavenPublication> {
artifact(dokkaJar)
pom {
name.set(project.name)
description.set(project.description ?: project.name)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("MIPT-NPM")
name.set("MIPT nuclear physics methods laboratory")
organization.set("MIPT")
organizationUrl.set("https://npm.mipt.ru")
}
}
scm {
tag.set(project.version.toString())
}
@ -98,11 +76,41 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
mavenPomConfiguration()
}
}
plugins.withId("org.jetbrains.dokka") {
val dokkaJar by tasks.creating(Jar::class) {
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.findByName("dokkaHtml"))
}
publications.withType<MavenPublication> {
artifact(dokkaJar)
}
}
internal fun Project.isSnapshot() = "dev" in version.toString() || version.toString().endsWith("SNAPSHOT")
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 key is provided, use it
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
} // else use agent signing
sign(publications)
}
} else {
logger.warn("Signing information is not provided. Skipping artefact signing.")
}
}
}
}
internal fun Project.addGithubPublishing(
githubOrg: String,
@ -178,8 +186,8 @@ internal fun Project.addSonatypePublishing() {
return
}
if (isSnapshot()) {
logger.info("Sonatype publishing skipped for dev version")
if (isInDevelopment) {
logger.info("Sonatype publishing skipped for development version")
return
}
@ -194,24 +202,8 @@ internal fun Project.addSonatypePublishing() {
allprojects {
plugins.withId("maven-publish") {
configure<PublishingExtension> {
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 key is provided, use it
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
} // else use file signing
sign(publications)
}
repositories.maven {
val sonatypeRepo = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
val sonatypeRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
name = "sonatype"
url = uri(sonatypeRepo)

View File

@ -0,0 +1,24 @@
package space.kscience.gradle
import org.gradle.api.publish.maven.MavenPom
public fun MavenPom.useApache2Licence(){
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
}
public fun MavenPom.useSPCTeam(){
developers {
developer {
id.set("SPC")
name.set("Scientific programming centre")
organization.set("MIPT")
organizationUrl.set("https://sciprog.center/")
}
}
}

View File

@ -1,6 +1,5 @@
package ru.mipt.npm.gradle
import org.junit.jupiter.api.Test
import space.kscience.gradle.KScienceVersions
class TestPlugins {
@Test