Compare commits
153 Commits
v0.11.5-ko
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 86c7c6b6e5 | |||
| d0d037857f | |||
| 4a67cc8298 | |||
| 134314e6d7 | |||
| be3a73c05a | |||
| 44dda55332 | |||
| dfdef2bff5 | |||
| aaabbd2097 | |||
| 25bf7d37d7 | |||
| 64cd2da1be | |||
| de77a1c6d0 | |||
| 47ed350f47 | |||
| d67679075b | |||
| 9f1403543d | |||
| e6b8f5ef56 | |||
| f51829ab02 | |||
| 7cd1f1bf8f | |||
| 229d6efc6b | |||
| ff2ca9f398 | |||
| 4c08233478 | |||
| 6412672184 | |||
| 625f2b9b66 | |||
| 84887ccfd2 | |||
| df5b175728 | |||
| 3fb883fc0a | |||
| bba1699a1e | |||
| 63b380ff90 | |||
| 3af28c3065 | |||
| 5a86f9c6ee | |||
| 7d50f5963c | |||
| 9544237613 | |||
| 95785ab5dd | |||
| 86e5196173 | |||
| d969f14229 | |||
| 3506100873 | |||
| 3b2d609751 | |||
| 1698a86940 | |||
| abbfe65308 | |||
| 093d9a628b | |||
| 7dc90b929d | |||
| d12497ebe2 | |||
| 7ea16f713b | |||
| e364f811af | |||
| e1c946cd8f | |||
| 36dae25531 | |||
| a6a1ed4102 | |||
| 2e1f3876af | |||
| 0dc3458176 | |||
| c951123fde | |||
| b507cb0536 | |||
| 558fd695b9 | |||
| 37e5603389 | |||
| 5c7dc3c729 | |||
| d6276e0ca0 | |||
| 2bd93104d6 | |||
| 91a82153fd | |||
| 53517859d4 | |||
| d93b0a578f | |||
| 43dcf509fb | |||
| ec3e3e3376 | |||
| 46be46461b | |||
| fbdb3e0da9 | |||
| e55e296ab0 | |||
| 329d023438 | |||
| cb1c6d79a7 | |||
| 93d881c9a4 | |||
| 2da966b1cd | |||
| d79453371e | |||
| 6cd7b572d6 | |||
| 3a150eff69 | |||
| 920385e135 | |||
| 71f7698633 | |||
| ed5faa0335 | |||
| 7636f37cfc | |||
| b5772a2e9b | |||
| dba45860f7 | |||
| 90762f493e | |||
| 54952c3da6 | |||
| 89af2dd644 | |||
| b27624bf1c | |||
| 4f41d90308 | |||
| 33b6de9f0e | |||
| 2f5e053aea | |||
| c3bdd8edca | |||
| c249dc5ae4 | |||
| 8a864f97a3 | |||
| 72f2678f3d | |||
| 8272c4ae4d | |||
| a62503ac41 | |||
| 5463c9326b | |||
| 4238dc5a43 | |||
| 021f78c510 | |||
| b05617ce9a | |||
| 70c190d7fa | |||
| d3432643e8 | |||
| 512954b510 | |||
| 9fc8d96e88 | |||
| 2e3b74eb63 | |||
| 2886b7b200 | |||
| 4106fe27a9 | |||
| b7c0d808b7 | |||
| e535fdc6f5 | |||
| d0079ba307 | |||
| a6755e33f5 | |||
| 185b5514c3 | |||
| 1e3018275d | |||
| 4bfd042f96 | |||
| 979e819c9a | |||
| 1b179e0b05 | |||
| a78a4f6118 | |||
| a26c7f6df0 | |||
| 99e3e1ea85 | |||
| b4fb5c515a | |||
| 54e862681f | |||
| e2a342751d | |||
| 6de53f5c0a | |||
| a46ca7ddb8 | |||
|
|
26a31ed771 | ||
|
|
680719ac56 | ||
| c9440e7fc9 | |||
| 0e06801d5f | |||
|
|
b4b66a101d | ||
| 8b14d5bed5 | |||
| b541fde58a | |||
| a27c1953b3 | |||
| 8a2c0b6e7d | |||
| 5d3eeaeeee | |||
| 5dacf9c9d6 | |||
| b4f494e58a | |||
| 8df651bead | |||
| c77f74c94b | |||
| 362d7a4042 | |||
| 187b8e8076 | |||
| aafcb06a1e | |||
| 5d0324bc7b | |||
| f6e27eebdd | |||
| 1c80eeb2c7 | |||
| 3565a03d57 | |||
| adfd6641cc | |||
| a5618726bf | |||
|
|
7d130dbecb | ||
| 0f1e42ab36 | |||
| be1767f090 | |||
| c236320855 | |||
| 97b0aa9d02 | |||
| 64b15356e7 | |||
|
|
2665d208b1 | ||
| f283d4d454 | |||
|
|
39c7ac024f | ||
| 89bc45cd1c | |||
| 0ba70aba5c | |||
| 0bea2d34a5 | |||
| af891a2149 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2.5.0
|
||||
with:
|
||||
java-version: 11
|
||||
java-version: 21
|
||||
distribution: liberica
|
||||
- uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
|
||||
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2.5.0
|
||||
with:
|
||||
java-version: 11
|
||||
java-version: 21
|
||||
distribution: liberica
|
||||
- uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
|
||||
256
CHANGELOG.md
256
CHANGELOG.md
@@ -1,12 +1,13 @@
|
||||
# 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
|
||||
- WasmWasi target
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -18,170 +19,321 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Security
|
||||
|
||||
## [0.11.5-kotlin-1.7.0]
|
||||
## 0.19.0-kotlin-2.2.0 - 2025-07-24
|
||||
|
||||
### Changed
|
||||
|
||||
- Replace manual JS dependency resource handling with `opensavvy` plugin.
|
||||
- Replace `useContextRecievers` with `useContextParameters`.
|
||||
- Submodule readme generated for all projects, not only for root
|
||||
- Replace `wasm` plugin configuration block with `wasmJs`
|
||||
|
||||
### Deprecated
|
||||
|
||||
- `useContextRecievers`
|
||||
- `wasm` configuration block
|
||||
|
||||
### Removed
|
||||
|
||||
- `fullStackApplication` configuration. Replaced by optional field in `fullStack`
|
||||
- Jupyter integration
|
||||
|
||||
## 0.17.x
|
||||
|
||||
### Added
|
||||
|
||||
- kotlinx-io dependency in version catalog
|
||||
|
||||
### Changed
|
||||
|
||||
- Use the new jvm executable option for full-stack instead of gradle application plugin.
|
||||
|
||||
### Removed
|
||||
|
||||
- `application` option
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix readme generation
|
||||
|
||||
## 0.16.0-kotlin-2.1.0 - 2025-01-02
|
||||
|
||||
### Changed
|
||||
|
||||
- Kotlin 2.1.0
|
||||
- Publication to central via `com.vanniktech.maven.publish.base`
|
||||
|
||||
## 0.15.4-kotlin-2.0.0 - 2024-06-04
|
||||
|
||||
### Added
|
||||
|
||||
- Pass `compose` extension to the kscience extension so compose dependencies could be called directly from kscience block
|
||||
|
||||
### Changed
|
||||
|
||||
- Use ES6 modules by default in JS
|
||||
- Kotlin 2.0
|
||||
|
||||
## 0.15.2-kotlin-1.9.22 - 2024-02-09
|
||||
|
||||
### Added
|
||||
|
||||
- Add development mode for fullstack.
|
||||
|
||||
### Changed
|
||||
|
||||
- Kotlin 1.9.20
|
||||
- Remove publishing defaults for Space and GitHub. Now publishing repositories is configured quasi-manually. Property keys for username and tokens are generated automatically.
|
||||
- All publishing targets are enabled by default. Introduce `publishing.targets` variable to regulate what is added to the module.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- JVM plugin in favor of Mpp.
|
||||
|
||||
### Removed
|
||||
|
||||
- JS plugin. It is deprecated in favor of MPP.
|
||||
- Unnecessary `dependsOn` for native dependencies.
|
||||
- Groovy gradle dependency notation.
|
||||
|
||||
## 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.7.0
|
||||
- Ktor 2.0.1
|
||||
- ExplicitAPI does not override existing value
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
- Ktor specific artifacts from version catalog
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
- Moved signing out of sonatype block
|
||||
|
||||
## 0.11.1-kotlin-1.6.10
|
||||
|
||||
### Security
|
||||
|
||||
## [0.11.1-kotlin-1.6.10]
|
||||
### Added
|
||||
|
||||
- Default templates for README and ARTIFACT
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- Replaced Groovy templates by FreeMarker
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
- JS publication sources jar
|
||||
|
||||
## [0.10.9-kotlin-1.6.10]
|
||||
## 0.10.9-kotlin-1.6.10
|
||||
|
||||
### Added
|
||||
|
||||
- html builders for readme
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- Kotlin 1.6.0
|
||||
- Use indy lambdas by default #32
|
||||
- Use indy lambdas by default #32
|
||||
- Change version scheme to `<version>-kotlin-<kotlin version>`
|
||||
|
||||
|
||||
### 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
|
||||
|
||||
## 0.10.0
|
||||
|
||||
### Fixed
|
||||
-Release task (#19)
|
||||
|
||||
## [0.10.0]
|
||||
### Added
|
||||
|
||||
- Lazy readme properties
|
||||
- BOM for kotlin-wrappers on JS
|
||||
- Jupyter loader
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- API validation disabled for dev versions
|
||||
- Kotlin plugins are propagated downstream
|
||||
|
||||
|
||||
### Removed
|
||||
|
||||
- bson support
|
||||
|
||||
## [0.9.5]
|
||||
## 0.9.5
|
||||
|
||||
### Added
|
||||
|
||||
- Disable API validation for snapshots
|
||||
- `-Xjvm-default=all` on JVM
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- `publication.platform` changed to `publishing.platform`
|
||||
- Dokka version to `1.4.30`
|
||||
- `useDateTime` in extension
|
||||
- Kotlin 1.5
|
||||
|
||||
|
||||
### Removed
|
||||
|
||||
- Publish plugin. Use MavenPublish instead
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
- Removed unnecessary `afterEvaluate` for compatibility with gradle 7.0
|
||||
|
||||
## [0.9.0]
|
||||
## 0.9.0
|
||||
|
||||
### Added
|
||||
|
||||
- Skip sonatype publishing for dev versions
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- Publishing repositories are explicit and defined in the top level project
|
||||
- Paths to publishing properties now use dot notation like `publishing.github.user`
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Publishing plugin
|
||||
|
||||
|
||||
### Removed
|
||||
|
||||
- Bintray publishing
|
||||
|
||||
## [0.8.4]
|
||||
## 0.8.4
|
||||
|
||||
### Added
|
||||
|
||||
- Adaptive support for host OS in native
|
||||
- CSS support for JS targets
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- Kotlin 1.4.31
|
||||
- Coroutines 1.4.3
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
- Plugin loading order for publishing
|
||||
- Release task
|
||||
- Readme generation for multi-module project
|
||||
|
||||
## [0.8.1]
|
||||
## 0.8.1
|
||||
|
||||
### Added
|
||||
|
||||
- Ktor version to versions
|
||||
- Add sonatype publishing
|
||||
- Per-platform release publishing
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- Kotlin to 1.4.30 stable.
|
||||
- Added intermediate jsCommon main/test sourcesSet for node plugin.
|
||||
- Plugin names changed to `ru.mipt.npm` package.
|
||||
- Common plugin id changed to `common`
|
||||
- Plugins group changed to `ru.mipt.npm` with `gradle` prefix
|
||||
|
||||
|
||||
### Removed
|
||||
|
||||
- kaml
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
- 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.
|
||||
- Add `binary-compatibility-validator` to the `project` plugin.
|
||||
@@ -189,8 +341,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Moved all logic to a common plugin, leaving only proxies for platform plugins
|
||||
- Suppress API validation for modules with maturity below DEVELOPMENT
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
- Remove node plugin. Node binaries should be turned on manually.
|
||||
- Use default webpack distribution path.
|
||||
- `ru.mipt.npm.base` -> `ru.mipt.npm.project`.
|
||||
@@ -200,26 +352,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Moved internals to internals
|
||||
- Kotlin 1.4.30-RC
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Support of `kaml` and `snake-yaml` in favor of `yamlKt`
|
||||
- Publish plugin
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
## 0.5.2
|
||||
|
||||
### Changed
|
||||
-Publishing in bintray now is automatic.
|
||||
|
||||
## [0.5.2]
|
||||
### Added
|
||||
- Copy resources for jvm modules and jvm source sets in mpp.
|
||||
|
||||
- Copy resources for jvm modules and jvm source sets in mpp.
|
||||
|
||||
23
README.md
23
README.md
@@ -1,28 +1,19 @@
|
||||
[](https://search.maven.org/search?q=g:%22ru.mipt.npm.gradle.project%22%20AND%20a:%22ru.mipt.npm.gradle.project.gradle.plugin%22)
|
||||
[](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`
|
||||
|
||||
## ru.mipt.npm.gradle.js
|
||||
`= kotlin("js") + ru.mipt.npm.gradle.common`
|
||||
|
||||
## ru.mipt.npm.gradle.native
|
||||
add default native targets to `ru.mipt.npm.gradle.mpp`
|
||||
|
||||
## ru.mipt.npm.gradle.node
|
||||
add node target to `ru.mipt.npm.gradle.mpp`
|
||||
## space.kscience.gradle.jvm
|
||||
`= kotlin("jvm") + space.kscience.gradle.common`
|
||||
|
||||
250
build.gradle.kts
250
build.gradle.kts
@@ -1,18 +1,18 @@
|
||||
plugins {
|
||||
alias(libs.plugins.changelog)
|
||||
alias(libs.plugins.dokka)
|
||||
alias(libs.plugins.kotlin.jvm)
|
||||
`java-gradle-plugin`
|
||||
`kotlin-dsl`
|
||||
`maven-publish`
|
||||
signing
|
||||
// `maven-publish`
|
||||
`version-catalog`
|
||||
alias(libs.plugins.jetbrains.changelog)
|
||||
alias(libs.plugins.jetbrains.dokka)
|
||||
alias(libs.plugins.versions.update)
|
||||
alias(libs.plugins.maven.publish.base)
|
||||
}
|
||||
|
||||
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())
|
||||
|
||||
@@ -22,24 +22,22 @@ 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)
|
||||
api("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.asProvider().get()}")
|
||||
api("org.gradle.toolchains:foojay-resolver:1.0.0")
|
||||
api("com.vanniktech:gradle-maven-publish-plugin:0.34.0")
|
||||
api("org.jetbrains.kotlinx:binary-compatibility-validator:0.18.0")
|
||||
api("org.jetbrains.intellij.plugins:gradle-changelog-plugin:${libs.versions.changelog.get()}")
|
||||
api("org.jetbrains.dokka:dokka-gradle-plugin:${libs.versions.dokka.get()}")
|
||||
|
||||
implementation("dev.opensavvy.resources.producer:dev.opensavvy.resources.producer.gradle.plugin:${libs.versions.opensavvy.resources.get()}")
|
||||
implementation("dev.opensavvy.resources.consumer:dev.opensavvy.resources.consumer.gradle.plugin:${libs.versions.opensavvy.resources.get()}")
|
||||
|
||||
implementation(libs.kotlin.serialization)
|
||||
implementation(libs.kotlinx.html)
|
||||
implementation("org.tomlj:tomlj:1.0.0")
|
||||
// // nexus publishing plugin
|
||||
// implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
|
||||
implementation(libs.tomlj)
|
||||
|
||||
implementation("org.freemarker:freemarker:2.3.31")
|
||||
implementation(libs.freemarker)
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
}
|
||||
@@ -52,174 +50,132 @@ 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"
|
||||
description = "Pre-configured JS project"
|
||||
implementationClass = "ru.mipt.npm.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.register("version") {
|
||||
group = "publishing"
|
||||
val versionFileProvider = project.layout.buildDirectory.file("project-version.txt")
|
||||
outputs.file(versionFileProvider)
|
||||
doLast {
|
||||
val versionFile = versionFileProvider.get().asFile
|
||||
versionFile.createNewFile()
|
||||
versionFile.writeText(project.version.toString())
|
||||
}
|
||||
}
|
||||
|
||||
//publishing version catalog
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
catalog.versionCatalog {
|
||||
from(files("gradle/libs.versions.toml"))
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
//publishing the artifact
|
||||
mavenPublishing {
|
||||
publishing.publications.create<MavenPublication>("version-catalog") {
|
||||
from(components["versionCatalog"])
|
||||
artifactId = "version-catalog"
|
||||
|
||||
val sourcesJar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
from(sourceSets.named("main").get().allSource)
|
||||
}
|
||||
pom {
|
||||
name.set("version-catalog")
|
||||
}
|
||||
}
|
||||
|
||||
val javadocsJar by tasks.creating(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.dokkaHtml)
|
||||
}
|
||||
val vcs = "https://git.sciprog.center/kscience/gradle-tools"
|
||||
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
val vcs = "https://github.com/mipt-npm/gradle-tools"
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set(vcs)
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications {
|
||||
create<MavenPublication>("catalog") {
|
||||
from(components["versionCatalog"])
|
||||
artifactId = "version-catalog"
|
||||
|
||||
pom {
|
||||
name.set("version-catalog")
|
||||
}
|
||||
}
|
||||
|
||||
withType<MavenPublication> {
|
||||
artifact(sourcesJar)
|
||||
artifact(javadocsJar)
|
||||
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set(vcs)
|
||||
|
||||
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 {
|
||||
url.set(vcs)
|
||||
tag.set(project.version.toString())
|
||||
}
|
||||
}
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
if (spaceUser != null && spaceToken != null) {
|
||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||
|
||||
repositories.maven {
|
||||
name = "space"
|
||||
url = uri(spaceRepo)
|
||||
|
||||
credentials {
|
||||
username = spaceUser
|
||||
password = spaceToken
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id.set("SPC")
|
||||
name.set("Scientific Programming Centre")
|
||||
organization.set("SPC")
|
||||
organizationUrl.set("https://sciprog.center/")
|
||||
}
|
||||
}
|
||||
|
||||
val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String
|
||||
val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String
|
||||
scm {
|
||||
url.set(vcs)
|
||||
tag.set(project.version.toString())
|
||||
}
|
||||
}
|
||||
|
||||
if (sonatypeUser != null && sonatypePassword != null) {
|
||||
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
|
||||
"https://oss.sonatype.org/content/repositories/snapshots"
|
||||
} else {
|
||||
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
}
|
||||
val spaceRepo = "https://maven.sciprog.center/kscience"
|
||||
val spcUser: String? = findProperty("publishing.spc.user") as? String
|
||||
val spcToken: String? = findProperty("publishing.spc.token") as? String
|
||||
|
||||
repositories.maven {
|
||||
name = "sonatype"
|
||||
url = uri(sonatypeRepo)
|
||||
if (spcUser != null && spcToken != null) {
|
||||
publishing.repositories.maven {
|
||||
name = "spc"
|
||||
url = uri(spaceRepo)
|
||||
|
||||
credentials {
|
||||
username = sonatypeUser
|
||||
password = sonatypePassword
|
||||
}
|
||||
}
|
||||
|
||||
if (plugins.findPlugin("signing") == null) {
|
||||
apply<SigningPlugin>()
|
||||
}
|
||||
|
||||
signing {
|
||||
//useGpgCmd()
|
||||
sign(publications)
|
||||
credentials {
|
||||
username = spcUser
|
||||
password = spcToken
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val centralUser: String? = project.findProperty("mavenCentralUsername") as? String
|
||||
val centralPassword: String? = project.findProperty("mavenCentralPassword") as? String
|
||||
|
||||
if (centralUser != null && centralPassword != null) {
|
||||
publishToMavenCentral()
|
||||
signAllPublications()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "11"
|
||||
kotlin {
|
||||
explicitApiWarning()
|
||||
jvmToolchain(21)
|
||||
}
|
||||
|
||||
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>())
|
||||
}
|
||||
|
||||
versionCatalogUpdate {
|
||||
sortByKey.set(false)
|
||||
|
||||
keep.keepUnusedVersions = true
|
||||
}
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
kotlin.code.style=official
|
||||
|
||||
nl.littlerobots.vcu.resolver=true
|
||||
|
||||
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
|
||||
@@ -1,101 +1,48 @@
|
||||
[versions]
|
||||
tools = "0.11.5-kotlin-1.7.0"
|
||||
kotlin = "1.7.0"
|
||||
atomicfu = "0.17.3"
|
||||
binary-compatibility-validator = "0.9.0"
|
||||
changelog = "1.3.1"
|
||||
dokka = "1.6.21"
|
||||
kotlin-jupyter = "0.11.0-106"
|
||||
kotlinx-benchmark = "0.4.2"
|
||||
kotlinx-cli = "0.3.4"
|
||||
kotlinx-coroutines = "1.6.2"
|
||||
kotlinx-datetime = "0.3.3"
|
||||
kotlinx-html = "0.7.5"
|
||||
kotlinx-knit = "0.4.0"
|
||||
# @pin
|
||||
kotlin = "2.2.20"
|
||||
# @pin
|
||||
tools = "0.19.2-kotlin-2.2.20"
|
||||
atomicfu = "0.29.0"
|
||||
changelog = "2.4.0"
|
||||
compose = "1.8.2"
|
||||
dokka = "2.0.0"
|
||||
jsBom = "2025.9.6"
|
||||
junit = "5.10.2"
|
||||
kotlin-jupyter = "0.15.0-616"
|
||||
kotlinx-benchmark = "0.4.14"
|
||||
kotlinx-cli = "0.3.6"
|
||||
kotlinx-coroutines = "1.10.2"
|
||||
kotlinx-datetime = "0.7.1"
|
||||
kotlinx-html = "0.12.0"
|
||||
kotlinx-knit = "0.5.0"
|
||||
kotlinx-nodejs = "0.0.7"
|
||||
kotlinx-serialization = "1.3.3"
|
||||
ktor = "2.0.2"
|
||||
xmlutil = "0.84.2"
|
||||
yamlkt = "0.11.0"
|
||||
jsBom = "1.0.0-pre.343"
|
||||
junit = "5.8.2"
|
||||
|
||||
[libraries]
|
||||
atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" }
|
||||
atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu" }
|
||||
|
||||
binary-compatibility-validator = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
|
||||
|
||||
changelog-gradle = { module = "org.jetbrains.intellij.plugins:gradle-changelog-plugin", version.ref = "changelog" }
|
||||
|
||||
dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
|
||||
|
||||
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
||||
|
||||
kotlin-jupyter-gradle = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin", version.ref = "kotlin-jupyter" }
|
||||
|
||||
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
|
||||
|
||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-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" }
|
||||
kotlinx-coroutines-reactive = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactive", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-rx2 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-rx3 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx3", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-javafx = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-javafx", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-guava = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-guava", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines" }
|
||||
|
||||
kotlinx-cli = { module = "org.jetbrains.kotlinx:kotlinx-cli", version.ref = "kotlinx-cli" }
|
||||
|
||||
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
|
||||
|
||||
kotlinx-html = { module = "org.jetbrains.kotlinx:kotlinx-html", version.ref = "kotlinx-html" }
|
||||
|
||||
kotlinx-knit = { module = "org.jetbrains.kotlinx:kotlinx-knit", version.ref = "kotlinx-knit" }
|
||||
|
||||
kotlinx-nodejs = { module = "org.jetbrains.kotlinx:kotlinx-nodejs", version.ref = "kotlinx-nodejs" }
|
||||
|
||||
kotlinx-serialization-cbor = { module = "org.jetbrains.kotlinx:kotlinx-serialization-cbor", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-hocon = { module = "org.jetbrains.kotlinx:kotlinx-serialization-hocon", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
|
||||
|
||||
ktor-bom = { module = "io.ktor:ktor-bom", 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" }
|
||||
xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", version.ref = "xmlutil" }
|
||||
|
||||
yamlkt = { module = "net.mamoe.yamlkt:yamlkt", version.ref = "yamlkt" }
|
||||
kotlinx-serialization = "1.9.0"
|
||||
kotlinx-io = "0.8.0"
|
||||
kover = "0.9.1"
|
||||
ktor = "3.2.3"
|
||||
ksp = "2.2.20-2.0.3"
|
||||
logback = "1.5.18"
|
||||
slf4j = "2.0.17"
|
||||
xmlutil = "0.91.2"
|
||||
yamlkt = "0.13.0"
|
||||
opensavvy-resources = "0.5.1"
|
||||
|
||||
[plugins]
|
||||
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
|
||||
|
||||
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||
|
||||
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" }
|
||||
|
||||
maven-publish = "com.vanniktech.maven.publish:0.34.0"
|
||||
maven-publish-base = "com.vanniktech.maven.publish.base:0.34.0"
|
||||
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
compose-jb = { id = "org.jetbrains.compose", version.ref = "compose" }
|
||||
jetbrains-changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
|
||||
jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlin" }
|
||||
kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" }
|
||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
|
||||
kotlin-dsl = "org.gradle.kotlin.kotlin-dsl:6.4.0"
|
||||
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" }
|
||||
kotlin-jupyter-api = { id = "org.jetbrains.kotlin.jupyter.api", version.ref = "kotlin-jupyter" }
|
||||
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
|
||||
kotlin-native-cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
|
||||
kotlin-plugin-allopen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" }
|
||||
kotlin-plugin-jpa = { id = "org.jetbrains.kotlin.plugin.jpa", version.ref = "kotlin" }
|
||||
@@ -105,7 +52,63 @@ kotlin-plugin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", versio
|
||||
kotlin-plugin-scripting = { id = "org.jetbrains.kotlin.plugin.scripting", version.ref = "kotlin" }
|
||||
kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
kotlin-plugin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
|
||||
|
||||
kotlin-jupyter-api = { id = "org.jetbrains.kotlin.jupyter.api", version.ref = "kotlin-jupyter" }
|
||||
|
||||
atomicfu = { id = "org.jetbrains.kotlinx.atomicfu", version.ref = "atomicfu" }
|
||||
kotlinx-benchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "kotlinx-benchmark" }
|
||||
kotlinx-kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
|
||||
kscience-mpp = { id = "space.kscience.gradle.mpp", version.ref = "tools" }
|
||||
kscience-project = { id = "space.kscience.gradle.project", version.ref = "tools" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
ktor = "io.ktor.plugin:3.2.3"
|
||||
opensavvy-resources-producer = { id = "dev.opensavvy.resources.producer", version.ref = "opensavvy-resources" }
|
||||
opensavvy-resources-consumer = { id = "dev.opensavvy.resources.consumer", version.ref = "opensavvy-resources" }
|
||||
versions = "com.github.ben-manes.versions:0.52.0"
|
||||
versions-update = "nl.littlerobots.version-catalog-update:1.0.0"
|
||||
|
||||
[libraries]
|
||||
atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu" }
|
||||
freemarker = "org.freemarker:freemarker:2.3.34"
|
||||
kotlin-js-wrappers = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version.ref = "jsBom" }
|
||||
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
|
||||
kotlin-sam-with-receiver-compiler-plugin-embeddable = { module = "org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin-embeddable", version.ref = "kotlin" }
|
||||
kotlin-scripting-compiler-embeddable = { module = "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable", version.ref = "kotlin" }
|
||||
kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
||||
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
|
||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" }
|
||||
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
|
||||
kotlinx-cli = { module = "org.jetbrains.kotlinx:kotlinx-cli", version.ref = "kotlinx-cli" }
|
||||
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-debug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-guava = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-guava", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-javafx = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-javafx", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-reactive = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactive", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-rx2 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-rx3 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx3", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
|
||||
kotlinx-html = { module = "org.jetbrains.kotlinx:kotlinx-html", version.ref = "kotlinx-html" }
|
||||
kotlinx-knit = { module = "org.jetbrains.kotlinx:kotlinx-knit", version.ref = "kotlinx-knit" }
|
||||
kotlinx-nodejs = { module = "org.jetbrains.kotlinx:kotlinx-nodejs", version.ref = "kotlinx-nodejs" }
|
||||
kotlinx-serialization-cbor = { module = "org.jetbrains.kotlinx:kotlinx-serialization-cbor", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-hocon = { module = "org.jetbrains.kotlinx:kotlinx-serialization-hocon", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-browser = "org.jetbrains.kotlinx:kotlinx-browser:0.5.0"
|
||||
kotlinx-io-core = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinx-io" }
|
||||
kotlinx-io-bytestring = { module = "org.jetbrains.kotlinx:kotlinx-io-bytestring", version.ref = "kotlinx-io" }
|
||||
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
|
||||
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
|
||||
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
|
||||
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
|
||||
tomlj = "org.tomlj:tomlj:1.1.1"
|
||||
xmlutil-core = { module = "io.github.pdvrieze.xmlutil:core", version.ref = "xmlutil" }
|
||||
xmlutil-ktor = { module = "io.github.pdvrieze.xmlutil:ktor", version.ref = "xmlutil" }
|
||||
xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", version.ref = "xmlutil" }
|
||||
yamlkt = { module = "net.mamoe.yamlkt:yamlkt", version.ref = "yamlkt" }
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1 +1,14 @@
|
||||
rootProject.name = "gradle-tools"
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
maven("https://repo.kotlin.link")
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version("0.9.0")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
public open class KScienceCommonPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.configureKScience(
|
||||
KotlinVersion(1, 7, 0)
|
||||
)
|
||||
}
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
@@ -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>()
|
||||
}
|
||||
}
|
||||
@@ -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>()
|
||||
}
|
||||
}
|
||||
@@ -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>()
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
package ru.mipt.npm.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.kotlin.dsl.*
|
||||
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.*
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param vcsUrl URL of the repository's web interface.
|
||||
* @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) {
|
||||
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") }
|
||||
}
|
||||
}
|
||||
|
||||
isVcsInitialized = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds GitHub as VCS and adds GitHub Packages Maven repository to publishing.
|
||||
*
|
||||
* @param githubProject the GitHub project.
|
||||
* @param githubOrg the GitHub user or organization.
|
||||
* @param addToRelease publish packages in the `release` task to the GitHub repository.
|
||||
*/
|
||||
public fun github(
|
||||
githubProject: String,
|
||||
githubOrg: String = "mipt-npm",
|
||||
addToRelease: 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) {
|
||||
try {
|
||||
project.addGithubPublishing(githubOrg, githubProject)
|
||||
repositoryNames += "github"
|
||||
} catch (t: Throwable) {
|
||||
project.logger.error("Failed to set up github publication", t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Space Packages Maven repository to publishing.
|
||||
*
|
||||
* @param spaceRepo the repository URL.
|
||||
* @param addToRelease publish packages in the `release` 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",
|
||||
) {
|
||||
project.addSpacePublishing(spaceRepo)
|
||||
|
||||
if (addToRelease) repositoryNames += "space"
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Sonatype Maven repository to publishing.
|
||||
*
|
||||
* @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" }
|
||||
project.addSonatypePublishing()
|
||||
|
||||
if (addToRelease) repositoryNames += "sonatype"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies third-party plugins (Dokka, Changelog, binary compatibility validator); configures Maven publishing, README
|
||||
* generation.
|
||||
*/
|
||||
public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project): Unit = target.run {
|
||||
apply<ChangelogPlugin>()
|
||||
apply<DokkaPlugin>()
|
||||
apply<BinaryCompatibilityValidatorPlugin>()
|
||||
|
||||
afterEvaluate {
|
||||
if (isSnapshot()) {
|
||||
configure<ApiValidationExtension> {
|
||||
validationDisabled = true
|
||||
}
|
||||
} else {
|
||||
configure<ChangelogPluginExtension> {
|
||||
version.set(project.version.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val rootReadmeExtension = KScienceReadmeExtension(this)
|
||||
val ksciencePublish = KSciencePublishingExtension(this)
|
||||
extensions.add("ksciencePublish", ksciencePublish)
|
||||
extensions.add("readme", rootReadmeExtension)
|
||||
|
||||
//Add readme generators to individual subprojects
|
||||
subprojects {
|
||||
val readmeExtension = KScienceReadmeExtension(this)
|
||||
extensions.add("readme", readmeExtension)
|
||||
val generateReadme by tasks.creating {
|
||||
group = "documentation"
|
||||
description = "Generate a README file if stub is present"
|
||||
|
||||
if (readmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(readmeExtension.readmeTemplate)
|
||||
}
|
||||
readmeExtension.inputFiles.forEach {
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
|
||||
val readmeFile = this@subprojects.file("README.md")
|
||||
outputs.file(readmeFile)
|
||||
|
||||
doLast {
|
||||
val readmeString = readmeExtension.readmeString()
|
||||
if (readmeString != null) {
|
||||
readmeFile.writeText(readmeString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tasks.withType<AbstractDokkaTask> {
|
||||
// dependsOn(generateReadme)
|
||||
// }
|
||||
}
|
||||
|
||||
val generateReadme by tasks.creating {
|
||||
group = "documentation"
|
||||
description = "Generate a README file and a feature matrix if stub is present"
|
||||
|
||||
subprojects {
|
||||
tasks.findByName("generateReadme")?.let {
|
||||
dependsOn(it)
|
||||
}
|
||||
}
|
||||
|
||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(rootReadmeExtension.readmeTemplate)
|
||||
}
|
||||
|
||||
rootReadmeExtension.inputFiles.forEach {
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
|
||||
val readmeFile = project.file("README.md")
|
||||
outputs.file(readmeFile)
|
||||
|
||||
doLast {
|
||||
// val projects = subprojects.associate {
|
||||
// val normalizedPath = it.path.replaceFirst(":","").replace(":","/")
|
||||
// it.path.replace(":","/") to it.extensions.findByType<KScienceReadmeExtension>()
|
||||
// }
|
||||
|
||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||
|
||||
val modulesString = buildString {
|
||||
subprojects.forEach { subproject ->
|
||||
val name = subproject.name
|
||||
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
|
||||
val ext = subproject.extensions.findByType<KScienceReadmeExtension>()
|
||||
appendLine("\n### [$name]($path)")
|
||||
if (ext != null) {
|
||||
appendLine("> ${ext.description}")
|
||||
appendLine(">\n> **Maturity**: ${ext.maturity}")
|
||||
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
|
||||
if (featureString.isNotBlank()) {
|
||||
appendLine(">\n> **Features:**")
|
||||
appendLine(featureString)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootReadmeExtension.property("modules", modulesString)
|
||||
|
||||
rootReadmeExtension.readmeString()?.let {
|
||||
readmeFile.writeText(it)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<AbstractDokkaTask> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable API validation for snapshots
|
||||
if (isSnapshot()) {
|
||||
extensions.findByType<ApiValidationExtension>()?.apply {
|
||||
validationDisabled = true
|
||||
logger.warn("API validation is disabled for snapshot or dev version")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public companion object {
|
||||
public const val RELEASE_GROUP: String = "release"
|
||||
}
|
||||
}
|
||||
@@ -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.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
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")
|
||||
|
||||
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> {
|
||||
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}")
|
||||
}
|
||||
}
|
||||
|
||||
if (explicitApi == null) explicitApiWarning()
|
||||
}
|
||||
tasks.withType<KotlinCompile> {
|
||||
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> {
|
||||
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}")
|
||||
}
|
||||
}
|
||||
|
||||
if (explicitApi == null) explicitApiWarning()
|
||||
}
|
||||
|
||||
(tasks.findByName("processResources") as? Copy)?.apply {
|
||||
fromJsDependencies("runtimeClasspath")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
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()
|
||||
}
|
||||
|
||||
if (explicitApi == null) explicitApiWarning()
|
||||
}
|
||||
}
|
||||
|
||||
// apply dokka for all projects
|
||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||
apply<DokkaPlugin>()
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,233 +0,0 @@
|
||||
package ru.mipt.npm.gradle.internal
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPom
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.plugins.signing.SigningExtension
|
||||
import org.gradle.plugins.signing.SigningPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.targets
|
||||
|
||||
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
||||
?: System.getenv(propertyName)
|
||||
|
||||
internal fun Project.requestProperty(propertyName: String): String = requestPropertyOrNull(propertyName)
|
||||
?: error("Property $propertyName not defined")
|
||||
|
||||
|
||||
internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit = {}) = allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
publications.create<MavenPublication>("js") {
|
||||
kotlin.targets.flatMap { it.components }.forEach {
|
||||
from(it)
|
||||
}
|
||||
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
plugins.withId("org.jetbrains.kotlin.jvm") {
|
||||
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
|
||||
|
||||
val sourcesJar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
kotlin.sourceSets.forEach {
|
||||
from(it.kotlin)
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
publications.create<MavenPublication>("jvm") {
|
||||
kotlin.target.components.forEach {
|
||||
from(it)
|
||||
}
|
||||
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
mavenPomConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.isSnapshot() = "dev" in version.toString() || version.toString().endsWith("SNAPSHOT")
|
||||
|
||||
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 = requestProperty("publishing.github.user")
|
||||
val githubToken: String = requestProperty("publishing.github.token")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
logger.info("Adding github publishing to project [${project.name}]")
|
||||
|
||||
repositories.maven {
|
||||
name = "github"
|
||||
url = uri("https://maven.pkg.github.com/$githubOrg/$githubProject/")
|
||||
|
||||
credentials {
|
||||
username = githubUser
|
||||
password = githubToken
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.addSpacePublishing(spaceRepo: String) {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping space publishing because publishing is disabled")
|
||||
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}]")
|
||||
|
||||
repositories.maven {
|
||||
name = "space"
|
||||
url = uri(spaceRepo)
|
||||
|
||||
credentials {
|
||||
username = spaceUser
|
||||
password = spaceToken
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.addSonatypePublishing() {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping sonatype publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
if (isSnapshot()) {
|
||||
logger.info("Sonatype publishing skipped for dev version")
|
||||
return
|
||||
}
|
||||
|
||||
if (requestPropertyOrNull("publishing.sonatype") == "false") {
|
||||
logger.info("Skipping sonatype publishing because `publishing.sonatype == false`")
|
||||
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://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
name = "sonatype"
|
||||
url = uri(sonatypeRepo)
|
||||
|
||||
credentials {
|
||||
username = sonatypeUser
|
||||
password = sonatypePassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
522
src/main/kotlin/space/kscience/gradle/KScienceExtension.kt
Normal file
522
src/main/kotlin/space/kscience/gradle/KScienceExtension.kt
Normal file
@@ -0,0 +1,522 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
import org.gradle.api.provider.Property
|
||||
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.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
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.KotlinJsBrowserDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinWasmJsTargetDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinWasmWasiTargetDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import space.kscience.gradle.internal.defaultKotlinJvmOpts
|
||||
import space.kscience.gradle.internal.requestPropertyOrNull
|
||||
import space.kscience.gradle.internal.useCommonDependency
|
||||
import javax.inject.Inject
|
||||
|
||||
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 = 17
|
||||
|
||||
public abstract class KScienceExtension @Inject constructor(public val project: Project) : ExtensionAware {
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.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.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)
|
||||
|
||||
|
||||
/**
|
||||
* Add context parameters to the project
|
||||
*/
|
||||
public fun useContextParameters() {
|
||||
project.tasks.withType<KotlinCompile> {
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll("-Xcontext-parameters")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Use useContextParameters", ReplaceWith("useContextParameters()"))
|
||||
public fun useContextReceivers(): Unit = useContextParameters()
|
||||
|
||||
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 wasmJsMain: DefaultSourceSet get() = DefaultSourceSet("wasmJsMain")
|
||||
public val wasmJsTest: DefaultSourceSet get() = DefaultSourceSet("wasmJsTest")
|
||||
|
||||
}
|
||||
|
||||
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.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(private val project: Project) {
|
||||
|
||||
|
||||
internal companion object {
|
||||
private fun defaultNativeTargets(project: Project): Set<KScienceNativeTarget> =
|
||||
when (val targets = project.requestPropertyOrNull("publishing.targets")) {
|
||||
null -> setOf(
|
||||
KScienceNativeTarget.linuxX64,
|
||||
KScienceNativeTarget.mingwX64,
|
||||
KScienceNativeTarget.macosX64,
|
||||
KScienceNativeTarget.macosArm64,
|
||||
KScienceNativeTarget.iosX64,
|
||||
KScienceNativeTarget.iosArm64,
|
||||
KScienceNativeTarget.iosSimulatorArm64,
|
||||
)
|
||||
|
||||
else -> targets.split(",").mapTo(HashSet()) {
|
||||
KScienceNativeTarget(KotlinNativePreset.valueOf(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal var targets: Set<KScienceNativeTarget> = defaultNativeTargets(project)
|
||||
|
||||
|
||||
/**
|
||||
* Replace all targets
|
||||
*/
|
||||
public fun setTargets(vararg target: KScienceNativeTarget) {
|
||||
targets = target.toSet()
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a native target
|
||||
*/
|
||||
public fun target(target: KScienceNativeTarget) {
|
||||
targets += target
|
||||
}
|
||||
|
||||
public fun target(
|
||||
preset: KotlinNativePreset,
|
||||
targetName: String = preset.name,
|
||||
targetConfiguration: KotlinNativeTarget.() -> Unit = { },
|
||||
): Unit = target(KScienceNativeTarget(preset, targetName, targetConfiguration))
|
||||
}
|
||||
|
||||
public abstract class KScienceMppExtension @Inject constructor(project: Project) : KScienceExtension(project) {
|
||||
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
public fun KotlinJvmTarget.application(
|
||||
mainClassName: String
|
||||
) {
|
||||
binaries {
|
||||
executable {
|
||||
mainClass.set(mainClassName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public fun KotlinJsTargetDsl.application(
|
||||
moduleName: String? = null,
|
||||
) {
|
||||
binaries.executable()
|
||||
this.project.plugins.apply("dev.opensavvy.resources.consumer")
|
||||
moduleName?.let {
|
||||
outputModuleName.set(moduleName)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable jvm target
|
||||
*/
|
||||
public fun jvm(block: KotlinJvmTarget.() -> Unit = {}) {
|
||||
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
project.configure<KotlinMultiplatformExtension> {
|
||||
jvm {
|
||||
compilerOptions {
|
||||
defaultKotlinJvmOpts()
|
||||
}
|
||||
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 {
|
||||
browser()
|
||||
useEsModules()
|
||||
block()
|
||||
}
|
||||
sourceSets {
|
||||
getByName("jsMain") {
|
||||
dependencies {
|
||||
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
||||
}
|
||||
}
|
||||
getByName("jsTest") {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
project.plugins.apply("dev.opensavvy.resources.producer")
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Wasm/Js target
|
||||
*/
|
||||
@OptIn(ExperimentalWasmDsl::class)
|
||||
public fun wasmJs(block: KotlinWasmJsTargetDsl.() -> Unit = {}) {
|
||||
|
||||
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
project.configure<KotlinMultiplatformExtension> {
|
||||
wasmJs {
|
||||
browser {
|
||||
testTask {
|
||||
useKarma {
|
||||
useChromeHeadless()
|
||||
}
|
||||
}
|
||||
}
|
||||
useEsModules()
|
||||
block()
|
||||
}
|
||||
sourceSets {
|
||||
getByName("wasmJsTest") {
|
||||
dependencies {
|
||||
implementation(kotlin("test-wasm-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalWasmDsl::class)
|
||||
public fun wasmWasi(block: KotlinWasmWasiTargetDsl.() -> Unit = {}) {
|
||||
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
project.configure<KotlinMultiplatformExtension> {
|
||||
wasmWasi {
|
||||
block()
|
||||
}
|
||||
sourceSets {
|
||||
getByName("wasmWasiTest") {
|
||||
dependencies {
|
||||
implementation(kotlin("test-wasm-wasi"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Use wasmJs", ReplaceWith("wasmJs(block)"))
|
||||
public fun wasm(block: KotlinWasmJsTargetDsl.() -> Unit = {}): Unit = wasmJs(block)
|
||||
|
||||
public fun jvmAndJs() {
|
||||
jvm()
|
||||
js()
|
||||
}
|
||||
|
||||
/**
|
||||
* Jvm and Js source sets including copy of Js bundle into JVM resources
|
||||
*
|
||||
* @param mainClassName if present, create a jvm application with it as an entry point
|
||||
*/
|
||||
public fun fullStack(
|
||||
bundleName: String = "js/bundle.js",
|
||||
mainClassName: String? = null,
|
||||
development: Boolean = false,
|
||||
jvmConfig: KotlinJvmTarget.() -> Unit = {},
|
||||
jsConfig: KotlinJsTargetDsl.() -> Unit = {},
|
||||
browserConfig: KotlinJsBrowserDsl.() -> Unit = {},
|
||||
) {
|
||||
js {
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
outputFileName = bundleName
|
||||
}
|
||||
browserConfig()
|
||||
}
|
||||
useEsModules()
|
||||
jsConfig()
|
||||
application()
|
||||
}
|
||||
jvm {
|
||||
val processResourcesTaskName =
|
||||
compilations[KotlinCompilation.MAIN_COMPILATION_NAME].processResourcesTaskName
|
||||
|
||||
|
||||
val jsBrowserDistribution = project.tasks.getByName(
|
||||
if (development) "jsBrowserDevelopmentExecutableDistribution" else "jsBrowserDistribution"
|
||||
)
|
||||
|
||||
project.tasks.getByName<ProcessResources>(processResourcesTaskName) {
|
||||
duplicatesStrategy = DuplicatesStrategy.WARN
|
||||
dependsOn(jsBrowserDistribution)
|
||||
from(jsBrowserDistribution)
|
||||
}
|
||||
mainClassName?.let {
|
||||
application(it)
|
||||
}
|
||||
|
||||
jvmConfig()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executable fullstack application
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use fullStack",
|
||||
ReplaceWith("fullStack(bundleName, mainClassName, development, jvmConfig, jsConfig, browserConfig)")
|
||||
)
|
||||
public fun fullStackApplication(
|
||||
mainClassName: String,
|
||||
bundleName: String = "js/bundle.js",
|
||||
development: Boolean = false,
|
||||
jvmConfig: KotlinJvmTarget.() -> Unit = {},
|
||||
jsConfig: KotlinJsTargetDsl.() -> Unit = {},
|
||||
browserConfig: KotlinJsBrowserDsl.() -> Unit = {},
|
||||
): Unit = fullStack(
|
||||
bundleName = bundleName,
|
||||
mainClassName = mainClassName,
|
||||
development = development,
|
||||
jvmConfig = jvmConfig,
|
||||
jsConfig = jsConfig,
|
||||
browserConfig = browserConfig
|
||||
)
|
||||
|
||||
/**
|
||||
* Enable all supported native targets
|
||||
*/
|
||||
public fun native(block: KScienceNativeConfiguration.() -> Unit = {}): Unit = with(project) {
|
||||
val nativeConfiguration = KScienceNativeConfiguration(this).apply(block)
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
nativeConfiguration.targets.forEach { 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
|
||||
)
|
||||
}
|
||||
}
|
||||
applyDefaultHierarchyTemplate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension(): T {
|
||||
// extensions.findByType<T>()?.let { return it }
|
||||
// return constructor(this).also {
|
||||
// extensions.add("kscience", it)
|
||||
// }
|
||||
|
||||
return extensions.create("kscience", T::class.java)
|
||||
}
|
||||
60
src/main/kotlin/space/kscience/gradle/KScienceJVMPlugin.kt
Normal file
60
src/main/kotlin/space/kscience/gradle/KScienceJVMPlugin.kt
Normal file
@@ -0,0 +1,60 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
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 space.kscience.gradle.internal.applySettings
|
||||
import space.kscience.gradle.internal.defaultKotlinCommonArgs
|
||||
import space.kscience.gradle.internal.defaultKotlinJvmOpts
|
||||
|
||||
public open class KScienceJVMPlugin : KSciencePlugin {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
|
||||
logger.warn("KScience JVM plugin is deprecated. Use MPP.")
|
||||
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()
|
||||
compilerOptions{
|
||||
defaultKotlinJvmOpts()
|
||||
compilerOptions.freeCompilerArgs.addAll(defaultKotlinCommonArgs)
|
||||
}
|
||||
}
|
||||
|
||||
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<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
// apply dokka for all projects
|
||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||
apply<DokkaPlugin>()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
62
src/main/kotlin/space/kscience/gradle/KScienceMPPlugin.kt
Normal file
62
src/main/kotlin/space/kscience/gradle/KScienceMPPlugin.kt
Normal file
@@ -0,0 +1,62 @@
|
||||
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.invoke
|
||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import space.kscience.gradle.internal.applySettings
|
||||
import space.kscience.gradle.internal.defaultKotlinCommonArgs
|
||||
|
||||
public interface KSciencePlugin : Plugin<Project>
|
||||
|
||||
public open class KScienceMPPlugin : KSciencePlugin {
|
||||
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
|
||||
//apply<KotlinMultiplatformPlugin>() for some reason it does not work
|
||||
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
} else {
|
||||
logger.info("Kotlin MPP plugin is already present")
|
||||
}
|
||||
|
||||
val kscience = registerKScienceExtension<KScienceMppExtension>()
|
||||
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
compilerOptions {
|
||||
freeCompilerArgs.add("-Xexpect-actual-classes")
|
||||
}
|
||||
sourceSets {
|
||||
getByName("commonTest") {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
all {
|
||||
languageSettings.applySettings()
|
||||
compilerOptions.freeCompilerArgs.addAll(defaultKotlinCommonArgs)
|
||||
}
|
||||
}
|
||||
|
||||
if (explicitApi == null) explicitApiWarning()
|
||||
|
||||
//pass compose extension inside kscience extensions to make it available inside kscience block
|
||||
plugins.withId("org.jetbrains.compose") {
|
||||
kscience.extensions.add(
|
||||
"compose",
|
||||
(this@configure as org.gradle.api.plugins.ExtensionAware).extensions.getByName("compose")
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// apply dokka for all projects
|
||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||
apply<DokkaPlugin>()
|
||||
}
|
||||
}
|
||||
}
|
||||
222
src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt
Normal file
222
src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt
Normal file
@@ -0,0 +1,222 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
import com.vanniktech.maven.publish.MavenPublishBaseExtension
|
||||
import com.vanniktech.maven.publish.MavenPublishBasePlugin
|
||||
import kotlinx.validation.ApiValidationExtension
|
||||
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
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 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 org.jetbrains.kotlin.gradle.targets.wasm.yarn.WasmYarnPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.wasm.yarn.WasmYarnRootExtension
|
||||
import space.kscience.gradle.internal.addPublishing
|
||||
import space.kscience.gradle.internal.setupPublication
|
||||
import space.kscience.gradle.internal.withKScience
|
||||
|
||||
/**
|
||||
* Simplifies adding repositories for Maven publishing, responds for releasing tasks for projects.
|
||||
*/
|
||||
public class KSciencePublishingExtension(public val project: Project) {
|
||||
private var isVcsInitialized = false
|
||||
|
||||
/**
|
||||
* Configures Git repository (sources) for the publication.
|
||||
*
|
||||
* @param vcsUrl URL of the repository's web interface.
|
||||
* @param connectionUrl URL of the Git repository.
|
||||
* @param developerConnectionUrl URL of the Git repository for developers.
|
||||
*/
|
||||
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("$connectionPrefix$it") }
|
||||
developerConnectionUrl?.let { developerConnection.set("$connectionPrefix$it") }
|
||||
}
|
||||
pomConfig()
|
||||
}
|
||||
|
||||
isVcsInitialized = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a repository with [repositoryName]. Uses "publishing.$repositoryName.user" and "publishing.$repositoryName.token"
|
||||
* properties pattern to store user and token
|
||||
*/
|
||||
public fun repository(
|
||||
repositoryName: String,
|
||||
url: String,
|
||||
) {
|
||||
require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" }
|
||||
project.addPublishing(repositoryName, url)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add publishing to maven central "new" API
|
||||
*/
|
||||
public fun central(): Unit = with(project) {
|
||||
require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" }
|
||||
if (isInDevelopment) {
|
||||
logger.info("Maven central publishing skipped for development version")
|
||||
} else {
|
||||
allprojects {
|
||||
plugins.withType<MavenPublishBasePlugin> {
|
||||
extensions.configure<MavenPublishBaseExtension> {
|
||||
publishToMavenCentral()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies third-party plugins (Dokka, Changelog, binary compatibility validator); configures Maven publishing, README
|
||||
* generation.
|
||||
*/
|
||||
public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project): Unit = target.run {
|
||||
apply<ChangelogPlugin>()
|
||||
apply<DokkaPlugin>()
|
||||
apply<BinaryCompatibilityValidatorPlugin>()
|
||||
|
||||
val ksciencePublish = KSciencePublishingExtension(this)
|
||||
extensions.add("ksciencePublish", ksciencePublish)
|
||||
|
||||
withKScience {
|
||||
extensions.add("publish", ksciencePublish)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.kotlin.link")
|
||||
google()
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/gradle/gradle/issues/15568
|
||||
tasks.withType<AbstractPublishToMaven>().configureEach {
|
||||
mustRunAfter(tasks.withType<Sign>())
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
if (isInDevelopment) {
|
||||
configure<ApiValidationExtension> {
|
||||
validationDisabled = true
|
||||
}
|
||||
} else {
|
||||
configure<ChangelogPluginExtension> {
|
||||
version.set(project.version.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Add readme generators to individual subprojects and root project
|
||||
allprojects {
|
||||
val readmeExtension = KScienceReadmeExtension(this)
|
||||
extensions.add("readme", readmeExtension)
|
||||
|
||||
withKScience {
|
||||
extensions.add("readme", readmeExtension)
|
||||
}
|
||||
|
||||
val generateReadme by tasks.registering {
|
||||
group = "documentation"
|
||||
description = "Generate a README file if stub is present"
|
||||
|
||||
inputs.property("features", readmeExtension.features)
|
||||
|
||||
if (readmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(readmeExtension.readmeTemplate)
|
||||
}
|
||||
|
||||
readmeExtension.inputFiles.forEach {
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
extensions.findByType<KScienceReadmeExtension>()?.let { subProjectReadmeExtension ->
|
||||
tasks.findByName("generateReadme")?.let { readmeTask ->
|
||||
dependsOn(readmeTask)
|
||||
}
|
||||
inputs.property("features-${name}", subProjectReadmeExtension.features)
|
||||
}
|
||||
}
|
||||
|
||||
val readmeFile = this@allprojects.file("README.md")
|
||||
outputs.file(readmeFile)
|
||||
|
||||
doLast {
|
||||
val readmeString = readmeExtension.readmeString()
|
||||
if (readmeString != null) {
|
||||
readmeFile.writeText(readmeString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<AbstractDokkaTask> {
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tasks.register("version") {
|
||||
group = "publishing"
|
||||
val versionFileProvider = project.layout.buildDirectory.file("project-version.txt")
|
||||
outputs.file(versionFileProvider)
|
||||
doLast {
|
||||
val versionFile = versionFileProvider.get().asFile
|
||||
versionFile.createNewFile()
|
||||
versionFile.writeText(project.version.toString())
|
||||
}
|
||||
}
|
||||
|
||||
// Disable API validation for snapshots
|
||||
if (isInDevelopment) {
|
||||
extensions.findByType<ApiValidationExtension>()?.apply {
|
||||
validationDisabled = true
|
||||
logger.warn("API validation is disabled for snapshot or dev version")
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withType<YarnPlugin> {
|
||||
rootProject.configure<YarnRootExtension> {
|
||||
lockFileDirectory = rootDir.resolve("gradle/js")
|
||||
yarnLockMismatchReport = YarnLockMismatchReport.WARNING
|
||||
}
|
||||
}
|
||||
plugins.withType<WasmYarnPlugin> {
|
||||
rootProject.configure<WasmYarnRootExtension> {
|
||||
lockFileDirectory = rootDir.resolve("gradle/wasm")
|
||||
yarnLockMismatchReport = YarnLockMismatchReport.WARNING
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public companion object {
|
||||
public const val DEPLOY_GROUP: String = "deploy"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ru.mipt.npm.gradle
|
||||
package space.kscience.gradle
|
||||
|
||||
import freemarker.cache.StringTemplateLoader
|
||||
import freemarker.template.Configuration
|
||||
@@ -10,11 +10,10 @@ import kotlinx.html.stream.createHTML
|
||||
import kotlinx.validation.ApiValidationExtension
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.intellij.lang.annotations.Language
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
import java.io.StringWriter
|
||||
import kotlin.collections.component1
|
||||
import kotlin.collections.component2
|
||||
import kotlin.collections.set
|
||||
|
||||
public enum class Maturity {
|
||||
PROTOTYPE,
|
||||
@@ -32,7 +31,8 @@ private fun Template.processToString(args: Map<String, Any?>): String {
|
||||
|
||||
|
||||
public class KScienceReadmeExtension(public val project: Project) {
|
||||
public var description: String = project.description ?: ""
|
||||
public var description: String? = null
|
||||
get() = field ?: project.description
|
||||
|
||||
public var maturity: Maturity = Maturity.EXPERIMENTAL
|
||||
set(value) {
|
||||
@@ -69,14 +69,14 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
private val fmLoader = StringTemplateLoader().apply {
|
||||
putTemplate(
|
||||
"artifact",
|
||||
this@KScienceReadmeExtension.javaClass.getResource("/templates/ARTIFACT-TEMPLATE.md")!!.readText()
|
||||
KScienceReadmeExtension::class.java.getResource("/templates/ARTIFACT-TEMPLATE.md")!!.readText()
|
||||
)
|
||||
if (readmeTemplate.exists()) {
|
||||
putTemplate("readme", readmeTemplate.readText())
|
||||
} else if (useDefaultReadmeTemplate) {
|
||||
putTemplate(
|
||||
"readme",
|
||||
this@KScienceReadmeExtension.javaClass.getResource("/templates/README-TEMPLATE.md")!!.readText()
|
||||
KScienceReadmeExtension::class.java.getResource("/templates/README-TEMPLATE.md")!!.readText()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -86,19 +86,25 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
templateLoader = fmLoader
|
||||
}
|
||||
|
||||
public data class Feature(val id: String, val description: String, val ref: String?, val name: String = id)
|
||||
public data class Feature(val id: String, val description: String, val ref: String?, val name: String = id): Serializable
|
||||
|
||||
public val features: MutableList<Feature> = ArrayList()
|
||||
public val features: MutableList<Feature> = mutableListOf()
|
||||
|
||||
@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) {
|
||||
/**
|
||||
* A plain readme feature with description
|
||||
*/
|
||||
public fun feature(
|
||||
id: String,
|
||||
@Language("File") ref: String? = null,
|
||||
name: String = id,
|
||||
@Language("markdown") description: () -> String,
|
||||
) {
|
||||
features += Feature(id, description(), ref, name)
|
||||
}
|
||||
|
||||
/**
|
||||
* A readme feature with HTML description
|
||||
*/
|
||||
public fun featureWithHtml(
|
||||
id: String,
|
||||
ref: String? = null,
|
||||
@@ -113,30 +119,47 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
features += Feature(id, text, ref, name)
|
||||
}
|
||||
|
||||
private val properties: MutableMap<String, () -> Any?> = mutableMapOf(
|
||||
"name" to { project.name },
|
||||
"group" to { project.group },
|
||||
"version" to { project.version },
|
||||
"description" to { project.description ?: "" },
|
||||
private val properties: MutableMap<String, Project.() -> Any?> = mutableMapOf(
|
||||
"name" to { name },
|
||||
"group" to { group },
|
||||
"version" to { version },
|
||||
"description" to { description ?: "" },
|
||||
"features" to { featuresString() },
|
||||
"published" to { project.plugins.findPlugin("maven-publish") != null },
|
||||
"published" to { plugins.findPlugin("maven-publish") != null },
|
||||
"artifact" to {
|
||||
val projectProperties = mapOf(
|
||||
"name" to project.name,
|
||||
"group" to project.group,
|
||||
"version" to project.version
|
||||
"name" to name,
|
||||
"group" to group,
|
||||
"version" to version
|
||||
)
|
||||
fmCfg.getTemplate("artifact").processToString(projectProperties)
|
||||
},
|
||||
"modules" to {
|
||||
buildString {
|
||||
subprojects.forEach { subproject ->
|
||||
subproject.extensions.findByType<KScienceReadmeExtension>()?.let { ext ->
|
||||
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
|
||||
appendLine("\n### [$path]($path)")
|
||||
ext.description?.let { appendLine("> ${ext.description}") }
|
||||
appendLine(">\n> **Maturity**: ${ext.maturity}")
|
||||
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
|
||||
if (featureString.isNotBlank()) {
|
||||
appendLine(">\n> **Features:**")
|
||||
appendLine(featureString)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
public fun getPropertyValues(): Map<String, Any?> = properties.mapValues { (_, value) -> value() }
|
||||
public fun getPropertyValues(): Map<String, Any?> = properties.mapValues { (_, value) -> project.value() }
|
||||
|
||||
public fun property(key: String, value: Any?) {
|
||||
properties[key] = { value }
|
||||
}
|
||||
|
||||
public fun property(key: String, value: () -> Any?) {
|
||||
public fun property(key: String, value: Project.() -> Any?) {
|
||||
properties[key] = value
|
||||
}
|
||||
|
||||
@@ -169,7 +192,7 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
*/
|
||||
internal fun featuresString(itemPrefix: String = " - ", pathPrefix: String = ""): String = buildString {
|
||||
features.forEach {
|
||||
appendLine("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description}")
|
||||
appendLine("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description.lines().firstOrNull() ?: ""}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,4 +205,38 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
project.logger.warn("Template with name ${ex.templateName} not found in ${project.name}")
|
||||
null
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as KScienceReadmeExtension
|
||||
|
||||
if (project != other.project) return false
|
||||
if (maturity != other.maturity) return false
|
||||
if (useDefaultReadmeTemplate != other.useDefaultReadmeTemplate) return false
|
||||
if (readmeTemplate != other.readmeTemplate) return false
|
||||
if (fmLoader != other.fmLoader) return false
|
||||
if (fmCfg != other.fmCfg) return false
|
||||
if (features != other.features) return false
|
||||
if (properties != other.properties) return false
|
||||
if (inputFiles != other.inputFiles) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = project.hashCode()
|
||||
result = 31 * result + maturity.hashCode()
|
||||
result = 31 * result + useDefaultReadmeTemplate.hashCode()
|
||||
result = 31 * result + readmeTemplate.hashCode()
|
||||
result = 31 * result + fmLoader.hashCode()
|
||||
result = 31 * result + fmCfg.hashCode()
|
||||
result = 31 * result + features.hashCode()
|
||||
result = 31 * result + properties.hashCode()
|
||||
result = 31 * result + inputFiles.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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")!!
|
||||
@@ -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,
|
||||
54
src/main/kotlin/space/kscience/gradle/internal/common.kt
Normal file
54
src/main/kotlin/space/kscience/gradle/internal/common.kt
Normal file
@@ -0,0 +1,54 @@
|
||||
package space.kscience.gradle.internal
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||
import space.kscience.gradle.KScienceExtension
|
||||
import space.kscience.gradle.KSciencePlugin
|
||||
import space.kscience.gradle.KScienceVersions
|
||||
|
||||
internal val defaultKotlinCommonArgs: List<String> = listOf(
|
||||
"-Xexpect-actual-classes"
|
||||
)
|
||||
|
||||
internal fun KotlinJvmCompilerOptions.defaultKotlinJvmOpts() {
|
||||
jvmDefault.set(JvmDefaultMode.NO_COMPATIBILITY)
|
||||
}
|
||||
|
||||
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.time.ExperimentalTime")
|
||||
optIn("kotlin.ExperimentalUnsignedTypes")
|
||||
optIn("kotlin.ExperimentalStdlibApi")
|
||||
optIn("kotlin.contracts.ExperimentalContracts")
|
||||
optIn("kotlin.js.ExperimentalJsExport")
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the project using the `KScienceExtension` provided by the `KSciencePlugin`.
|
||||
*
|
||||
* This function locates the `KSciencePlugin` in the project, and if found, applies the given
|
||||
* configuration block to the `KScienceExtension` associated with the plugin.
|
||||
*
|
||||
* @param block a configuration block that is applied to the `KScienceExtension` instance, allowing
|
||||
* users to customize the project according to the extension's capabilities.
|
||||
*/
|
||||
internal fun Project.withKScience(block: KScienceExtension.() -> Unit) {
|
||||
plugins.withType<KSciencePlugin>().configureEach {
|
||||
extensions.findByType<KScienceExtension>()?.apply(block)
|
||||
}
|
||||
}
|
||||
@@ -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>,
|
||||
112
src/main/kotlin/space/kscience/gradle/internal/publishing.kt
Normal file
112
src/main/kotlin/space/kscience/gradle/internal/publishing.kt
Normal file
@@ -0,0 +1,112 @@
|
||||
package space.kscience.gradle.internal
|
||||
|
||||
import com.vanniktech.maven.publish.MavenPublishBaseExtension
|
||||
import com.vanniktech.maven.publish.MavenPublishBasePlugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPom
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
|
||||
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
||||
?: System.getenv(propertyName)
|
||||
|
||||
internal fun Project.requestProperty(propertyName: String): String = requestPropertyOrNull(propertyName)
|
||||
?: error("Property $propertyName not defined")
|
||||
|
||||
|
||||
internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit = {}) = allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
apply<MavenPublishBasePlugin>()
|
||||
|
||||
configure<PublishingExtension> {
|
||||
|
||||
plugins.withId("org.jetbrains.kotlin.jvm") {
|
||||
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
|
||||
|
||||
val sourcesJar by tasks.registering(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
kotlin.sourceSets.forEach {
|
||||
from(it.kotlin)
|
||||
}
|
||||
}
|
||||
|
||||
publications.create<MavenPublication>("jvm") {
|
||||
from(project.components["java"])
|
||||
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications.withType<MavenPublication> {
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description ?: project.name)
|
||||
|
||||
scm {
|
||||
tag.set(project.version.toString())
|
||||
}
|
||||
|
||||
mavenPomConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId("org.jetbrains.dokka") {
|
||||
val dokkaJar by tasks.registering(Jar::class) {
|
||||
group = "documentation"
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.findByName("dokkaGenerate"))
|
||||
}
|
||||
publications.withType<MavenPublication> {
|
||||
artifact(dokkaJar)
|
||||
}
|
||||
}
|
||||
|
||||
//apply signing if signing configuration is available
|
||||
if (requestPropertyOrNull("signing.password") != null || requestPropertyOrNull("signing.secretKeyRingFile") != null) {
|
||||
plugins.withType<MavenPublishBasePlugin> {
|
||||
extensions.configure<MavenPublishBaseExtension> {
|
||||
signAllPublications()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.warn("Signing information is not provided. Skipping artefact signing.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.addPublishing(
|
||||
repositoryName: String,
|
||||
urlString: String
|
||||
) {
|
||||
require(repositoryName.matches("\\w*".toRegex())) { "Repository name must contain only letters or numbers" }
|
||||
val user: String? = requestPropertyOrNull("publishing.$repositoryName.user")
|
||||
val token: String? = requestPropertyOrNull("publishing.$repositoryName.token")
|
||||
|
||||
if (user == null || token == null) {
|
||||
logger.info("Skipping $repositoryName publishing because $repositoryName credentials are not defined")
|
||||
return
|
||||
}
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
logger.info("Adding $repositoryName publishing to project [${project.name}]")
|
||||
|
||||
repositories.maven {
|
||||
name = repositoryName
|
||||
url = uri(urlString)
|
||||
|
||||
credentials {
|
||||
username = user
|
||||
password = token
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/main/kotlin/space/kscience/gradle/pomConfig.kt
Normal file
24
src/main/kotlin/space/kscience/gradle/pomConfig.kt
Normal 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("SPC")
|
||||
organizationUrl.set("https://sciprog.center/")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,6 @@
|
||||
|
||||
The Maven coordinates of this project are `${group}:${name}:${version}`.
|
||||
|
||||
**Gradle Groovy:**
|
||||
```groovy
|
||||
repositories {
|
||||
maven { url 'https://repo.kotlin.link' }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation '${group}:${name}:${version}'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
repositories {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import space.kscience.gradle.KScienceVersions
|
||||
|
||||
class TestPlugins {
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user