Compare commits
66 Commits
v0.11.3-ko
...
master
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
|
53c399d542 | ||
8ba91f805e | |||
19f3d1ba5d | |||
90880fc10f | |||
eed0f274c7 | |||
e3ecfb54c9 | |||
6526a486f9 | |||
07bde0e593 | |||
368ed94c52 | |||
|
277ab651f8 | ||
|
a9b35eb466 | ||
6e9ef8326b |
6
.github/workflows/publish.yml
vendored
6
.github/workflows/publish.yml
vendored
@ -19,6 +19,6 @@ jobs:
|
|||||||
- uses: gradle/gradle-build-action@v2
|
- uses: gradle/gradle-build-action@v2
|
||||||
with:
|
with:
|
||||||
arguments: |
|
arguments: |
|
||||||
publishAllPublicationsToSpaceRepository
|
publishAllPublicationsToSpaceRepository
|
||||||
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }}
|
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }}
|
||||||
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }}
|
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }}
|
||||||
|
43
.space.kts
Normal file
43
.space.kts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import kotlin.io.path.readText
|
||||||
|
|
||||||
|
job("Build") {
|
||||||
|
gradlew("openjdk:11", "build")
|
||||||
|
}
|
||||||
|
|
||||||
|
job("Publish"){
|
||||||
|
startOn {
|
||||||
|
gitPush { enabled = false }
|
||||||
|
}
|
||||||
|
container("openjdk:11") {
|
||||||
|
env["SPACE_USER"] = Secrets("space_user")
|
||||||
|
env["SPACE_TOKEN"] = Secrets("space_token")
|
||||||
|
kotlinScript { api ->
|
||||||
|
|
||||||
|
val spaceUser = System.getenv("SPACE_USER")
|
||||||
|
val spaceToken = System.getenv("SPACE_TOKEN")
|
||||||
|
|
||||||
|
// write version to the build directory
|
||||||
|
api.gradlew("version")
|
||||||
|
|
||||||
|
//read version from build file
|
||||||
|
val version = java.nio.file.Path.of("build/project-version.txt").readText()
|
||||||
|
|
||||||
|
api.space().projects.automation.deployments.start(
|
||||||
|
project = api.projectIdentifier(),
|
||||||
|
targetIdentifier = TargetIdentifier.Key("gradle-tools"),
|
||||||
|
version = version,
|
||||||
|
// automatically update deployment status based on a status of a job
|
||||||
|
syncWithAutomationJob = true
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
api.gradlew(
|
||||||
|
"publishAllPublicationsToSpaceRepository",
|
||||||
|
"-Ppublishing.space.user=\"$spaceUser\"",
|
||||||
|
"-Ppublishing.space.token=\"$spaceToken\"",
|
||||||
|
)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
println("Publish failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
124
CHANGELOG.md
124
CHANGELOG.md
@ -1,75 +1,133 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
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/),
|
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
## 0.14.4-kotlin-1.8.20-RC - 2023-03-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Easier dependency handling in `kscience` block
|
||||||
|
- Customizable base jdk version
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- MPP does not use JVM and JS(IR) targets anymore. They could be turned manually via `js()`, `jvm()` or `fullStack()`
|
||||||
|
- Signing is not applied if signingId is not provided
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- FX plugins
|
||||||
|
- Unnecessary library shortcuts (html and datetime)
|
||||||
|
- deploy/release tasks
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Gradle 8 compatibility
|
||||||
|
- Dokka publication
|
||||||
|
- issues with test sourcesets
|
||||||
|
|
||||||
|
## 0.13.4-kotlin-1.8.0 - 2022-12-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Public `isInDevelopment` project flag
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Require manual pom config for publications
|
||||||
|
- Kotlin 1.8.0
|
||||||
|
- Versions update
|
||||||
|
- Project group changed to `space.kscience`
|
||||||
|
- Moved `yarn.lock` to `gradle` directory
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
- FX configuration
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Xjdk-release flag because it is broken until https://youtrack.jetbrains.com/issue/KT-52823
|
||||||
|
- Use CSS loader in JS by default
|
||||||
|
|
||||||
|
## 0.11.6-kotlin-1.7.0
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Coroutines tests are applied only when explicit `useCoroutines` is used.
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Atomicfu support inside the plugin
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Rollback coroutines to 1.6.1
|
||||||
|
|
||||||
|
## 0.11.5-kotlin-1.7.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Coroutine tests as default dependency for tests
|
- Coroutine tests as default dependency for tests
|
||||||
- Context receiver flag
|
- Context receiver flag
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Separate release tasks for each target
|
- Separate release tasks for each target
|
||||||
- Kotlin 1.6.20
|
- Kotlin 1.7.0
|
||||||
- Context receivers enabled
|
- Ktor 2.0.1
|
||||||
- Ktor 2.0
|
- ExplicitAPI does not override existing value
|
||||||
|
|
||||||
### Deprecated
|
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
- Ktor specific artifacts from version catalog
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Moved signing out of sonatype block
|
||||||
|
|
||||||
### Security
|
## 0.11.1-kotlin-1.6.10
|
||||||
|
|
||||||
## [0.11.1-kotlin-1.6.10]
|
|
||||||
### Added
|
### Added
|
||||||
- Default templates for README and ARTIFACT
|
- Default templates for README and ARTIFACT
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Replaced Groovy templates by FreeMarker
|
- Replaced Groovy templates by FreeMarker
|
||||||
|
|
||||||
### Deprecated
|
|
||||||
|
|
||||||
### Removed
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- JS publication sources jar
|
- JS publication sources jar
|
||||||
|
|
||||||
### Security
|
## 0.10.9-kotlin-1.6.10
|
||||||
|
|
||||||
## [0.10.9-kotlin-1.6.10]
|
|
||||||
### Added
|
### Added
|
||||||
- html builders for readme
|
- html builders for readme
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Kotlin 1.6.0
|
- Kotlin 1.6.0
|
||||||
- Use indy lambdas by default #32
|
- Use indy lambdas by default #32
|
||||||
- Change version scheme to `<version>-kotlin-<kotlin version>`
|
- Change version scheme to `<version>-kotlin-<kotlin version>`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- remove `nativeMain` dependency from `nativeTest`
|
- remove `nativeMain` dependency from `nativeTest`
|
||||||
|
|
||||||
## [0.10.4]
|
## 0.10.4
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Kotlin 1.6
|
- Kotlin 1.6
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Some issues with opt-ins
|
- Some issues with opt-ins
|
||||||
|
|
||||||
## [0.10.2]
|
## 0.10.2
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Experimental automatic JS project bundling in MPP
|
- Experimental automatic JS project bundling in MPP
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Remove vcs requirement for Space publication
|
- Remove vcs requirement for Space publication
|
||||||
|
|
||||||
### Fixed
|
## 0.10.0
|
||||||
-Release task (#19)
|
|
||||||
|
|
||||||
## [0.10.0]
|
|
||||||
### Added
|
### Added
|
||||||
- Lazy readme properties
|
- Lazy readme properties
|
||||||
- BOM for kotlin-wrappers on JS
|
- BOM for kotlin-wrappers on JS
|
||||||
@ -82,7 +140,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Removed
|
### Removed
|
||||||
- bson support
|
- bson support
|
||||||
|
|
||||||
## [0.9.5]
|
## 0.9.5
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Disable API validation for snapshots
|
- Disable API validation for snapshots
|
||||||
- `-Xjvm-default=all` on JVM
|
- `-Xjvm-default=all` on JVM
|
||||||
@ -99,7 +158,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
- Removed unnecessary `afterEvaluate` for compatibility with gradle 7.0
|
- Removed unnecessary `afterEvaluate` for compatibility with gradle 7.0
|
||||||
|
|
||||||
## [0.9.0]
|
## 0.9.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Skip sonatype publishing for dev versions
|
- Skip sonatype publishing for dev versions
|
||||||
|
|
||||||
@ -113,7 +173,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Removed
|
### Removed
|
||||||
- Bintray publishing
|
- Bintray publishing
|
||||||
|
|
||||||
## [0.8.4]
|
## 0.8.4
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Adaptive support for host OS in native
|
- Adaptive support for host OS in native
|
||||||
- CSS support for JS targets
|
- CSS support for JS targets
|
||||||
@ -127,7 +188,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Release task
|
- Release task
|
||||||
- Readme generation for multi-module project
|
- Readme generation for multi-module project
|
||||||
|
|
||||||
## [0.8.1]
|
## 0.8.1
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Ktor version to versions
|
- Ktor version to versions
|
||||||
- Add sonatype publishing
|
- Add sonatype publishing
|
||||||
@ -147,7 +209,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Fix publishing load order for sonatype
|
- Fix publishing load order for sonatype
|
||||||
- Fix root project readme
|
- Fix root project readme
|
||||||
|
|
||||||
## [0.7.4]
|
## 0.7.4
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Changelog plugin automatically applied to `project`.
|
- Changelog plugin automatically applied to `project`.
|
||||||
- Feature matrix and Readme generation task for a `project` plugin.
|
- Feature matrix and Readme generation task for a `project` plugin.
|
||||||
@ -173,16 +236,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Removed
|
### Removed
|
||||||
- `useDokka` method. Documentation jar should be added manually if needed.
|
- `useDokka` method. Documentation jar should be added manually if needed.
|
||||||
|
|
||||||
## [0.6.0]
|
## 0.6.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Migrate to kotlin 1.4.0
|
- Migrate to kotlin 1.4.0
|
||||||
- Separate Native (current platform) and nodeJs plugins.
|
- Separate Native (current platform) and nodeJs plugins.
|
||||||
- Add `application()` toggle in plugin configuration to produce binaries on JS and applicaion plugin on jvm.
|
- Add `application()` toggle in plugin configuration to produce binaries on JS and applicaion plugin on jvm.
|
||||||
- Add `publish` to expose publishing configuration.
|
- Add `publish` to expose publishing configuration.
|
||||||
|
|
||||||
### Changed
|
## 0.5.2
|
||||||
-Publishing in bintray now is automatic.
|
|
||||||
|
|
||||||
## [0.5.2]
|
|
||||||
### Added
|
### Added
|
||||||
- Copy resources for jvm modules and jvm source sets in mpp.
|
- Copy resources for jvm modules and jvm source sets in mpp.
|
||||||
|
26
README.md
26
README.md
@ -1,28 +1,28 @@
|
|||||||
[![Maven Central](https://img.shields.io/maven-central/v/ru.mipt.npm.gradle.project/ru.mipt.npm.gradle.project.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22ru.mipt.npm.gradle.project%22%20AND%20a:%22ru.mipt.npm.gradle.project.gradle.plugin%22)
|
[![Maven Central](https://img.shields.io/maven-central/v/space.kscience.gradle.project/space.kscience.gradle.project.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22space.kscience.gradle.project%22%20AND%20a:%22space.kscience.gradle.project.gradle.plugin%22)
|
||||||
|
|
||||||
# KScience build tools
|
# KScience build tools
|
||||||
|
|
||||||
A collection of gradle plugins for building and publish in *kscience* and *dataforge* projects.
|
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.
|
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.
|
Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool.
|
||||||
|
|
||||||
## ru.mipt.npm.gradle.mpp
|
## space.kscience.gradle.mpp
|
||||||
`= kotlin("multiplatform") + ru.mipt.npm.gradle.common`
|
`= kotlin("multiplatform") + space.kscience.gradle.common`
|
||||||
|
|
||||||
Includes JVM-IR and JS-IR-Browser targets.
|
Includes JVM-IR and JS-IR-Browser targets.
|
||||||
|
|
||||||
## ru.mipt.npm.gradle.jvm
|
## space.kscience.gradle.jvm
|
||||||
`= kotlin("jvm") + ru.mipt.npm.gradle.common`
|
`= kotlin("jvm") + space.kscience.gradle.common`
|
||||||
|
|
||||||
## ru.mipt.npm.gradle.js
|
## space.kscience.gradle.js
|
||||||
`= kotlin("js") + ru.mipt.npm.gradle.common`
|
`= kotlin("js") + space.kscience.gradle.common`
|
||||||
|
|
||||||
## ru.mipt.npm.gradle.native
|
## space.kscience.gradle.native
|
||||||
add default native targets to `ru.mipt.npm.gradle.mpp`
|
add default native targets to `space.kscience.gradle.mpp`
|
||||||
|
|
||||||
## ru.mipt.npm.gradle.node
|
## space.kscience.gradle.node
|
||||||
add node target to `ru.mipt.npm.gradle.mpp`
|
add node target to `space.kscience.gradle.mpp`
|
||||||
|
235
build.gradle.kts
235
build.gradle.kts
@ -1,17 +1,17 @@
|
|||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.changelog)
|
|
||||||
alias(libs.plugins.dokka)
|
|
||||||
`java-gradle-plugin`
|
`java-gradle-plugin`
|
||||||
`kotlin-dsl`
|
`kotlin-dsl`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
signing
|
signing
|
||||||
`version-catalog`
|
`version-catalog`
|
||||||
|
alias(libs.plugins.changelog)
|
||||||
|
alias(libs.plugins.dokka)
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "ru.mipt.npm"
|
group = "space.kscience"
|
||||||
version = libs.versions.tools.get()
|
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())
|
changelog.version.set(project.version.toString())
|
||||||
|
|
||||||
@ -21,20 +21,17 @@ repositories {
|
|||||||
maven("https://repo.kotlin.link")
|
maven("https://repo.kotlin.link")
|
||||||
}
|
}
|
||||||
|
|
||||||
java.targetCompatibility = JavaVersion.VERSION_11
|
|
||||||
|
|
||||||
kotlin.explicitApiWarning()
|
kotlin.explicitApiWarning()
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(libs.kotlin.gradle)
|
api(libs.kotlin.gradle)
|
||||||
implementation(libs.atomicfu.gradle)
|
|
||||||
implementation(libs.binary.compatibility.validator)
|
implementation(libs.binary.compatibility.validator)
|
||||||
implementation(libs.changelog.gradle)
|
implementation(libs.changelog.gradle)
|
||||||
implementation(libs.dokka.gradle)
|
implementation(libs.dokka.gradle)
|
||||||
implementation(libs.kotlin.jupyter.gradle)
|
implementation(libs.kotlin.jupyter.gradle)
|
||||||
implementation(libs.kotlin.serialization)
|
implementation(libs.kotlin.serialization)
|
||||||
implementation(libs.kotlinx.html)
|
implementation(libs.kotlinx.html)
|
||||||
implementation("org.tomlj:tomlj:1.0.0")
|
implementation("org.tomlj:tomlj:1.1.0")
|
||||||
// // nexus publishing plugin
|
// // nexus publishing plugin
|
||||||
// implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
|
// implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
|
||||||
|
|
||||||
@ -51,53 +48,45 @@ tasks.test {
|
|||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
plugins {
|
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") {
|
create("project") {
|
||||||
id = "ru.mipt.npm.gradle.project"
|
id = "space.kscience.gradle.project"
|
||||||
description = "The root plugin for multi-module project infrastructure"
|
description = "The root plugin for multi-module project infrastructure"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
|
implementationClass = "space.kscience.gradle.KScienceProjectPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("mpp") {
|
create("mpp") {
|
||||||
id = "ru.mipt.npm.gradle.mpp"
|
id = "space.kscience.gradle.mpp"
|
||||||
description = "Pre-configured multiplatform project"
|
description = "Pre-configured multiplatform project"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
|
implementationClass = "space.kscience.gradle.KScienceMPPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("jvm") {
|
create("jvm") {
|
||||||
id = "ru.mipt.npm.gradle.jvm"
|
id = "space.kscience.gradle.jvm"
|
||||||
description = "Pre-configured JVM project"
|
description = "Pre-configured JVM project"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
|
implementationClass = "space.kscience.gradle.KScienceJVMPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("js") {
|
create("js") {
|
||||||
id = "ru.mipt.npm.gradle.js"
|
id = "space.kscience.gradle.js"
|
||||||
description = "Pre-configured JS project"
|
description = "Pre-configured JS project"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
|
implementationClass = "space.kscience.gradle.KScienceJSPlugin"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
create("native") {
|
tasks.create("version") {
|
||||||
id = "ru.mipt.npm.gradle.native"
|
group = "publishing"
|
||||||
description = "Additional native targets to be use alongside mpp"
|
val versionFile = project.buildDir.resolve("project-version.txt")
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
|
outputs.file(versionFile)
|
||||||
}
|
doLast {
|
||||||
|
versionFile.createNewFile()
|
||||||
create("node") {
|
versionFile.writeText(project.version.toString())
|
||||||
id = "ru.mipt.npm.gradle.node"
|
println(project.version)
|
||||||
description = "Additional nodejs target to be use alongside mpp"
|
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//publishing version catalog
|
//publishing version catalog
|
||||||
|
|
||||||
@Suppress("UnstableApiUsage")
|
|
||||||
catalog.versionCatalog {
|
catalog.versionCatalog {
|
||||||
from(files("gradle/libs.versions.toml"))
|
from(files("gradle/libs.versions.toml"))
|
||||||
}
|
}
|
||||||
@ -115,110 +104,126 @@ val javadocsJar by tasks.creating(Jar::class) {
|
|||||||
from(tasks.dokkaHtml)
|
from(tasks.dokkaHtml)
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
val emptyJavadocJar by tasks.creating(Jar::class) {
|
||||||
publishing {
|
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||||
val vcs = "https://github.com/mipt-npm/gradle-tools"
|
archiveBaseName.set("empty")
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
}
|
||||||
|
|
||||||
// Process each publication we have in this project
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("catalog") {
|
|
||||||
from(components["versionCatalog"])
|
|
||||||
artifactId = "version-catalog"
|
|
||||||
|
|
||||||
pom {
|
val emptySourcesJar by tasks.creating(Jar::class) {
|
||||||
name.set("version-catalog")
|
archiveClassifier.set("sources")
|
||||||
}
|
archiveBaseName.set("empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
val vcs = "https://github.com/mipt-npm/gradle-tools"
|
||||||
|
|
||||||
|
// 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> {
|
withType<MavenPublication> {
|
||||||
artifact(sourcesJar)
|
// thanks @vladimirsitnikv for the fix
|
||||||
artifact(javadocsJar)
|
artifact(if (name == "catalog") emptySourcesJar else sourcesJar)
|
||||||
|
artifact(if (name == "catalog") emptyJavadocJar else javadocsJar)
|
||||||
|
|
||||||
pom {
|
|
||||||
name.set(project.name)
|
pom {
|
||||||
description.set(project.description)
|
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)
|
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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
|
val spaceRepo = "https://maven.pkg.jetbrains.space/spc/p/sci/maven"
|
||||||
val spaceUser: String? = project.findProperty("publishing.space.user") as? String
|
val spaceUser: String? = findProperty("publishing.space.user") as? String
|
||||||
val spaceToken: String? = project.findProperty("publishing.space.token") as? String
|
val spaceToken: String? = findProperty("publishing.space.token") as? String
|
||||||
|
|
||||||
if (spaceUser != null && spaceToken != null) {
|
if (spaceUser != null && spaceToken != null) {
|
||||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||||
|
|
||||||
repositories.maven {
|
repositories.maven {
|
||||||
name = "space"
|
name = "space"
|
||||||
url = uri(spaceRepo)
|
url = uri(spaceRepo)
|
||||||
|
|
||||||
credentials {
|
credentials {
|
||||||
username = spaceUser
|
username = spaceUser
|
||||||
password = spaceToken
|
password = spaceToken
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String
|
||||||
|
val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories.maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = uri(sonatypeRepo)
|
||||||
|
|
||||||
|
credentials {
|
||||||
|
username = sonatypeUser
|
||||||
|
password = sonatypePassword
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String
|
signing {
|
||||||
val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String
|
//useGpgCmd()
|
||||||
|
sign(publications)
|
||||||
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories.maven {
|
|
||||||
name = "sonatype"
|
|
||||||
url = uri(sonatypeRepo)
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
username = sonatypeUser
|
|
||||||
password = sonatypePassword
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugins.findPlugin("signing") == null) {
|
|
||||||
apply<SigningPlugin>()
|
|
||||||
}
|
|
||||||
|
|
||||||
signing {
|
|
||||||
//useGpgCmd()
|
|
||||||
sign(publications)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
|
||||||
kotlinOptions.jvmTarget = "11"
|
kotlin {
|
||||||
|
jvmToolchain {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(11))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.processResources.configure {
|
tasks.processResources.configure {
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
from("gradle/libs.versions.toml")
|
from("gradle/libs.versions.toml")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround for https://github.com/gradle/gradle/issues/15568
|
||||||
|
tasks.withType<AbstractPublishToMaven>().configureEach {
|
||||||
|
mustRunAfter(tasks.withType<Sign>())
|
||||||
}
|
}
|
@ -1,25 +1,26 @@
|
|||||||
[versions]
|
[versions]
|
||||||
tools = "0.11.3-kotlin-1.6.20"
|
tools = "0.14.4-kotlin-1.8.20-RC"
|
||||||
kotlin = "1.6.20"
|
kotlin = "1.8.20-RC"
|
||||||
atomicfu = "0.17.1"
|
atomicfu = "0.19.0"
|
||||||
binary-compatibility-validator = "0.8.0"
|
binary-compatibility-validator = "0.12.1"
|
||||||
changelog = "1.3.1"
|
changelog = "2.0.0"
|
||||||
dokka = "1.6.10"
|
dokka = "1.7.20"
|
||||||
kotlin-jupyter = "0.11.0-71"
|
kotlin-jupyter = "0.11.0-317"
|
||||||
kotlinx-benchmark = "0.4.2"
|
kotlinx-benchmark = "0.4.7"
|
||||||
kotlinx-cli = "0.3.4"
|
kotlinx-cli = "0.3.5"
|
||||||
kotlinx-collections-immutable = "0.3.5"
|
kotlinx-coroutines = "1.6.4"
|
||||||
kotlinx-coroutines = "1.6.1"
|
kotlinx-datetime = "0.4.0"
|
||||||
kotlinx-datetime = "0.3.2"
|
kotlinx-html = "0.8.0"
|
||||||
kotlinx-html = "0.7.3"
|
kotlinx-knit = "0.4.0"
|
||||||
kotlinx-knit = "0.3.0"
|
|
||||||
kotlinx-nodejs = "0.0.7"
|
kotlinx-nodejs = "0.0.7"
|
||||||
kotlinx-serialization = "1.3.2"
|
kotlinx-serialization = "1.4.1"
|
||||||
ktor = "2.0.0"
|
ktor = "2.2.3"
|
||||||
xmlutil = "0.84.1"
|
xmlutil = "0.84.3"
|
||||||
yamlkt = "0.10.2"
|
yamlkt = "0.12.0"
|
||||||
jsBom = "0.0.1-pre.313-kotlin-1.6.10"
|
jsBom = "1.0.0-pre.509"
|
||||||
junit = "5.8.2"
|
junit = "5.9.2"
|
||||||
|
compose = "1.3.0"
|
||||||
|
logback = "1.4.5"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" }
|
atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" }
|
||||||
@ -38,8 +39,6 @@ kotlin-jupyter-gradle = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-grad
|
|||||||
|
|
||||||
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
|
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
|
||||||
|
|
||||||
kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinx-collections-immutable" }
|
|
||||||
|
|
||||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
|
kotlinx-coroutines-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-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-debug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "kotlinx-coroutines" }
|
||||||
@ -73,60 +72,6 @@ kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-seria
|
|||||||
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
|
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
|
||||||
|
|
||||||
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
|
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
|
||||||
ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktor" }
|
|
||||||
ktor-client-apache = { module = "io.ktor:ktor-client-apache", version.ref = "ktor" }
|
|
||||||
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
|
|
||||||
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
|
||||||
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
|
|
||||||
ktor-client-auth-basic = { module = "io.ktor:ktor-client-auth-basic", version.ref = "ktor" }
|
|
||||||
ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" }
|
|
||||||
ktor-client-encoding = { module = "io.ktor:ktor-client-encoding", version.ref = "ktor" }
|
|
||||||
ktor-client-json = { module = "io.ktor:ktor-client-json", version.ref = "ktor" }
|
|
||||||
ktor-client-gson = { module = "io.ktor:ktor-client-gson", version.ref = "ktor" }
|
|
||||||
ktor-client-jackson = { module = "io.ktor:ktor-client-jackson", version.ref = "ktor" }
|
|
||||||
ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
|
|
||||||
ktor-client-logging = { module = "io.ktor:ktor-client-loggin", version.ref = "ktor" }
|
|
||||||
ktor-client-tracing = { module = "io.ktor:ktor-client-tracing", version.ref = "ktor" }
|
|
||||||
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
|
|
||||||
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
|
|
||||||
ktor-client-jetty = { module = "io.ktor:ktor-client-jetty", version.ref = "ktor" }
|
|
||||||
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
|
|
||||||
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
|
|
||||||
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
|
|
||||||
ktor-auth-jwt = { module = "io.ktor:ktor-auth-jwt", version.ref = "ktor" }
|
|
||||||
ktor-auth-ldap = { module = "io.ktor:ktor-auth-ldap", version.ref = "ktor" }
|
|
||||||
ktor-auth = { module = "io.ktor:ktor-auth", version.ref = "ktor" }
|
|
||||||
ktor-freemaker = { module = "io.ktor:ktor-freemaker", version.ref = "ktor" }
|
|
||||||
ktor-gson = { module = "io.ktor:ktor-gson", version.ref = "ktor" }
|
|
||||||
ktor-html-builder = { module = "io.ktor:ktor-html-builder", version.ref = "ktor" }
|
|
||||||
ktor-jackson = { module = "io.ktor:ktor-jackson", version.ref = "ktor" }
|
|
||||||
ktor-locations = { module = "io.ktor:ktor-locations", version.ref = "ktor" }
|
|
||||||
ktor-metrics-micrometer = { module = "io.ktor:ktor-metrics-micrometer", version.ref = "ktor" }
|
|
||||||
ktor-metrics = { module = "io.ktor:ktor-metrics", version.ref = "ktor" }
|
|
||||||
ktor-mustache = { module = "io.ktor:ktor-mustache", version.ref = "ktor" }
|
|
||||||
ktor-pebble = { module = "io.ktor:ktor-pebble", version.ref = "ktor" }
|
|
||||||
ktor-serialization = { module = "io.ktor:ktor-serialization", version.ref = "ktor" }
|
|
||||||
ktor-server-sessions = { module = "io.ktor:ktor-server-sessions", version.ref = "ktor" }
|
|
||||||
ktor-thymeleaf = { module = "io.ktor:ktor-thymeleaf", version.ref = "ktor" }
|
|
||||||
ktor-velocity = { module = "io.ktor:ktor-velocity", version.ref = "ktor" }
|
|
||||||
ktor-webjars = { module = "io.ktor:ktor-webjars", version.ref = "ktor" }
|
|
||||||
ktor-websockets = { module = "io.ktor:ktor-websockets", version.ref = "ktor" }
|
|
||||||
ktor-http = { module = "io.ktor:ktor-http", version.ref = "ktor" }
|
|
||||||
ktor-http-cio = { module = "io.ktor:ktor-http-cio", version.ref = "ktor" }
|
|
||||||
ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor" }
|
|
||||||
ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" }
|
|
||||||
ktor-network-tls = { module = "io.ktor:ktor-network-tls", version.ref = "ktor" }
|
|
||||||
ktor-network-tls-certificates = { module = "io.ktor:ktor-network-tls-certificates", version.ref = "ktor" }
|
|
||||||
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
|
|
||||||
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
|
|
||||||
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
|
|
||||||
ktor-server-jetty = { module = "io.ktor:ktor-server-jetty", version.ref = "ktor" }
|
|
||||||
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
|
|
||||||
ktor-server-servlet = { module = "io.ktor:ktor-server-servlet", version.ref = "ktor" }
|
|
||||||
ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
|
|
||||||
ktor-server-tomcat = { module = "io.ktor:ktor-server-tomcat", version.ref = "ktor" }
|
|
||||||
ktor-test-dispatcher = { module = "io.ktor:ktor-test-dispatcher", version.ref = "ktor" }
|
|
||||||
ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor" }
|
|
||||||
|
|
||||||
xmlutil-core = { module = "io.github.pdvrieze.xmlutil:core", version.ref = "xmlutil" }
|
xmlutil-core = { module = "io.github.pdvrieze.xmlutil:core", version.ref = "xmlutil" }
|
||||||
xmlutil-ktor = { module = "io.github.pdvrieze.xmlutil:ktor", version.ref = "xmlutil" }
|
xmlutil-ktor = { module = "io.github.pdvrieze.xmlutil:ktor", version.ref = "xmlutil" }
|
||||||
@ -134,18 +79,21 @@ xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", v
|
|||||||
|
|
||||||
yamlkt = { module = "net.mamoe.yamlkt:yamlkt", version.ref = "yamlkt" }
|
yamlkt = { module = "net.mamoe.yamlkt:yamlkt", version.ref = "yamlkt" }
|
||||||
|
|
||||||
|
logback-classic = {module = "ch.qos.logback:logback-classic", version.ref = "logback"}
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
|
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
|
||||||
|
|
||||||
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||||
|
compose = {id = "org.jetbrains.compose", version.ref = "compose"}
|
||||||
|
|
||||||
gradle-common = { id = "ru.mipt.npm.gradle.common", version.ref = "tools" }
|
gradle-common = { id = "space.kscience.gradle.common", version.ref = "tools" }
|
||||||
gradle-project = { id = "ru.mipt.npm.gradle.project", version.ref = "tools" }
|
gradle-project = { id = "space.kscience.gradle.project", version.ref = "tools" }
|
||||||
gradle-mpp = { id = "ru.mipt.npm.gradle.mpp", version.ref = "tools" }
|
gradle-mpp = { id = "space.kscience.gradle.mpp", version.ref = "tools" }
|
||||||
gradle-jvm = { id = "ru.mipt.npm.gradle.jvm", version.ref = "tools" }
|
gradle-jvm = { id = "space.kscience.gradle.jvm", version.ref = "tools" }
|
||||||
gradle-js = { id = "ru.mipt.npm.gradle.js", version.ref = "tools" }
|
gradle-js = { id = "space.kscience.gradle.js", version.ref = "tools" }
|
||||||
gradle-native = { id = "ru.mipt.npm.gradle.native", version.ref = "tools" }
|
gradle-native = { id = "space.kscience.gradle.native", version.ref = "tools" }
|
||||||
gradle-node = { id = "ru.mipt.npm.gradle.node", version.ref = "tools" }
|
gradle-node = { id = "space.kscience.gradle.node", version.ref = "tools" }
|
||||||
|
|
||||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlin" }
|
kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlin" }
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package ru.mipt.npm.gradle
|
|
||||||
|
|
||||||
import org.gradle.api.Plugin
|
|
||||||
import org.gradle.api.Project
|
|
||||||
|
|
||||||
@Suppress("UNUSED_VARIABLE")
|
|
||||||
public open class KScienceCommonPlugin : Plugin<Project> {
|
|
||||||
override fun apply(project: Project): Unit = project.configureKScience(
|
|
||||||
KotlinVersion(1, 6, 10)
|
|
||||||
)
|
|
||||||
}
|
|
@ -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,169 +0,0 @@
|
|||||||
package ru.mipt.npm.gradle
|
|
||||||
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.plugins.JavaPluginExtension
|
|
||||||
import org.gradle.api.tasks.Copy
|
|
||||||
import org.gradle.api.tasks.testing.Test
|
|
||||||
import org.gradle.kotlin.dsl.*
|
|
||||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
|
||||||
import ru.mipt.npm.gradle.internal.applyRepos
|
|
||||||
import ru.mipt.npm.gradle.internal.applySettings
|
|
||||||
import ru.mipt.npm.gradle.internal.fromJsDependencies
|
|
||||||
|
|
||||||
|
|
||||||
private val defaultJvmArgs: List<String> = listOf("-Xjvm-default=all", "-Xlambdas=indy", "-Xcontext-receivers")
|
|
||||||
|
|
||||||
public fun Project.configureKScience(
|
|
||||||
kotlinVersion: KotlinVersion
|
|
||||||
){
|
|
||||||
//Common configuration
|
|
||||||
registerKScienceExtension()
|
|
||||||
repositories.applyRepos()
|
|
||||||
|
|
||||||
//Configuration for K-JVM plugin
|
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
|
||||||
//logger.info("Applying KScience configuration for JVM project")
|
|
||||||
configure<KotlinJvmProjectExtension> {
|
|
||||||
explicitApiWarning()
|
|
||||||
|
|
||||||
sourceSets.all {
|
|
||||||
languageSettings.applySettings(kotlinVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets["test"].apply {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-junit5"))
|
|
||||||
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tasks.withType<KotlinJvmCompile> {
|
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
|
||||||
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
|
||||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<Test> {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
|
||||||
//logger.info("Applying KScience configuration for JS project")
|
|
||||||
configure<KotlinJsProjectExtension> {
|
|
||||||
explicitApiWarning()
|
|
||||||
|
|
||||||
js(IR) {
|
|
||||||
browser {
|
|
||||||
commonWebpackConfig {
|
|
||||||
cssSupport.enabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets.all {
|
|
||||||
languageSettings.applySettings(kotlinVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets["main"].apply {
|
|
||||||
dependencies {
|
|
||||||
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets["test"].apply {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-js"))
|
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(tasks.findByName("processResources") as? Copy)?.apply {
|
|
||||||
fromJsDependencies("runtimeClasspath")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
|
||||||
configure<KotlinMultiplatformExtension> {
|
|
||||||
explicitApiWarning()
|
|
||||||
|
|
||||||
jvm {
|
|
||||||
compilations.all {
|
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
|
||||||
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
js(IR) {
|
|
||||||
browser {
|
|
||||||
commonWebpackConfig {
|
|
||||||
cssSupport.enabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
val commonMain by getting {
|
|
||||||
dependencies {
|
|
||||||
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val commonTest by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-common"))
|
|
||||||
implementation(kotlin("test-annotations-common"))
|
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val jvmMain by getting
|
|
||||||
val jvmTest by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-junit5"))
|
|
||||||
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val jsMain by getting
|
|
||||||
val jsTest by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-js"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets.all {
|
|
||||||
languageSettings.applySettings(kotlinVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
|
|
||||||
fromJsDependencies("jsRuntimeClasspath")
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
|
||||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<Test> {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply dokka for all projects
|
|
||||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
|
||||||
apply<DokkaPlugin>()
|
|
||||||
}
|
|
||||||
}
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
548
src/main/kotlin/space/kscience/gradle/KScienceExtension.kt
Normal file
548
src/main/kotlin/space/kscience/gradle/KScienceExtension.kt
Normal file
@ -0,0 +1,548 @@
|
|||||||
|
package space.kscience.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.file.DuplicatesStrategy
|
||||||
|
import org.gradle.api.plugins.ApplicationPlugin
|
||||||
|
import org.gradle.api.provider.Property
|
||||||
|
import org.gradle.api.tasks.Copy
|
||||||
|
import org.gradle.api.tasks.testing.Test
|
||||||
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
|
import org.gradle.kotlin.dsl.*
|
||||||
|
import org.gradle.language.jvm.tasks.ProcessResources
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBrowserDsl
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinWasmTargetDsl
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask
|
||||||
|
import space.kscience.gradle.internal.defaultKotlinJvmArgs
|
||||||
|
import space.kscience.gradle.internal.fromJsDependencies
|
||||||
|
import space.kscience.gradle.internal.useCommonDependency
|
||||||
|
|
||||||
|
public enum class DependencyConfiguration {
|
||||||
|
API,
|
||||||
|
IMPLEMENTATION,
|
||||||
|
COMPILE_ONLY,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum class DependencySourceSet(public val setName: String, public val suffix: String) {
|
||||||
|
MAIN("main", "Main"),
|
||||||
|
TEST("test", "Test")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this project version has a development tag (`development` property to true, "dev" in the middle or "SNAPSHOT" in the end).
|
||||||
|
*/
|
||||||
|
public val Project.isInDevelopment: Boolean
|
||||||
|
get() = findProperty("development") == true
|
||||||
|
|| "dev" in version.toString()
|
||||||
|
|| version.toString().endsWith("SNAPSHOT")
|
||||||
|
|
||||||
|
|
||||||
|
private const val defaultJdkVersion = 11
|
||||||
|
|
||||||
|
public open class KScienceExtension(public val project: Project) {
|
||||||
|
|
||||||
|
public val jdkVersionProperty: Property<Int> = project.objects.property<Int>().apply {
|
||||||
|
set(defaultJdkVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var jdkVersion: Int by jdkVersionProperty
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use coroutines-core with default version or [version]
|
||||||
|
*/
|
||||||
|
public fun useCoroutines(
|
||||||
|
version: String = KScienceVersions.coroutinesVersion,
|
||||||
|
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||||
|
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||||
|
) {
|
||||||
|
project.useCommonDependency(
|
||||||
|
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
|
||||||
|
dependencySourceSet = sourceSet,
|
||||||
|
dependencyConfiguration = configuration
|
||||||
|
)
|
||||||
|
project.useCommonDependency(
|
||||||
|
"org.jetbrains.kotlinx:kotlinx-coroutines-test:$version",
|
||||||
|
dependencySourceSet = DependencySourceSet.TEST,
|
||||||
|
dependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use core serialization library and configure targets
|
||||||
|
*/
|
||||||
|
public fun useSerialization(
|
||||||
|
version: String = KScienceVersions.serializationVersion,
|
||||||
|
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||||
|
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||||
|
block: SerializationTargets.() -> Unit = {},
|
||||||
|
): Unit = project.run {
|
||||||
|
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
|
||||||
|
val artifactName = if (version.startsWith("0")) {
|
||||||
|
"kotlinx-serialization-runtime"
|
||||||
|
} else {
|
||||||
|
"kotlinx-serialization-core"
|
||||||
|
}
|
||||||
|
useCommonDependency(
|
||||||
|
"org.jetbrains.kotlinx:$artifactName:$version",
|
||||||
|
dependencySourceSet = sourceSet,
|
||||||
|
dependencyConfiguration = configuration
|
||||||
|
)
|
||||||
|
SerializationTargets(sourceSet, configuration).block()
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun useKtor(version: String = KScienceVersions.ktorVersion): Unit = with(project) {
|
||||||
|
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
configure<KotlinMultiplatformExtension> {
|
||||||
|
sourceSets.findByName("commonMain")?.apply {
|
||||||
|
dependencies {
|
||||||
|
api(platform("io.ktor:ktor-bom:$version"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
|
configure<KotlinJvmProjectExtension> {
|
||||||
|
sourceSets.findByName("main")?.apply {
|
||||||
|
dependencies {
|
||||||
|
api(platform("io.ktor:ktor-bom:$version"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
|
configure<KotlinJsProjectExtension> {
|
||||||
|
sourceSets.findByName("main")?.apply {
|
||||||
|
dependencies {
|
||||||
|
api(platform("io.ktor:ktor-bom:$version"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply jupyter plugin and add entry point for the jupyter library.
|
||||||
|
* If left empty applies a plugin without declaring library producers
|
||||||
|
*/
|
||||||
|
public fun jupyterLibrary(vararg pluginClasses: String) {
|
||||||
|
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
|
||||||
|
project.tasks.named("processJupyterApiResources", JupyterApiResourcesTask::class.java) {
|
||||||
|
libraryProducers = pluginClasses.toList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply common dependencies for different kind of targets
|
||||||
|
*/
|
||||||
|
public fun dependencies(sourceSet: String? = null, dependencyBlock: KotlinDependencyHandler.() -> Unit) {
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
|
project.configure<KotlinJvmProjectExtension> {
|
||||||
|
sourceSets.getByName(sourceSet ?: "main") {
|
||||||
|
dependencies(dependencyBlock)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
|
project.configure<KotlinJsProjectExtension> {
|
||||||
|
sourceSets.getByName(sourceSet ?: "main") {
|
||||||
|
dependencies(dependencyBlock)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
project.configure<KotlinMultiplatformExtension> {
|
||||||
|
sourceSets.getByName(sourceSet ?: "commonMain") {
|
||||||
|
dependencies(dependencyBlock)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun testDependencies(sourceSet: String? = null, dependencyBlock: KotlinDependencyHandler.() -> Unit) {
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
|
project.configure<KotlinJvmProjectExtension> {
|
||||||
|
sourceSets.getByName(sourceSet ?: "test") {
|
||||||
|
dependencies(dependencyBlock)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
|
project.configure<KotlinJsProjectExtension> {
|
||||||
|
sourceSets.getByName(sourceSet ?: "test") {
|
||||||
|
dependencies(dependencyBlock)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
project.configure<KotlinMultiplatformExtension> {
|
||||||
|
sourceSets.getByName(sourceSet ?: "commonTest") {
|
||||||
|
dependencies(dependencyBlock)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DefaultSourceSet(public val key: String)
|
||||||
|
|
||||||
|
public fun dependencies(
|
||||||
|
defaultSourceSet: DefaultSourceSet,
|
||||||
|
dependencyBlock: KotlinDependencyHandler.() -> Unit,
|
||||||
|
): Unit = dependencies(defaultSourceSet.key, dependencyBlock)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark this module as an application module. JVM application should be enabled separately
|
||||||
|
*/
|
||||||
|
public fun application() {
|
||||||
|
project.extensions.findByType<KotlinProjectExtension>()?.apply {
|
||||||
|
explicitApi = null
|
||||||
|
}
|
||||||
|
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
|
project.apply<ApplicationPlugin>()
|
||||||
|
}
|
||||||
|
|
||||||
|
project.extensions.findByType<KotlinJsProjectExtension>()?.apply {
|
||||||
|
js(IR) {
|
||||||
|
binaries.executable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||||
|
targets.withType<KotlinJsTargetDsl> {
|
||||||
|
binaries.executable()
|
||||||
|
}
|
||||||
|
|
||||||
|
targets.withType<KotlinNativeTarget> {
|
||||||
|
binaries.executable()
|
||||||
|
}
|
||||||
|
|
||||||
|
targets.withType<KotlinWasmTargetDsl> {
|
||||||
|
binaries.executable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add context receivers to this project and all subprojects
|
||||||
|
*/
|
||||||
|
public fun useContextReceivers() {
|
||||||
|
project.tasks.withType<KotlinCompile> {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs = freeCompilerArgs + "-Xcontext-receivers"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public operator fun DefaultSourceSet.invoke(dependencyBlock: KotlinDependencyHandler.() -> Unit) {
|
||||||
|
dependencies(this, dependencyBlock)
|
||||||
|
}
|
||||||
|
|
||||||
|
public val commonMain: DefaultSourceSet get() = DefaultSourceSet("commonMain")
|
||||||
|
public val commonTest: DefaultSourceSet get() = DefaultSourceSet("commonTest")
|
||||||
|
|
||||||
|
public val jvmMain: DefaultSourceSet get() = DefaultSourceSet("jvmMain")
|
||||||
|
public val jvmTest: DefaultSourceSet get() = DefaultSourceSet("jvmTest")
|
||||||
|
public val jsMain: DefaultSourceSet get() = DefaultSourceSet("jsMain")
|
||||||
|
public val jsTest: DefaultSourceSet get() = DefaultSourceSet("jsTest")
|
||||||
|
public val nativeMain: DefaultSourceSet get() = DefaultSourceSet("nativeMain")
|
||||||
|
public val nativeTest: DefaultSourceSet get() = DefaultSourceSet("nativeTest")
|
||||||
|
public val wasmMain: DefaultSourceSet get() = DefaultSourceSet("wasmMain")
|
||||||
|
public val wasmTest: DefaultSourceSet get() = DefaultSourceSet("wasmTest")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum class KotlinNativePreset {
|
||||||
|
linuxX64,
|
||||||
|
mingwX64,
|
||||||
|
macosX64,
|
||||||
|
macosArm64,
|
||||||
|
iosX64,
|
||||||
|
iosArm64,
|
||||||
|
iosSimulatorArm64,
|
||||||
|
}
|
||||||
|
|
||||||
|
public data class KScienceNativeTarget(
|
||||||
|
val preset: KotlinNativePreset,
|
||||||
|
val targetName: String = preset.name,
|
||||||
|
val targetConfiguration: KotlinNativeTarget.() -> Unit = { },
|
||||||
|
) {
|
||||||
|
public companion object {
|
||||||
|
public val linuxX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.linuxX64)
|
||||||
|
public val mingwX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.mingwX64)
|
||||||
|
public val macosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.macosX64)
|
||||||
|
public val macosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.macosX64)
|
||||||
|
public val iosX64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosX64)
|
||||||
|
public val iosArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosArm64)
|
||||||
|
public val iosSimulatorArm64: KScienceNativeTarget = KScienceNativeTarget(KotlinNativePreset.iosSimulatorArm64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KScienceNativeConfiguration {
|
||||||
|
|
||||||
|
|
||||||
|
internal companion object {
|
||||||
|
private fun defaultNativeTargets(): Map<KotlinNativePreset, KScienceNativeTarget> {
|
||||||
|
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
return when {
|
||||||
|
hostOs.startsWith("Windows") -> listOf(
|
||||||
|
KScienceNativeTarget.linuxX64,
|
||||||
|
KScienceNativeTarget.mingwX64
|
||||||
|
)
|
||||||
|
|
||||||
|
hostOs == "Mac OS X" -> listOf(
|
||||||
|
KScienceNativeTarget.macosX64,
|
||||||
|
KScienceNativeTarget.macosArm64,
|
||||||
|
KScienceNativeTarget.iosX64,
|
||||||
|
KScienceNativeTarget.iosArm64,
|
||||||
|
KScienceNativeTarget.iosSimulatorArm64,
|
||||||
|
)
|
||||||
|
|
||||||
|
hostOs == "Linux" -> listOf(KScienceNativeTarget.linuxX64)
|
||||||
|
else -> {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
|
}.associateBy { it.preset }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal var targets: Map<KotlinNativePreset, KScienceNativeTarget> = defaultNativeTargets()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace all targets
|
||||||
|
*/
|
||||||
|
public fun setTargets(vararg target: KScienceNativeTarget) {
|
||||||
|
targets = target.associateBy { it.preset }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a native target
|
||||||
|
*/
|
||||||
|
public fun target(target: KScienceNativeTarget) {
|
||||||
|
targets += target.preset to target
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun target(
|
||||||
|
preset: KotlinNativePreset,
|
||||||
|
targetName: String = preset.name,
|
||||||
|
targetConfiguration: KotlinNativeTarget.() -> Unit = { },
|
||||||
|
): Unit = target(KScienceNativeTarget(preset, targetName, targetConfiguration))
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class KScienceMppExtension(project: Project) : KScienceExtension(project) {
|
||||||
|
/**
|
||||||
|
* Enable jvm target
|
||||||
|
*/
|
||||||
|
public fun jvm(block: KotlinJvmTarget.() -> Unit = {}) {
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
project.configure<KotlinMultiplatformExtension> {
|
||||||
|
jvm {
|
||||||
|
compilations.all {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs = freeCompilerArgs + defaultKotlinJvmArgs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
block()
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
getByName("jvmTest") {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-junit5"))
|
||||||
|
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jvmToolchain {
|
||||||
|
languageVersion.set(jdkVersionProperty.map { JavaLanguageVersion.of(it) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
project.tasks.withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable JS-IR (browser) target.
|
||||||
|
*/
|
||||||
|
public fun js(block: KotlinJsTargetDsl.() -> Unit = {}) {
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
project.configure<KotlinMultiplatformExtension> {
|
||||||
|
js(IR) {
|
||||||
|
browser()
|
||||||
|
block()
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
getByName("jsTest") {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-js"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(project.tasks.findByName("jsProcessResources") as? Copy)?.apply {
|
||||||
|
fromJsDependencies("jsRuntimeClasspath")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalWasmDsl::class)
|
||||||
|
public fun wasm(block: KotlinWasmTargetDsl.() -> Unit = {}) {
|
||||||
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
project.configure<KotlinMultiplatformExtension> {
|
||||||
|
wasm {
|
||||||
|
browser()
|
||||||
|
block()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun jvmAndJs() {
|
||||||
|
jvm()
|
||||||
|
js()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jvm and Js source sets including copy of Js bundle into JVM resources
|
||||||
|
*/
|
||||||
|
public fun fullStack(
|
||||||
|
bundleName: String = "js/bundle.js",
|
||||||
|
jvmConfig: KotlinJvmTarget.() -> Unit = {},
|
||||||
|
jsConfig: KotlinJsTargetDsl.() -> Unit = {},
|
||||||
|
browserConfig: KotlinJsBrowserDsl.() -> Unit = {},
|
||||||
|
) {
|
||||||
|
js {
|
||||||
|
binaries.executable()
|
||||||
|
browser {
|
||||||
|
webpackTask {
|
||||||
|
outputFileName = bundleName
|
||||||
|
}
|
||||||
|
browserConfig()
|
||||||
|
}
|
||||||
|
jsConfig()
|
||||||
|
}
|
||||||
|
jvm {
|
||||||
|
val processResourcesTaskName =
|
||||||
|
compilations[org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.MAIN_COMPILATION_NAME]
|
||||||
|
.processResourcesTaskName
|
||||||
|
|
||||||
|
val jsBrowserDistribution = project.tasks.getByName("jsBrowserDistribution")
|
||||||
|
|
||||||
|
project.tasks.getByName<ProcessResources>(processResourcesTaskName) {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.WARN
|
||||||
|
dependsOn(jsBrowserDistribution)
|
||||||
|
from(jsBrowserDistribution)
|
||||||
|
}
|
||||||
|
jvmConfig()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable all supported native targets
|
||||||
|
*/
|
||||||
|
public fun native(block: KScienceNativeConfiguration.() -> Unit = {}): Unit = with(project) {
|
||||||
|
val nativeConfiguration = KScienceNativeConfiguration().apply(block)
|
||||||
|
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
configure<KotlinMultiplatformExtension> {
|
||||||
|
val nativeTargets: List<KotlinNativeTarget> =
|
||||||
|
nativeConfiguration.targets.values.map { nativeTarget ->
|
||||||
|
when (nativeTarget.preset) {
|
||||||
|
KotlinNativePreset.linuxX64 -> linuxX64(
|
||||||
|
nativeTarget.targetName,
|
||||||
|
nativeTarget.targetConfiguration
|
||||||
|
)
|
||||||
|
|
||||||
|
KotlinNativePreset.mingwX64 -> mingwX64(
|
||||||
|
nativeTarget.targetName,
|
||||||
|
nativeTarget.targetConfiguration
|
||||||
|
)
|
||||||
|
|
||||||
|
KotlinNativePreset.macosX64 -> macosX64(
|
||||||
|
nativeTarget.targetName,
|
||||||
|
nativeTarget.targetConfiguration
|
||||||
|
)
|
||||||
|
|
||||||
|
KotlinNativePreset.macosArm64 -> macosArm64(
|
||||||
|
nativeTarget.targetName,
|
||||||
|
nativeTarget.targetConfiguration
|
||||||
|
)
|
||||||
|
|
||||||
|
KotlinNativePreset.iosX64 -> iosX64(
|
||||||
|
nativeTarget.targetName,
|
||||||
|
nativeTarget.targetConfiguration
|
||||||
|
)
|
||||||
|
|
||||||
|
KotlinNativePreset.iosArm64 -> iosArm64(
|
||||||
|
nativeTarget.targetName,
|
||||||
|
nativeTarget.targetConfiguration
|
||||||
|
)
|
||||||
|
|
||||||
|
KotlinNativePreset.iosSimulatorArm64 -> iosSimulatorArm64(
|
||||||
|
nativeTarget.targetName,
|
||||||
|
nativeTarget.targetConfiguration
|
||||||
|
)
|
||||||
|
|
||||||
|
// else -> {
|
||||||
|
// logger.error("Native preset ${nativeTarget.preset} not recognised.")
|
||||||
|
// null
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
val commonMain by getting
|
||||||
|
val commonTest by getting
|
||||||
|
|
||||||
|
val nativeMain by creating {
|
||||||
|
dependsOn(commonMain)
|
||||||
|
}
|
||||||
|
|
||||||
|
val nativeTest by creating {
|
||||||
|
//should NOT depend on nativeMain because automatic dependency by plugin
|
||||||
|
dependsOn(commonTest)
|
||||||
|
}
|
||||||
|
|
||||||
|
configure(nativeTargets) {
|
||||||
|
compilations["main"]?.apply {
|
||||||
|
configure(kotlinSourceSets) {
|
||||||
|
dependsOn(nativeMain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compilations["test"]?.apply {
|
||||||
|
configure(kotlinSourceSets) {
|
||||||
|
dependsOn(nativeTest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension(constructor: (Project) -> T): T {
|
||||||
|
extensions.findByType<T>()?.let { return it }
|
||||||
|
return constructor(this).also {
|
||||||
|
extensions.add("kscience", it)
|
||||||
|
}
|
||||||
|
}
|
56
src/main/kotlin/space/kscience/gradle/KScienceJSPlugin.kt
Normal file
56
src/main/kotlin/space/kscience/gradle/KScienceJSPlugin.kt
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package space.kscience.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.tasks.Copy
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
|
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||||
|
import space.kscience.gradle.internal.applySettings
|
||||||
|
import space.kscience.gradle.internal.fromJsDependencies
|
||||||
|
|
||||||
|
public open class KScienceJSPlugin : Plugin<Project> {
|
||||||
|
override fun apply(project: Project): Unit = project.run {
|
||||||
|
if (!plugins.hasPlugin("org.jetbrains.kotlin.js")) {
|
||||||
|
plugins.apply("org.jetbrains.kotlin.js")
|
||||||
|
} else {
|
||||||
|
logger.info("Kotlin JS plugin is already present")
|
||||||
|
}
|
||||||
|
registerKScienceExtension(::KScienceExtension)
|
||||||
|
|
||||||
|
//logger.info("Applying KScience configuration for JS project")
|
||||||
|
configure<KotlinJsProjectExtension> {
|
||||||
|
js(IR) { browser { } }
|
||||||
|
|
||||||
|
sourceSets.all {
|
||||||
|
languageSettings.applySettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets["main"].apply {
|
||||||
|
dependencies {
|
||||||
|
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets["test"].apply {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-js"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (explicitApi == null) explicitApiWarning()
|
||||||
|
}
|
||||||
|
|
||||||
|
(tasks.findByName("processResources") as? Copy)?.apply {
|
||||||
|
fromJsDependencies("runtimeClasspath")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// apply dokka for all projects
|
||||||
|
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||||
|
apply<DokkaPlugin>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
src/main/kotlin/space/kscience/gradle/KScienceJVMPlugin.kt
Normal file
61
src/main/kotlin/space/kscience/gradle/KScienceJVMPlugin.kt
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package space.kscience.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.tasks.testing.Test
|
||||||
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
|
import org.gradle.kotlin.dsl.withType
|
||||||
|
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import space.kscience.gradle.internal.applySettings
|
||||||
|
import space.kscience.gradle.internal.defaultKotlinJvmArgs
|
||||||
|
|
||||||
|
public open class KScienceJVMPlugin : Plugin<Project> {
|
||||||
|
override fun apply(project: Project): Unit = project.run {
|
||||||
|
if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm")) {
|
||||||
|
plugins.apply("org.jetbrains.kotlin.jvm")
|
||||||
|
} else {
|
||||||
|
logger.info("Kotlin JVM plugin is already present")
|
||||||
|
}
|
||||||
|
val extension = registerKScienceExtension(::KScienceExtension)
|
||||||
|
|
||||||
|
//logger.info("Applying KScience configuration for JVM project")
|
||||||
|
configure<KotlinJvmProjectExtension> {
|
||||||
|
sourceSets.all {
|
||||||
|
languageSettings.applySettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets["test"].apply {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-junit5"))
|
||||||
|
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (explicitApi == null) explicitApiWarning()
|
||||||
|
jvmToolchain {
|
||||||
|
languageVersion.set(extension.jdkVersionProperty.map { JavaLanguageVersion.of(it) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile> {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs = freeCompilerArgs + defaultKotlinJvmArgs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply dokka for all projects
|
||||||
|
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||||
|
apply<DokkaPlugin>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
54
src/main/kotlin/space/kscience/gradle/KScienceMPPlugin.kt
Normal file
54
src/main/kotlin/space/kscience/gradle/KScienceMPPlugin.kt
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package space.kscience.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
|
import org.gradle.kotlin.dsl.hasPlugin
|
||||||
|
import org.gradle.kotlin.dsl.invoke
|
||||||
|
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
||||||
|
import space.kscience.gradle.internal.applySettings
|
||||||
|
|
||||||
|
public open class KScienceMPPlugin : Plugin<Project> {
|
||||||
|
override fun apply(project: Project): Unit = project.run {
|
||||||
|
if (!plugins.hasPlugin(KotlinMultiplatformPlugin::class)) {
|
||||||
|
//apply<KotlinMultiplatformPlugin>() for some reason it does not work
|
||||||
|
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||||
|
} else {
|
||||||
|
logger.info("Kotlin MPP plugin is already present")
|
||||||
|
}
|
||||||
|
|
||||||
|
registerKScienceExtension(::KScienceMppExtension)
|
||||||
|
|
||||||
|
configure<KotlinMultiplatformExtension> {
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
getByName("commonMain"){
|
||||||
|
dependencies {
|
||||||
|
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getByName("commonTest"){
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-common"))
|
||||||
|
implementation(kotlin("test-annotations-common"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.all {
|
||||||
|
languageSettings.applySettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (explicitApi == null) explicitApiWarning()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// apply dokka for all projects
|
||||||
|
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||||
|
apply<DokkaPlugin>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,35 +1,24 @@
|
|||||||
package ru.mipt.npm.gradle
|
package space.kscience.gradle
|
||||||
|
|
||||||
import kotlinx.validation.ApiValidationExtension
|
import kotlinx.validation.ApiValidationExtension
|
||||||
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
|
import org.gradle.api.publish.maven.MavenPom
|
||||||
|
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
|
import org.gradle.plugins.signing.Sign
|
||||||
import org.jetbrains.changelog.ChangelogPlugin
|
import org.jetbrains.changelog.ChangelogPlugin
|
||||||
import org.jetbrains.changelog.ChangelogPluginExtension
|
import org.jetbrains.changelog.ChangelogPluginExtension
|
||||||
import org.jetbrains.dokka.gradle.AbstractDokkaTask
|
import org.jetbrains.dokka.gradle.AbstractDokkaTask
|
||||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||||
import ru.mipt.npm.gradle.internal.*
|
import space.kscience.gradle.internal.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplifies adding repositories for Maven publishing, responds for releasing tasks for projects.
|
* Simplifies adding repositories for Maven publishing, responds for releasing tasks for projects.
|
||||||
*/
|
*/
|
||||||
public class KSciencePublishingExtension(public val project: Project) {
|
public class KSciencePublishingExtension(public val project: Project) {
|
||||||
private var isVcsInitialized = false
|
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.
|
* Configures Git repository (sources) for the publication.
|
||||||
@ -38,16 +27,23 @@ public class KSciencePublishingExtension(public val project: Project) {
|
|||||||
* @param connectionUrl URL of the Git repository.
|
* @param connectionUrl URL of the Git repository.
|
||||||
* @param developerConnectionUrl URL of the Git repository for developers.
|
* @param developerConnectionUrl URL of the Git repository for developers.
|
||||||
*/
|
*/
|
||||||
public fun git(vcsUrl: String, connectionUrl: String? = null, developerConnectionUrl: String? = connectionUrl) {
|
public fun pom(
|
||||||
|
vcsUrl: String,
|
||||||
|
connectionUrl: String? = null,
|
||||||
|
developerConnectionUrl: String? = connectionUrl,
|
||||||
|
connectionPrefix: String = "scm:git:",
|
||||||
|
pomConfig: MavenPom.() -> Unit,
|
||||||
|
) {
|
||||||
if (!isVcsInitialized) {
|
if (!isVcsInitialized) {
|
||||||
project.setupPublication {
|
project.setupPublication {
|
||||||
url.set(vcsUrl)
|
url.set(vcsUrl)
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
url.set(vcsUrl)
|
url.set(vcsUrl)
|
||||||
connectionUrl?.let { connection.set("scm:git:$it") }
|
connectionUrl?.let { connection.set("$connectionPrefix$it") }
|
||||||
developerConnectionUrl?.let { developerConnection.set("scm:git:$it") }
|
developerConnectionUrl?.let { developerConnection.set("$connectionPrefix$it") }
|
||||||
}
|
}
|
||||||
|
pomConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
isVcsInitialized = true
|
isVcsInitialized = true
|
||||||
@ -59,22 +55,16 @@ public class KSciencePublishingExtension(public val project: Project) {
|
|||||||
*
|
*
|
||||||
* @param githubProject the GitHub project.
|
* @param githubProject the GitHub project.
|
||||||
* @param githubOrg the GitHub user or organization.
|
* @param githubOrg the GitHub user or organization.
|
||||||
* @param addToRelease publish packages in the `release` task to the GitHub repository.
|
* @param deploy publish packages in the `deploy` task to the GitHub repository.
|
||||||
*/
|
*/
|
||||||
public fun github(
|
public fun github(
|
||||||
|
githubOrg: String,
|
||||||
githubProject: String,
|
githubProject: String,
|
||||||
githubOrg: String = "mipt-npm",
|
deploy: Boolean = project.requestPropertyOrNull("publishing.github") == "true",
|
||||||
addToRelease: Boolean = project.requestPropertyOrNull("publishing.github") == "true",
|
|
||||||
) {
|
) {
|
||||||
// Automatically initialize VCS using GitHub
|
if (deploy) {
|
||||||
if (!isVcsInitialized) {
|
|
||||||
git("https://github.com/$githubOrg/${githubProject}", "https://github.com/$githubOrg/${githubProject}.git")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addToRelease) {
|
|
||||||
try {
|
try {
|
||||||
project.addGithubPublishing(githubOrg, githubProject)
|
project.addGithubPublishing(githubOrg, githubProject)
|
||||||
repositoryNames += "github"
|
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
project.logger.error("Failed to set up github publication", t)
|
project.logger.error("Failed to set up github publication", t)
|
||||||
}
|
}
|
||||||
@ -85,15 +75,12 @@ public class KSciencePublishingExtension(public val project: Project) {
|
|||||||
* Adds Space Packages Maven repository to publishing.
|
* Adds Space Packages Maven repository to publishing.
|
||||||
*
|
*
|
||||||
* @param spaceRepo the repository URL.
|
* @param spaceRepo the repository URL.
|
||||||
* @param addToRelease publish packages in the `release` task to the Space repository.
|
* @param deploy publish packages in the `deploy` task to the Space repository.
|
||||||
*/
|
*/
|
||||||
public fun space(
|
public fun space(
|
||||||
spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven",
|
spaceRepo: String,
|
||||||
addToRelease: Boolean = project.requestPropertyOrNull("publishing.space") != "false",
|
|
||||||
) {
|
) {
|
||||||
project.addSpacePublishing(spaceRepo)
|
project.addSpacePublishing(spaceRepo)
|
||||||
|
|
||||||
if (addToRelease) repositoryNames += "space"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,13 +88,9 @@ public class KSciencePublishingExtension(public val project: Project) {
|
|||||||
*
|
*
|
||||||
* @param addToRelease publish packages in the `release` task to the Sonatype repository.
|
* @param addToRelease publish packages in the `release` task to the Sonatype repository.
|
||||||
*/
|
*/
|
||||||
public fun sonatype(
|
public fun sonatype() {
|
||||||
addToRelease: Boolean = (project.requestPropertyOrNull("publishing.sonatype") != "false"),
|
require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" }
|
||||||
) {
|
|
||||||
require(isVcsInitialized) { "The project vcs is not set up use 'git' method to do so" }
|
|
||||||
project.addSonatypePublishing()
|
project.addSonatypePublishing()
|
||||||
|
|
||||||
if (addToRelease) repositoryNames += "sonatype"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,8 +104,21 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
apply<DokkaPlugin>()
|
apply<DokkaPlugin>()
|
||||||
apply<BinaryCompatibilityValidatorPlugin>()
|
apply<BinaryCompatibilityValidatorPlugin>()
|
||||||
|
|
||||||
|
allprojects{
|
||||||
|
repositories{
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://repo.kotlin.link")
|
||||||
|
maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround for https://github.com/gradle/gradle/issues/15568
|
||||||
|
tasks.withType<AbstractPublishToMaven>().configureEach {
|
||||||
|
mustRunAfter(tasks.withType<Sign>())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
if (isSnapshot()) {
|
if (isInDevelopment) {
|
||||||
configure<ApiValidationExtension> {
|
configure<ApiValidationExtension> {
|
||||||
validationDisabled = true
|
validationDisabled = true
|
||||||
}
|
}
|
||||||
@ -142,6 +138,8 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
subprojects {
|
subprojects {
|
||||||
val readmeExtension = KScienceReadmeExtension(this)
|
val readmeExtension = KScienceReadmeExtension(this)
|
||||||
extensions.add("readme", readmeExtension)
|
extensions.add("readme", readmeExtension)
|
||||||
|
|
||||||
|
@Suppress("UNUSED_VARIABLE")
|
||||||
val generateReadme by tasks.creating {
|
val generateReadme by tasks.creating {
|
||||||
group = "documentation"
|
group = "documentation"
|
||||||
description = "Generate a README file if stub is present"
|
description = "Generate a README file if stub is present"
|
||||||
@ -204,11 +202,10 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
|
|
||||||
val modulesString = buildString {
|
val modulesString = buildString {
|
||||||
subprojects.forEach { subproject ->
|
subprojects.forEach { subproject ->
|
||||||
val name = subproject.name
|
// val name = subproject.name
|
||||||
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
|
subproject.extensions.findByType<KScienceReadmeExtension>()?.let { ext ->
|
||||||
val ext = subproject.extensions.findByType<KScienceReadmeExtension>()
|
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
|
||||||
appendLine("\n### [$name]($path)")
|
appendLine("\n### [$path]($path)")
|
||||||
if (ext != null) {
|
|
||||||
appendLine("> ${ext.description}")
|
appendLine("> ${ext.description}")
|
||||||
appendLine(">\n> **Maturity**: ${ext.maturity}")
|
appendLine(">\n> **Maturity**: ${ext.maturity}")
|
||||||
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
|
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
|
||||||
@ -234,49 +231,32 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
dependsOn(generateReadme)
|
dependsOn(generateReadme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.create("version") {
|
||||||
val releaseAll by tasks.creating {
|
group = "publishing"
|
||||||
group = RELEASE_GROUP
|
val versionFile = project.buildDir.resolve("project-version.txt")
|
||||||
description = "Publish development or production release based on version suffix"
|
outputs.file(versionFile)
|
||||||
dependsOn(generateReadme)
|
doLast {
|
||||||
}
|
versionFile.createNewFile()
|
||||||
|
versionFile.writeText(project.version.toString())
|
||||||
allprojects {
|
println(project.version)
|
||||||
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
|
// Disable API validation for snapshots
|
||||||
if (isSnapshot()) {
|
if (isInDevelopment) {
|
||||||
extensions.findByType<ApiValidationExtension>()?.apply {
|
extensions.findByType<ApiValidationExtension>()?.apply {
|
||||||
validationDisabled = true
|
validationDisabled = true
|
||||||
logger.warn("API validation is disabled for snapshot or dev version")
|
logger.warn("API validation is disabled for snapshot or dev version")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) {
|
||||||
|
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().lockFileDirectory =
|
||||||
|
rootDir.resolve("gradle")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
public const val RELEASE_GROUP: String = "release"
|
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.cache.StringTemplateLoader
|
||||||
import freemarker.template.Configuration
|
import freemarker.template.Configuration
|
||||||
@ -90,11 +90,6 @@ public class KScienceReadmeExtension(public val project: Project) {
|
|||||||
|
|
||||||
public val features: MutableList<Feature> = ArrayList()
|
public val features: MutableList<Feature> = ArrayList()
|
||||||
|
|
||||||
@Deprecated("Use lambda builder instead.")
|
|
||||||
public fun feature(id: String, description: String, ref: String? = null, name: String = id) {
|
|
||||||
features += Feature(id, description, ref, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
|
public fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
|
||||||
features += Feature(id, description(), ref, name)
|
features += Feature(id, description(), ref, name)
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package ru.mipt.npm.gradle
|
package space.kscience.gradle
|
||||||
|
|
||||||
|
|
||||||
import org.gradle.api.JavaVersion
|
|
||||||
import org.tomlj.Toml
|
import org.tomlj.Toml
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,8 +23,6 @@ public object KScienceVersions {
|
|||||||
public val jsBom: String get() = toml.getString("versions.jsBom")!!
|
public val jsBom: String get() = toml.getString("versions.jsBom")!!
|
||||||
internal val junit: String get() = toml.getString("versions.junit")!!
|
internal val junit: String get() = toml.getString("versions.junit")!!
|
||||||
|
|
||||||
public val JVM_TARGET: JavaVersion = JavaVersion.VERSION_11
|
|
||||||
|
|
||||||
public object Serialization {
|
public object Serialization {
|
||||||
public val xmlVersion: String get() = toml.getString("versions.xmlutil")!!
|
public val xmlVersion: String get() = toml.getString("versions.xmlutil")!!
|
||||||
public val yamlKtVersion: String get() = toml.getString("versions.yamlkt")!!
|
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 org.gradle.api.Project
|
||||||
import ru.mipt.npm.gradle.internal.useCommonDependency
|
import space.kscience.gradle.internal.useCommonDependency
|
||||||
|
|
||||||
public class SerializationTargets(
|
public class SerializationTargets(
|
||||||
public val sourceSet: DependencySourceSet,
|
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.artifacts.ProjectDependency
|
||||||
|
import org.gradle.api.tasks.Copy
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||||
|
import space.kscience.gradle.KScienceVersions
|
||||||
|
|
||||||
|
|
||||||
|
internal val defaultKotlinJvmArgs: List<String> =
|
||||||
|
listOf("-Xjvm-default=all", "-Xlambdas=indy"/* "-Xjdk-release=${KScienceVersions.JVM_TARGET}"*/)
|
||||||
|
|
||||||
|
internal fun resolveKotlinVersion(): KotlinVersion {
|
||||||
|
val (major, minor, patch) = KScienceVersions.kotlinVersion.split(".", "-")
|
||||||
|
return KotlinVersion(major.toInt(), minor.toInt(), patch.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun LanguageSettingsBuilder.applySettings(
|
||||||
|
kotlinVersion: KotlinVersion = resolveKotlinVersion(),
|
||||||
|
) {
|
||||||
|
val versionString = "${kotlinVersion.major}.${kotlinVersion.minor}"
|
||||||
|
languageVersion = versionString
|
||||||
|
apiVersion = versionString
|
||||||
|
progressiveMode = true
|
||||||
|
|
||||||
|
optIn("kotlin.RequiresOptIn")
|
||||||
|
optIn("kotlin.ExperimentalUnsignedTypes")
|
||||||
|
optIn("kotlin.ExperimentalStdlibApi")
|
||||||
|
optIn("kotlin.time.ExperimentalTime")
|
||||||
|
optIn("kotlin.contracts.ExperimentalContracts")
|
||||||
|
optIn("kotlin.js.ExperimentalJsExport")
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun Copy.fromJsDependencies(configurationName: String) = project.run {
|
||||||
|
val configuration = configurations[configurationName]
|
||||||
|
?: error("Configuration with name $configurationName could not be resolved.")
|
||||||
|
val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map {
|
||||||
|
it.dependencyProject
|
||||||
|
}
|
||||||
|
projectDeps.forEach { dep ->
|
||||||
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
dep.tasks.findByName("jsProcessResources")?.let { task ->
|
||||||
|
dependsOn(task)
|
||||||
|
from(task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
|
dep.tasks.findByName("processResources")?.let { task ->
|
||||||
|
dependsOn(task)
|
||||||
|
from(task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.mipt.npm.gradle.internal
|
package space.kscience.gradle.internal
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.configure
|
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.KotlinJsProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import ru.mipt.npm.gradle.DependencyConfiguration
|
import space.kscience.gradle.DependencyConfiguration
|
||||||
import ru.mipt.npm.gradle.DependencySourceSet
|
import space.kscience.gradle.DependencySourceSet
|
||||||
|
|
||||||
internal fun Project.useDependency(
|
internal fun Project.useDependency(
|
||||||
vararg pairs: Pair<String, String>,
|
vararg pairs: Pair<String, String>,
|
@ -1,4 +1,4 @@
|
|||||||
package ru.mipt.npm.gradle.internal
|
package space.kscience.gradle.internal
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.publish.PublishingExtension
|
import org.gradle.api.publish.PublishingExtension
|
||||||
@ -10,6 +10,8 @@ import org.gradle.plugins.signing.SigningExtension
|
|||||||
import org.gradle.plugins.signing.SigningPlugin
|
import org.gradle.plugins.signing.SigningPlugin
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets
|
||||||
|
import space.kscience.gradle.isInDevelopment
|
||||||
|
|
||||||
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
||||||
?: System.getenv(propertyName)
|
?: System.getenv(propertyName)
|
||||||
@ -31,8 +33,9 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
|
|||||||
from(it.kotlin)
|
from(it.kotlin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publications.create<MavenPublication>("js") {
|
publications.create<MavenPublication>("js") {
|
||||||
kotlin.js().components.forEach {
|
kotlin.targets.flatMap { it.components }.forEach {
|
||||||
from(it)
|
from(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,37 +63,12 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val dokkaJar by tasks.creating(Jar::class) {
|
|
||||||
group = "documentation"
|
|
||||||
archiveClassifier.set("javadoc")
|
|
||||||
from(tasks.findByName("dokkaHtml"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process each publication we have in this project
|
// Process each publication we have in this project
|
||||||
publications.withType<MavenPublication> {
|
publications.withType<MavenPublication> {
|
||||||
artifact(dokkaJar)
|
|
||||||
|
|
||||||
pom {
|
pom {
|
||||||
name.set(project.name)
|
name.set(project.name)
|
||||||
description.set(project.description ?: 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 {
|
scm {
|
||||||
tag.set(project.version.toString())
|
tag.set(project.version.toString())
|
||||||
}
|
}
|
||||||
@ -98,12 +76,42 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
|
|||||||
mavenPomConfiguration()
|
mavenPomConfiguration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins.withId("org.jetbrains.dokka") {
|
||||||
|
val dokkaJar by tasks.creating(Jar::class) {
|
||||||
|
group = "documentation"
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
from(tasks.findByName("dokkaHtml"))
|
||||||
|
}
|
||||||
|
publications.withType<MavenPublication> {
|
||||||
|
artifact(dokkaJar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestPropertyOrNull("publishing.signing.id") != null || requestPropertyOrNull("signing.gnupg.keyName") != null) {
|
||||||
|
|
||||||
|
if (!plugins.hasPlugin("signing")) {
|
||||||
|
apply<SigningPlugin>()
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.configure<SigningExtension>("signing") {
|
||||||
|
val signingId: String? = requestPropertyOrNull("publishing.signing.id")
|
||||||
|
if (!signingId.isNullOrBlank()) {
|
||||||
|
val signingKey: String = requestProperty("publishing.signing.key")
|
||||||
|
val signingPassphrase: String = requestProperty("publishing.signing.passPhrase")
|
||||||
|
|
||||||
|
// if key is provided, use it
|
||||||
|
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
|
||||||
|
} // else use agent signing
|
||||||
|
sign(publications)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn("Signing information is not provided. Skipping artefact signing.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Project.isSnapshot() = "dev" in version.toString() || version.toString().endsWith("SNAPSHOT")
|
|
||||||
|
|
||||||
internal fun Project.addGithubPublishing(
|
internal fun Project.addGithubPublishing(
|
||||||
githubOrg: String,
|
githubOrg: String,
|
||||||
githubProject: String,
|
githubProject: String,
|
||||||
@ -178,8 +186,8 @@ internal fun Project.addSonatypePublishing() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSnapshot()) {
|
if (isInDevelopment) {
|
||||||
logger.info("Sonatype publishing skipped for dev version")
|
logger.info("Sonatype publishing skipped for development version")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,24 +202,8 @@ internal fun Project.addSonatypePublishing() {
|
|||||||
allprojects {
|
allprojects {
|
||||||
plugins.withId("maven-publish") {
|
plugins.withId("maven-publish") {
|
||||||
configure<PublishingExtension> {
|
configure<PublishingExtension> {
|
||||||
if (!plugins.hasPlugin("signing")) {
|
|
||||||
apply<SigningPlugin>()
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions.configure<SigningExtension>("signing") {
|
|
||||||
val signingId: String? = requestPropertyOrNull("publishing.signing.id")
|
|
||||||
if (!signingId.isNullOrBlank()) {
|
|
||||||
val signingKey: String = requestProperty("publishing.signing.key")
|
|
||||||
val signingPassphrase: String = requestProperty("publishing.signing.passPhrase")
|
|
||||||
|
|
||||||
// if key is provided, use it
|
|
||||||
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
|
|
||||||
} // else use file signing
|
|
||||||
sign(publications)
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories.maven {
|
repositories.maven {
|
||||||
val sonatypeRepo = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
val sonatypeRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||||
name = "sonatype"
|
name = "sonatype"
|
||||||
url = uri(sonatypeRepo)
|
url = uri(sonatypeRepo)
|
||||||
|
|
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("MIPT")
|
||||||
|
organizationUrl.set("https://sciprog.center/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package ru.mipt.npm.gradle
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import space.kscience.gradle.KScienceVersions
|
||||||
|
|
||||||
class TestPlugins {
|
class TestPlugins {
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user