Compare commits
149 Commits
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 | ||
|
3d843210ea | ||
|
6d5a29567d | ||
6e9ef8326b | |||
027a00a486 | |||
96dff3f3ee | |||
|
4891b1f469 | ||
|
b150fd5fd3 | ||
|
e9c6174645 | ||
e1a11452d2 | |||
|
22e6657e79 | ||
|
66564457ff | ||
|
e8a301b4d1 | ||
526faf33eb | |||
|
69676b8521 | ||
|
572cbce67f | ||
|
778e4875d2 | ||
|
25c1c45818 | ||
|
acb13abc6e | ||
|
137299b615 | ||
|
dd5a9f75c4 | ||
|
74b38c62ef | ||
|
63600f9ebb | ||
|
1ee0e7ab41 | ||
7a9cf427f7 | |||
63106cd3aa | |||
dae2dfcde7 | |||
820664a74b | |||
7d16d0f5c7 | |||
|
0ba835925e | ||
|
59c2a13e4b | ||
b5270617fc | |||
5b88c2c5ad | |||
|
d911842922 | ||
e007ac9c7a | |||
|
a915d2256d | ||
54274f0c0d | |||
1c37a165c2 | |||
931d69ec1d | |||
680bd9ed33 | |||
0415ed30d5 | |||
8410e7e498 | |||
138ee1cfea | |||
db9b4dec50 | |||
878405ac6a | |||
6fa4b264a2 | |||
|
f67f1bf4f0 | ||
|
e586d20c91 | ||
dd3d95dba4 | |||
|
2a6c88636b | ||
|
c8edc513f1 | ||
|
02d2971b79 | ||
|
dc2ff2efb3 | ||
|
4f49e24d61 | ||
|
c227258e09 | ||
|
3fa500f451 | ||
|
852158c665 | ||
|
b751e79a8a | ||
|
970b9ad581 | ||
|
bb573291dd | ||
|
4768874bb5 | ||
100f7cd55f | |||
|
252a633583 | ||
|
b70037385c | ||
f11d47aee5 | |||
4eeb81cdbb | |||
2ad0630b7b | |||
|
8fe085c4bd | ||
663f2ea630 | |||
35e01abf93 | |||
|
000bc1e986 | ||
|
19a604f3b3 | ||
670a4ca71e | |||
329bfa5881 | |||
24af07eb7b | |||
5cd86474de | |||
ddbb128692 | |||
357e4c03be | |||
e44bf118dc | |||
e0d331d4d4 | |||
c5b8c688a2 | |||
023ca7b80c | |||
5ff90436f5 | |||
ba4548b3d7 | |||
a221951197 |
21
.github/workflows/build.yml
vendored
Normal file
21
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
name: Gradle build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ dev, master ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 40
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2.5.0
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: liberica
|
||||
- uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: build
|
24
.github/workflows/publish.yml
vendored
Normal file
24
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: Gradle publish
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [ created ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 40
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2.5.0
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: liberica
|
||||
- uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: |
|
||||
publishAllPublicationsToSpaceRepository
|
||||
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }}
|
||||
-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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
163
CHANGELOG.md
163
CHANGELOG.md
@ -1,11 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
@ -18,7 +18,130 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Security
|
||||
|
||||
## [0.9.5]
|
||||
## 0.14.4-kotlin-1.8.20-RC - 2023-03-12
|
||||
|
||||
### Added
|
||||
- Easier dependency handling in `kscience` block
|
||||
- Customizable base jdk version
|
||||
|
||||
### Changed
|
||||
- MPP does not use JVM and JS(IR) targets anymore. They could be turned manually via `js()`, `jvm()` or `fullStack()`
|
||||
- Signing is not applied if signingId is not provided
|
||||
|
||||
### Removed
|
||||
- FX plugins
|
||||
- Unnecessary library shortcuts (html and datetime)
|
||||
- deploy/release tasks
|
||||
|
||||
### Fixed
|
||||
- Gradle 8 compatibility
|
||||
- Dokka publication
|
||||
- issues with test sourcesets
|
||||
|
||||
## 0.13.4-kotlin-1.8.0 - 2022-12-31
|
||||
|
||||
### Added
|
||||
- Public `isInDevelopment` project flag
|
||||
|
||||
### Changed
|
||||
- Require manual pom config for publications
|
||||
- Kotlin 1.8.0
|
||||
- Versions update
|
||||
- Project group changed to `space.kscience`
|
||||
- Moved `yarn.lock` to `gradle` directory
|
||||
|
||||
### Deprecated
|
||||
- FX configuration
|
||||
|
||||
### Removed
|
||||
- Xjdk-release flag because it is broken until https://youtrack.jetbrains.com/issue/KT-52823
|
||||
- Use CSS loader in JS by default
|
||||
|
||||
## 0.11.6-kotlin-1.7.0
|
||||
|
||||
### Changed
|
||||
- Coroutines tests are applied only when explicit `useCoroutines` is used.
|
||||
|
||||
### Removed
|
||||
- Atomicfu support inside the plugin
|
||||
|
||||
### Fixed
|
||||
- Rollback coroutines to 1.6.1
|
||||
|
||||
## 0.11.5-kotlin-1.7.0
|
||||
|
||||
### Added
|
||||
- Coroutine tests as default dependency for tests
|
||||
- Context receiver flag
|
||||
|
||||
### Changed
|
||||
- Separate release tasks for each target
|
||||
- Kotlin 1.7.0
|
||||
- Ktor 2.0.1
|
||||
- ExplicitAPI does not override existing value
|
||||
|
||||
### Removed
|
||||
- Ktor specific artifacts from version catalog
|
||||
|
||||
### Fixed
|
||||
- Moved signing out of sonatype block
|
||||
|
||||
## 0.11.1-kotlin-1.6.10
|
||||
|
||||
### Added
|
||||
- Default templates for README and ARTIFACT
|
||||
|
||||
### Changed
|
||||
- Replaced Groovy templates by FreeMarker
|
||||
|
||||
### Fixed
|
||||
- JS publication sources jar
|
||||
|
||||
## 0.10.9-kotlin-1.6.10
|
||||
|
||||
### Added
|
||||
- html builders for readme
|
||||
|
||||
### Changed
|
||||
- Kotlin 1.6.0
|
||||
- Use indy lambdas by default #32
|
||||
- Change version scheme to `<version>-kotlin-<kotlin version>`
|
||||
|
||||
### Fixed
|
||||
- remove `nativeMain` dependency from `nativeTest`
|
||||
|
||||
## 0.10.4
|
||||
|
||||
### Changed
|
||||
- Kotlin 1.6
|
||||
|
||||
### Fixed
|
||||
- Some issues with opt-ins
|
||||
|
||||
## 0.10.2
|
||||
|
||||
### Added
|
||||
- Experimental automatic JS project bundling in MPP
|
||||
|
||||
### Changed
|
||||
- Remove vcs requirement for Space publication
|
||||
|
||||
## 0.10.0
|
||||
|
||||
### Added
|
||||
- Lazy readme properties
|
||||
- BOM for kotlin-wrappers on JS
|
||||
- Jupyter loader
|
||||
|
||||
### Changed
|
||||
- API validation disabled for dev versions
|
||||
- Kotlin plugins are propagated downstream
|
||||
|
||||
### Removed
|
||||
- bson support
|
||||
|
||||
## 0.9.5
|
||||
|
||||
### Added
|
||||
- Disable API validation for snapshots
|
||||
- `-Xjvm-default=all` on JVM
|
||||
@ -29,17 +152,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `useDateTime` in extension
|
||||
- Kotlin 1.5
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- Publish plugin. Use MavenPublish instead
|
||||
|
||||
### Fixed
|
||||
- Removed unnecessary `afterEvaluate` for compatibility with gradle 7.0
|
||||
|
||||
### Security
|
||||
## 0.9.0
|
||||
|
||||
## [0.9.0]
|
||||
### Added
|
||||
- Skip sonatype publishing for dev versions
|
||||
|
||||
@ -53,11 +173,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Removed
|
||||
- Bintray publishing
|
||||
|
||||
### Fixed
|
||||
## 0.8.4
|
||||
|
||||
### Security
|
||||
|
||||
## [0.8.4]
|
||||
### Added
|
||||
- Adaptive support for host OS in native
|
||||
- CSS support for JS targets
|
||||
@ -66,18 +183,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Kotlin 1.4.31
|
||||
- Coroutines 1.4.3
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
- Plugin loading order for publishing
|
||||
- Release task
|
||||
- Readme generation for multi-module project
|
||||
|
||||
### Security
|
||||
## 0.8.1
|
||||
|
||||
## [0.8.1]
|
||||
### Added
|
||||
- Ktor version to versions
|
||||
- Add sonatype publishing
|
||||
@ -90,8 +202,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Common plugin id changed to `common`
|
||||
- Plugins group changed to `ru.mipt.npm` with `gradle` prefix
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- kaml
|
||||
|
||||
@ -99,9 +209,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fix publishing load order for sonatype
|
||||
- Fix root project readme
|
||||
|
||||
### Security
|
||||
|
||||
## [0.7.4]
|
||||
## 0.7.4
|
||||
|
||||
### Added
|
||||
- Changelog plugin automatically applied to `project`.
|
||||
@ -128,11 +236,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Removed
|
||||
- `useDokka` method. Documentation jar should be added manually if needed.
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
### Security
|
||||
## [0.6.0]
|
||||
## 0.6.0
|
||||
|
||||
### Added
|
||||
- Migrate to kotlin 1.4.0
|
||||
@ -140,10 +244,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Add `application()` toggle in plugin configuration to produce binaries on JS and applicaion plugin on jvm.
|
||||
- Add `publish` to expose publishing configuration.
|
||||
|
||||
### Changed
|
||||
-Publishing in bintray now is automatic.
|
||||
|
||||
## [0.5.2]
|
||||
## 0.5.2
|
||||
|
||||
### Added
|
||||
- Copy resources for jvm modules and jvm source sets in mpp.
|
29
README.md
29
README.md
@ -1,29 +1,28 @@
|
||||
[![Maven Central](https://img.shields.io/maven-central/v/space.kscience.gradle.project/space.kscience.gradle.project.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22space.kscience.gradle.project%22%20AND%20a:%22space.kscience.gradle.project.gradle.plugin%22)
|
||||
|
||||
# KScience build tools
|
||||
|
||||
A collection of gradle plugins for building and publish in *kscience* and *dataforge* projects.
|
||||
|
||||
## ru.mipt.npm.gradle.common
|
||||
## space.kscience.gradle.common
|
||||
A primary plugin. When used with kotlin-jvm, kotlin-js or kotlin-mulitplatform configures the project for appropriate target.
|
||||
|
||||
## ru.mipt.npm.gradle.project
|
||||
## space.kscience.gradle.project
|
||||
Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool.
|
||||
|
||||
## ru.mipt.npm.gradle.publish
|
||||
Enables publishing to maven-central, bintray, Space and github.
|
||||
|
||||
## ru.mipt.npm.gradle.mpp
|
||||
`= kotlin("multiplatform") + ru.mipt.npm.gradle.common`
|
||||
## space.kscience.gradle.mpp
|
||||
`= kotlin("multiplatform") + space.kscience.gradle.common`
|
||||
|
||||
Includes JVM-IR and JS-IR-Browser targets.
|
||||
|
||||
## ru.mipt.npm.gradle.jvm
|
||||
`= kotlin("jvm") + ru.mipt.npm.gradle.common`
|
||||
## space.kscience.gradle.jvm
|
||||
`= kotlin("jvm") + space.kscience.gradle.common`
|
||||
|
||||
## ru.mipt.npm.gradle.js
|
||||
`= kotlin("js") + ru.mipt.npm.gradle.common`
|
||||
## space.kscience.gradle.js
|
||||
`= kotlin("js") + space.kscience.gradle.common`
|
||||
|
||||
## ru.mipt.npm.gradle.native
|
||||
add default native targets to `ru.mipt.npm.gradle.mpp`
|
||||
## space.kscience.gradle.native
|
||||
add default native targets to `space.kscience.gradle.mpp`
|
||||
|
||||
## ru.mipt.npm.gradle.node
|
||||
add node target to `ru.mipt.npm.gradle.mpp`
|
||||
## space.kscience.gradle.node
|
||||
add node target to `space.kscience.gradle.mpp`
|
||||
|
199
build.gradle.kts
199
build.gradle.kts
@ -3,18 +3,17 @@ plugins {
|
||||
`kotlin-dsl`
|
||||
`maven-publish`
|
||||
signing
|
||||
id("org.jetbrains.changelog") version "1.1.2"
|
||||
id("org.jetbrains.dokka") version "1.4.32"
|
||||
`version-catalog`
|
||||
alias(libs.plugins.changelog)
|
||||
alias(libs.plugins.dokka)
|
||||
}
|
||||
|
||||
group = "ru.mipt.npm"
|
||||
version = "0.9.5"
|
||||
group = "space.kscience"
|
||||
version = libs.versions.tools.get()
|
||||
|
||||
description = "Build tools for DataForge and kscience projects"
|
||||
description = "Build tools for kotlin for science projects"
|
||||
|
||||
changelog{
|
||||
version = project.version.toString()
|
||||
}
|
||||
changelog.version.set(project.version.toString())
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -22,88 +21,120 @@ repositories {
|
||||
maven("https://repo.kotlin.link")
|
||||
}
|
||||
|
||||
val kotlinVersion = "1.5.0"
|
||||
kotlin.explicitApiWarning()
|
||||
|
||||
java {
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
// Add plugins used in buildSrc as dependencies, also we should specify version only here
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.16.1")
|
||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.32")
|
||||
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.1.2")
|
||||
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.5.0")
|
||||
api(libs.kotlin.gradle)
|
||||
implementation(libs.binary.compatibility.validator)
|
||||
implementation(libs.changelog.gradle)
|
||||
implementation(libs.dokka.gradle)
|
||||
implementation(libs.kotlin.jupyter.gradle)
|
||||
implementation(libs.kotlin.serialization)
|
||||
implementation(libs.kotlinx.html)
|
||||
implementation("org.tomlj:tomlj:1.1.0")
|
||||
// // nexus publishing plugin
|
||||
// implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
|
||||
|
||||
implementation("org.freemarker:freemarker:2.3.31")
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
}
|
||||
|
||||
project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply {
|
||||
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"
|
||||
}
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
//declaring exported plugins
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("project") {
|
||||
id = "ru.mipt.npm.gradle.project"
|
||||
description = "The root plugin for multimodule project infrastructure"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
|
||||
id = "space.kscience.gradle.project"
|
||||
description = "The root plugin for multi-module project infrastructure"
|
||||
implementationClass = "space.kscience.gradle.KScienceProjectPlugin"
|
||||
}
|
||||
|
||||
create("mpp") {
|
||||
id = "ru.mipt.npm.gradle.mpp"
|
||||
id = "space.kscience.gradle.mpp"
|
||||
description = "Pre-configured multiplatform project"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
|
||||
implementationClass = "space.kscience.gradle.KScienceMPPlugin"
|
||||
}
|
||||
|
||||
create("jvm") {
|
||||
id = "ru.mipt.npm.gradle.jvm"
|
||||
id = "space.kscience.gradle.jvm"
|
||||
description = "Pre-configured JVM project"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
|
||||
implementationClass = "space.kscience.gradle.KScienceJVMPlugin"
|
||||
}
|
||||
|
||||
create("js") {
|
||||
id = "ru.mipt.npm.gradle.js"
|
||||
id = "space.kscience.gradle.js"
|
||||
description = "Pre-configured JS project"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
|
||||
}
|
||||
|
||||
create("native") {
|
||||
id = "ru.mipt.npm.gradle.native"
|
||||
description = "Additional native targets to be use alongside mpp"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
|
||||
}
|
||||
|
||||
create("node") {
|
||||
id = "ru.mipt.npm.gradle.node"
|
||||
description = "Additional nodejs target to be use alongside mpp"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
|
||||
implementationClass = "space.kscience.gradle.KScienceJSPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
val vcs = "https://github.com/mipt-npm/gradle-tools"
|
||||
tasks.create("version") {
|
||||
group = "publishing"
|
||||
val versionFile = project.buildDir.resolve("project-version.txt")
|
||||
outputs.file(versionFile)
|
||||
doLast {
|
||||
versionFile.createNewFile()
|
||||
versionFile.writeText(project.version.toString())
|
||||
println(project.version)
|
||||
}
|
||||
}
|
||||
|
||||
val sourcesJar: Jar by tasks.creating(Jar::class) {
|
||||
//publishing version catalog
|
||||
|
||||
catalog.versionCatalog {
|
||||
from(files("gradle/libs.versions.toml"))
|
||||
}
|
||||
|
||||
//publishing the artifact
|
||||
|
||||
val sourcesJar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
from(sourceSets.named("main").get().allSource)
|
||||
}
|
||||
}
|
||||
|
||||
val javadocsJar: Jar by tasks.creating(Jar::class) {
|
||||
group = "documentation"
|
||||
val javadocsJar by tasks.creating(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.dokkaHtml)
|
||||
}
|
||||
}
|
||||
|
||||
val emptyJavadocJar by tasks.creating(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
archiveBaseName.set("empty")
|
||||
archiveClassifier.set("javadoc")
|
||||
}
|
||||
|
||||
|
||||
val emptySourcesJar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
archiveBaseName.set("empty")
|
||||
}
|
||||
|
||||
publishing {
|
||||
val vcs = "https://github.com/mipt-npm/gradle-tools"
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
||||
publication.apply {
|
||||
artifact(sourcesJar)
|
||||
artifact(javadocsJar)
|
||||
publications {
|
||||
create<MavenPublication>("catalog") {
|
||||
from(components["versionCatalog"])
|
||||
artifactId = "version-catalog"
|
||||
|
||||
pom {
|
||||
name.set("version-catalog")
|
||||
}
|
||||
}
|
||||
|
||||
withType<MavenPublication> {
|
||||
// thanks @vladimirsitnikv for the fix
|
||||
artifact(if (name == "catalog") emptySourcesJar else sourcesJar)
|
||||
artifact(if (name == "catalog") emptyJavadocJar else javadocsJar)
|
||||
|
||||
|
||||
pom {
|
||||
name.set(project.name)
|
||||
@ -113,19 +144,20 @@ afterEvaluate {
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
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("http://npm.mipt.ru")
|
||||
organizationUrl.set("https://npm.mipt.ru")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
scm {
|
||||
url.set(vcs)
|
||||
tag.set(project.version.toString())
|
||||
@ -134,22 +166,21 @@ afterEvaluate {
|
||||
}
|
||||
}
|
||||
|
||||
val spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
|
||||
val spaceUser: String? = project.findProperty("publishing.space.user") as? String
|
||||
val spaceToken: String? = project.findProperty("publishing.space.token") as? String
|
||||
val spaceRepo = "https://maven.pkg.jetbrains.space/spc/p/sci/maven"
|
||||
val spaceUser: String? = findProperty("publishing.space.user") as? String
|
||||
val spaceToken: String? = findProperty("publishing.space.token") as? String
|
||||
|
||||
if (spaceUser != null && spaceToken != null) {
|
||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||
repositories {
|
||||
maven {
|
||||
|
||||
repositories.maven {
|
||||
name = "space"
|
||||
url = uri(spaceRepo)
|
||||
|
||||
credentials {
|
||||
username = spaceUser
|
||||
password = spaceToken
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,26 +194,36 @@ afterEvaluate {
|
||||
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
}
|
||||
|
||||
if (plugins.findPlugin("signing") == null) {
|
||||
plugins.apply("signing")
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
repositories.maven {
|
||||
name = "sonatype"
|
||||
url = uri(sonatypeRepo)
|
||||
|
||||
credentials {
|
||||
username = sonatypeUser
|
||||
password = sonatypePassword
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
//useGpgCmd()
|
||||
sign(publications)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
kotlin {
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(11))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.processResources.configure {
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
from("gradle/libs.versions.toml")
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/gradle/gradle/issues/15568
|
||||
tasks.withType<AbstractPublishToMaven>().configureEach {
|
||||
mustRunAfter(tasks.withType<Sign>())
|
||||
}
|
1
gradle.properties
Normal file
1
gradle.properties
Normal file
@ -0,0 +1 @@
|
||||
kotlin.code.style=official
|
116
gradle/libs.versions.toml
Normal file
116
gradle/libs.versions.toml
Normal file
@ -0,0 +1,116 @@
|
||||
[versions]
|
||||
tools = "0.14.4-kotlin-1.8.20-RC"
|
||||
kotlin = "1.8.20-RC"
|
||||
atomicfu = "0.19.0"
|
||||
binary-compatibility-validator = "0.12.1"
|
||||
changelog = "2.0.0"
|
||||
dokka = "1.7.20"
|
||||
kotlin-jupyter = "0.11.0-317"
|
||||
kotlinx-benchmark = "0.4.7"
|
||||
kotlinx-cli = "0.3.5"
|
||||
kotlinx-coroutines = "1.6.4"
|
||||
kotlinx-datetime = "0.4.0"
|
||||
kotlinx-html = "0.8.0"
|
||||
kotlinx-knit = "0.4.0"
|
||||
kotlinx-nodejs = "0.0.7"
|
||||
kotlinx-serialization = "1.4.1"
|
||||
ktor = "2.2.3"
|
||||
xmlutil = "0.84.3"
|
||||
yamlkt = "0.12.0"
|
||||
jsBom = "1.0.0-pre.509"
|
||||
junit = "5.9.2"
|
||||
compose = "1.3.0"
|
||||
logback = "1.4.5"
|
||||
|
||||
[libraries]
|
||||
atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" }
|
||||
atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu" }
|
||||
|
||||
binary-compatibility-validator = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
|
||||
|
||||
changelog-gradle = { module = "org.jetbrains.intellij.plugins:gradle-changelog-plugin", version.ref = "changelog" }
|
||||
|
||||
dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
|
||||
|
||||
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
||||
|
||||
kotlin-jupyter-gradle = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin", version.ref = "kotlin-jupyter" }
|
||||
|
||||
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
|
||||
|
||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-debug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-reactive = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactive", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-rx2 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-rx3 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx3", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-javafx = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-javafx", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-guava = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-guava", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines" }
|
||||
|
||||
kotlinx-cli = { module = "org.jetbrains.kotlinx:kotlinx-cli", version.ref = "kotlinx-cli" }
|
||||
|
||||
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
|
||||
|
||||
kotlinx-html = { module = "org.jetbrains.kotlinx:kotlinx-html", version.ref = "kotlinx-html" }
|
||||
|
||||
kotlinx-knit = { module = "org.jetbrains.kotlinx:kotlinx-knit", version.ref = "kotlinx-knit" }
|
||||
|
||||
kotlinx-nodejs = { module = "org.jetbrains.kotlinx:kotlinx-nodejs", version.ref = "kotlinx-nodejs" }
|
||||
|
||||
kotlinx-serialization-cbor = { module = "org.jetbrains.kotlinx:kotlinx-serialization-cbor", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-hocon = { module = "org.jetbrains.kotlinx:kotlinx-serialization-hocon", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "kotlinx-serialization" }
|
||||
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
|
||||
|
||||
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
|
||||
|
||||
xmlutil-core = { module = "io.github.pdvrieze.xmlutil:core", version.ref = "xmlutil" }
|
||||
xmlutil-ktor = { module = "io.github.pdvrieze.xmlutil:ktor", version.ref = "xmlutil" }
|
||||
xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", version.ref = "xmlutil" }
|
||||
|
||||
yamlkt = { module = "net.mamoe.yamlkt:yamlkt", version.ref = "yamlkt" }
|
||||
|
||||
logback-classic = {module = "ch.qos.logback:logback-classic", version.ref = "logback"}
|
||||
|
||||
[plugins]
|
||||
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
|
||||
|
||||
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||
compose = {id = "org.jetbrains.compose", version.ref = "compose"}
|
||||
|
||||
gradle-common = { id = "space.kscience.gradle.common", version.ref = "tools" }
|
||||
gradle-project = { id = "space.kscience.gradle.project", version.ref = "tools" }
|
||||
gradle-mpp = { id = "space.kscience.gradle.mpp", version.ref = "tools" }
|
||||
gradle-jvm = { id = "space.kscience.gradle.jvm", version.ref = "tools" }
|
||||
gradle-js = { id = "space.kscience.gradle.js", version.ref = "tools" }
|
||||
gradle-native = { id = "space.kscience.gradle.native", version.ref = "tools" }
|
||||
gradle-node = { id = "space.kscience.gradle.node", version.ref = "tools" }
|
||||
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlin" }
|
||||
kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" }
|
||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
|
||||
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
kotlin-native-cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
|
||||
kotlin-plugin-allopen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" }
|
||||
kotlin-plugin-jpa = { id = "org.jetbrains.kotlin.plugin.jpa", version.ref = "kotlin" }
|
||||
kotlin-plugin-lombok = { id = "org.jetbrains.kotlin.plugin.lombok", version.ref = "kotlin" }
|
||||
kotlin-plugin-noarg = { id = "org.jetbrains.kotlin.plugin.noarg", version.ref = "kotlin" }
|
||||
kotlin-plugin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
|
||||
kotlin-plugin-scripting = { id = "org.jetbrains.kotlin.plugin.scripting", version.ref = "kotlin" }
|
||||
kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
kotlin-plugin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
|
||||
|
||||
kotlin-jupyter-api = { id = "org.jetbrains.kotlin.jupyter.api", version.ref = "kotlin-jupyter" }
|
||||
|
||||
kotlinx-benchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "kotlinx-benchmark" }
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
269
gradlew
vendored
Normal file → Executable file
269
gradlew
vendored
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -17,67 +17,101 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@ -106,80 +140,95 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
@ -1,2 +0,0 @@
|
||||
rootProject.name = 'gradle-tools'
|
||||
|
1
settings.gradle.kts
Normal file
1
settings.gradle.kts
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = "gradle-tools"
|
@ -1,166 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
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.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
|
||||
|
||||
open class KScienceCommonPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
//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["main"].apply {
|
||||
languageSettings.applySettings()
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
languageSettings.applySettings()
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<KotlinJvmCompile> {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
|
||||
}
|
||||
}
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.apply {
|
||||
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["main"].apply {
|
||||
languageSettings.applySettings()
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
languageSettings.applySettings()
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(tasks.findByName("processResources") as? Copy)?.apply {
|
||||
fromJsDependencies("runtimeClasspath")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
js(IR) {
|
||||
browser{
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.invoke {
|
||||
val commonMain by getting
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-common"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
||||
}
|
||||
}
|
||||
val jsMain by getting
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
targets.all {
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
|
||||
fromJsDependencies("jsRuntimeClasspath")
|
||||
}
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.apply {
|
||||
withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// apply dokka for all projects
|
||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||
plugins.apply("org.jetbrains.dokka")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.ApplicationPlugin
|
||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
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 ru.mipt.npm.gradle.internal.defaultPlatform
|
||||
import ru.mipt.npm.gradle.internal.useCommonDependency
|
||||
import ru.mipt.npm.gradle.internal.useFx
|
||||
|
||||
enum class FXModule(val artifact: String, 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)
|
||||
}
|
||||
|
||||
enum class FXPlatform(val id: String) {
|
||||
WINDOWS("win"),
|
||||
LINUX("linux"),
|
||||
MAC("mac")
|
||||
}
|
||||
|
||||
enum class DependencyConfiguration {
|
||||
API,
|
||||
IMPLEMENTATION,
|
||||
COMPILE_ONLY
|
||||
}
|
||||
|
||||
enum class DependencySourceSet(val setName: String, val suffix: String) {
|
||||
MAIN("main", "Main"),
|
||||
TEST("test", "Test")
|
||||
}
|
||||
|
||||
|
||||
class KScienceExtension(val project: Project) {
|
||||
|
||||
/**
|
||||
* Use coroutines-core with default version or [version]
|
||||
*/
|
||||
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-atmicfu plugin and library
|
||||
*/
|
||||
fun useAtomic(
|
||||
version: String = KScienceVersions.atomicVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
|
||||
): Unit = project.run {
|
||||
plugins.apply("kotlinx-atomicfu")
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:atomicfu:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Use core serialization library and configure targets
|
||||
*/
|
||||
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).apply(block)
|
||||
}
|
||||
|
||||
fun useFx(
|
||||
vararg modules: FXModule,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
|
||||
version: String = "11",
|
||||
platform: FXPlatform = defaultPlatform
|
||||
) = project.useFx(modules.toList(), configuration, version, platform)
|
||||
|
||||
fun useHtml(
|
||||
version: String = KScienceVersions.atomicVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
|
||||
): Unit = project.useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-html:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
|
||||
/**
|
||||
* Use kotlinx-datetime library with default version or [version]
|
||||
*/
|
||||
fun useDateTime(version: String = KScienceVersions.dateTimeVersion){
|
||||
project.useCommonDependency("org.jetbrains.kotlinx:kotlinx-datetime:$version")
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark this module as an application module. JVM application should be enabled separately
|
||||
*/
|
||||
fun application() {
|
||||
project.extensions.findByType<KotlinProjectExtension>()?.apply {
|
||||
explicitApi = null
|
||||
}
|
||||
|
||||
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
project.plugins.apply(ApplicationPlugin::class.java)
|
||||
}
|
||||
|
||||
project.extensions.findByType<KotlinJsProjectExtension>()?.apply {
|
||||
js {
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
|
||||
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
js {
|
||||
binaries.executable()
|
||||
}
|
||||
targets.filterIsInstance<KotlinNativeTarget>().forEach {
|
||||
it.binaries.executable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun publish() {
|
||||
project.plugins.apply(MavenPublishPlugin::class)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.registerKScienceExtension() {
|
||||
if (extensions.findByType<KScienceExtension>() == null) {
|
||||
extensions.add("kscience", KScienceExtension(this))
|
||||
}
|
||||
}
|
@ -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
|
||||
|
||||
open class KScienceJSPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
if (plugins.findPlugin("org.jetbrains.kotlin.js") == null) {
|
||||
pluginManager.apply("org.jetbrains.kotlin.js")
|
||||
} else {
|
||||
logger.info("Kotlin JS plugin is already present")
|
||||
}
|
||||
plugins.apply(KScienceCommonPlugin::class)
|
||||
}
|
||||
}
|
@ -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
|
||||
|
||||
open class KScienceJVMPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
if (plugins.findPlugin("org.jetbrains.kotlin.jvm") == null) {
|
||||
pluginManager.apply("org.jetbrains.kotlin.jvm")
|
||||
} else {
|
||||
logger.info("Kotlin JVM plugin is already present")
|
||||
}
|
||||
plugins.apply(KScienceCommonPlugin::class)
|
||||
}
|
||||
}
|
@ -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
|
||||
|
||||
open class KScienceMPPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
||||
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
|
||||
} else {
|
||||
logger.info("Kotlin MPP plugin is already present")
|
||||
}
|
||||
plugins.apply(KScienceCommonPlugin::class)
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
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.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
|
||||
private fun KotlinMultiplatformExtension.sourceSets(configure: Action<NamedDomainObjectContainer<KotlinSourceSet>>): Unit =
|
||||
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("sourceSets", configure)
|
||||
|
||||
class KScienceNativePlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) = project.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")
|
||||
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
||||
logger.info("KScience plugin is not resolved. Adding it automatically")
|
||||
pluginManager.apply(KScienceCommonPlugin::class)
|
||||
}
|
||||
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
val isLinux = hostOs == "Linux"
|
||||
val isMinGw = hostOs.startsWith("Windows")
|
||||
val isMacOs = hostOs == "Mac OS X"
|
||||
|
||||
if (isLinux || isMinGw) {
|
||||
linuxX64()
|
||||
}
|
||||
if (isMinGw) {
|
||||
mingwX64()
|
||||
}
|
||||
if (isMacOs) {
|
||||
macosX64()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain = findByName("commonMain")!!
|
||||
val commonTest = findByName("commonTest")!!
|
||||
|
||||
val nativeMain = create("nativeMain").apply {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
val nativeTest = create("nativeTest").apply {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
findByName("linuxX64Main")?.dependsOn(nativeMain)
|
||||
findByName("linuxX64Test")?.dependsOn(nativeTest)
|
||||
|
||||
findByName("mingwX64Main")?.dependsOn(nativeMain)
|
||||
findByName("mingwX64Test")?.dependsOn(nativeTest)
|
||||
|
||||
findByName("macosX64Main")?.dependsOn(nativeMain)
|
||||
findByName("macosX64Test")?.dependsOn(nativeTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
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.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
|
||||
private fun KotlinMultiplatformExtension.sourceSets(configure: Action<NamedDomainObjectContainer<KotlinSourceSet>>): Unit =
|
||||
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("sourceSets", configure)
|
||||
|
||||
/**
|
||||
* Create a separate target for node
|
||||
*/
|
||||
class KScienceNodePlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) = 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")
|
||||
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
||||
logger.info("KScience plugin is not resolved. Adding it automatically")
|
||||
pluginManager.apply(KScienceCommonPlugin::class)
|
||||
}
|
||||
|
||||
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,191 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import kotlinx.validation.ApiValidationExtension
|
||||
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.changelog.ChangelogPlugin
|
||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import ru.mipt.npm.gradle.internal.*
|
||||
|
||||
@Suppress("unused")
|
||||
class KSciencePublishingExtension(val project: Project) {
|
||||
private var initializedFlag = false
|
||||
|
||||
fun configurePublications(vcsUrl: String) {
|
||||
if (!initializedFlag) {
|
||||
project.setupPublication(vcsUrl)
|
||||
initializedFlag = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* github publishing
|
||||
*/
|
||||
fun github(githubProject: String, githubOrg: String = "mipt-npm") {
|
||||
//automatically initialize vcs using github
|
||||
if (!initializedFlag) {
|
||||
configurePublications("https://github.com/$githubOrg/$githubProject")
|
||||
}
|
||||
project.addGithubPublishing(githubOrg, githubProject)
|
||||
}
|
||||
|
||||
/**
|
||||
* Space publishing
|
||||
*/
|
||||
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") {
|
||||
require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" }
|
||||
project.addSpacePublishing(spaceRepo)
|
||||
}
|
||||
|
||||
// // Bintray publishing
|
||||
// var bintrayOrg: String? by project.extra
|
||||
// var bintrayUser: String? by project.extra
|
||||
// var bintrayApiKey: String? by project.extra
|
||||
// var bintrayRepo: String? by project.extra
|
||||
|
||||
/**
|
||||
* Sonatype publishing
|
||||
*/
|
||||
fun sonatype() {
|
||||
require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" }
|
||||
project.addSonatypePublishing()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply extension and repositories
|
||||
*/
|
||||
open class KScienceProjectPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project): Unit = target.run {
|
||||
apply<ChangelogPlugin>()
|
||||
apply<DokkaPlugin>()
|
||||
apply<BinaryCompatibilityValidatorPlugin>()
|
||||
|
||||
val rootReadmeExtension = KScienceReadmeExtension(this)
|
||||
extensions.add("ksciencePublish", KSciencePublishingExtension(this))
|
||||
extensions.add("readme", rootReadmeExtension)
|
||||
|
||||
//Add readme generators to individual subprojects
|
||||
subprojects {
|
||||
val readmeExtension = KScienceReadmeExtension(this)
|
||||
extensions.add("readme", readmeExtension)
|
||||
val generateReadme by tasks.creating {
|
||||
group = "documentation"
|
||||
description = "Generate a README file if stub is present"
|
||||
|
||||
if (readmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(readmeExtension.readmeTemplate)
|
||||
}
|
||||
readmeExtension.additionalFiles.forEach {
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
|
||||
val readmeFile = this@subprojects.file("README.md")
|
||||
outputs.file(readmeFile)
|
||||
|
||||
doLast {
|
||||
val readmeString = readmeExtension.readmeString()
|
||||
if (readmeString != null) {
|
||||
readmeFile.writeText(readmeString)
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<DokkaTask> {
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
}
|
||||
|
||||
val generateReadme by tasks.creating {
|
||||
group = "documentation"
|
||||
description = "Generate a README file and a feature matrix if stub is present"
|
||||
|
||||
subprojects {
|
||||
tasks.findByName("generateReadme")?.let {
|
||||
dependsOn(it)
|
||||
}
|
||||
}
|
||||
|
||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(rootReadmeExtension.readmeTemplate)
|
||||
}
|
||||
rootReadmeExtension.additionalFiles.forEach {
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
|
||||
val readmeFile = project.file("README.md")
|
||||
outputs.file(readmeFile)
|
||||
|
||||
doLast {
|
||||
// val projects = subprojects.associate {
|
||||
// val normalizedPath = it.path.replaceFirst(":","").replace(":","/")
|
||||
// it.path.replace(":","/") to it.extensions.findByType<KScienceReadmeExtension>()
|
||||
// }
|
||||
|
||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||
|
||||
val modulesString = buildString {
|
||||
subprojects.forEach { subproject ->
|
||||
val name = subproject.name
|
||||
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
|
||||
val ext = subproject.extensions.findByType<KScienceReadmeExtension>()
|
||||
appendLine("<hr/>")
|
||||
appendLine("\n* ### [$name]($path)")
|
||||
if (ext != null) {
|
||||
appendLine("> ${ext.description}")
|
||||
appendLine(">\n> **Maturity**: ${ext.maturity}")
|
||||
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
|
||||
if (featureString.isNotBlank()) {
|
||||
appendLine(">\n> **Features:**")
|
||||
appendLine(featureString)
|
||||
}
|
||||
}
|
||||
}
|
||||
appendLine("<hr/>")
|
||||
}
|
||||
|
||||
val rootReadmeProperties: Map<String, Any?> =
|
||||
rootReadmeExtension.actualizedProperties + ("modules" to modulesString)
|
||||
|
||||
readmeFile.writeText(
|
||||
SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate)
|
||||
.make(rootReadmeProperties).toString()
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<DokkaTask> {
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
|
||||
//val patchChangelog by tasks.getting
|
||||
|
||||
val release by tasks.creating {
|
||||
group = RELEASE_GROUP
|
||||
description = "Publish development or production release based on version suffix"
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
|
||||
// Disable API validation for snapshots
|
||||
if (isSnapshot()) {
|
||||
extensions.findByType<ApiValidationExtension>()?.apply {
|
||||
validationDisabled = true
|
||||
logger.warn("API validation is disabled for snapshot or dev version")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val RELEASE_GROUP = "release"
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import kotlinx.validation.ApiValidationExtension
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
import java.io.File
|
||||
|
||||
enum class Maturity {
|
||||
PROTOTYPE,
|
||||
EXPERIMENTAL,
|
||||
DEVELOPMENT,
|
||||
STABLE
|
||||
}
|
||||
|
||||
|
||||
class KScienceReadmeExtension(val project: Project) {
|
||||
var description: String = project.description ?: ""
|
||||
var maturity: Maturity = Maturity.EXPERIMENTAL
|
||||
set(value) {
|
||||
field = value
|
||||
val projectName = project.name
|
||||
if (value == Maturity.EXPERIMENTAL || value == Maturity.PROTOTYPE) {
|
||||
project.rootProject.run {
|
||||
plugins.withId("org.jetbrains.kotlinx.binary-compatibility-validator") {
|
||||
extensions.getByType<ApiValidationExtension>().apply {
|
||||
project.logger.warn("$value project $projectName is excluded from API validation")
|
||||
ignoredProjects.add(projectName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var readmeTemplate: File = project.file("docs/README-TEMPLATE.md")
|
||||
|
||||
data class Feature(val id: String, val description: String, val ref: String?, val name: String = id)
|
||||
|
||||
val features = ArrayList<Feature>()
|
||||
|
||||
@Deprecated("Use lambda builder instead")
|
||||
fun feature(id: String, description: String, ref: String? = null, name: String = id) {
|
||||
features.add(Feature(id, description, ref, name))
|
||||
}
|
||||
|
||||
fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
|
||||
features.add(Feature(id, description(), ref, name))
|
||||
}
|
||||
|
||||
private val properties: MutableMap<String, () -> Any?> = mutableMapOf(
|
||||
"name" to { project.name },
|
||||
"group" to { project.group },
|
||||
"version" to { project.version },
|
||||
"features" to { featuresString() }
|
||||
)
|
||||
|
||||
val actualizedProperties
|
||||
get() = properties.mapValues { (_, value) ->
|
||||
value.invoke()
|
||||
}
|
||||
|
||||
fun property(key: String, value: Any?) {
|
||||
properties[key] = { value }
|
||||
}
|
||||
|
||||
fun propertyByTemplate(key: String, template: String) {
|
||||
val actual = actualizedProperties
|
||||
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
||||
}
|
||||
|
||||
internal val additionalFiles = ArrayList<File>()
|
||||
|
||||
fun propertyByTemplate(key: String, template: File) {
|
||||
val actual = actualizedProperties
|
||||
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
||||
additionalFiles.add(template)
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a markdown string listing features
|
||||
*/
|
||||
fun featuresString(itemPrefix: String = " - ", pathPrefix: String = "") = buildString {
|
||||
features.forEach {
|
||||
appendLine("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description}")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a readme string from the stub
|
||||
*/
|
||||
fun readmeString(): String? {
|
||||
return if (readmeTemplate.exists()) {
|
||||
val actual = actualizedProperties
|
||||
SimpleTemplateEngine().createTemplate(readmeTemplate).make(actual).toString()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.JavaVersion
|
||||
|
||||
/**
|
||||
* Build constants
|
||||
*/
|
||||
object KScienceVersions {
|
||||
const val kotlinVersion = "1.5.0"
|
||||
const val kotlinxNodeVersion = "0.0.7"
|
||||
const val coroutinesVersion = "1.4.3"
|
||||
const val serializationVersion = "1.1.0"
|
||||
const val atomicVersion = "0.16.1"
|
||||
const val ktorVersion = "1.5.3"
|
||||
const val htmlVersion = "0.7.3"
|
||||
const val dateTimeVersion = "0.1.1"
|
||||
|
||||
val JVM_TARGET = JavaVersion.VERSION_11
|
||||
|
||||
object Serialization{
|
||||
const val xmlVersion = "0.81.2"
|
||||
const val bsonVersion = "0.4.4"
|
||||
const val yamlKtVersion = "0.9.0"
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
import ru.mipt.npm.gradle.internal.useCommonDependency
|
||||
import ru.mipt.npm.gradle.internal.useDependency
|
||||
|
||||
class SerializationTargets(
|
||||
val sourceSet: DependencySourceSet,
|
||||
val configuration: DependencyConfiguration
|
||||
) {
|
||||
|
||||
fun Project.json(
|
||||
version: String = KScienceVersions.serializationVersion
|
||||
) {
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-json:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.cbor(
|
||||
version: String = KScienceVersions.serializationVersion
|
||||
) {
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-cbor:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.protobuf(
|
||||
version: String = KScienceVersions.serializationVersion
|
||||
) {
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.xml(
|
||||
version: String = KScienceVersions.Serialization.xmlVersion
|
||||
) {
|
||||
repositories {
|
||||
maven("https://dl.bintray.com/pdvrieze/maven")
|
||||
}
|
||||
useCommonDependency(
|
||||
"net.devrieze:xmlutil-serialization:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.yamlKt(
|
||||
version: String = KScienceVersions.Serialization.yamlKtVersion
|
||||
) {
|
||||
useCommonDependency(
|
||||
"net.mamoe.yamlkt:yamlkt:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.bson(
|
||||
version: String = KScienceVersions.Serialization.bsonVersion
|
||||
) {
|
||||
useDependency(
|
||||
"jvm" to "com.github.jershell:kbson:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
}
|
@ -1,72 +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.tasks.Copy
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||
|
||||
internal fun LanguageSettingsBuilder.applySettings(): Unit {
|
||||
languageVersion = "1.5"
|
||||
apiVersion = "1.5"
|
||||
progressiveMode = true
|
||||
useExperimentalAnnotation("kotlin.Experimental")
|
||||
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||
useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
||||
useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
||||
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||
useExperimentalAnnotation("kotlin.js.ExperimentalJsExport")
|
||||
}
|
||||
|
||||
internal fun RepositoryHandler.applyRepos(): Unit {
|
||||
mavenCentral()
|
||||
maven("https://repo.kotlin.link")
|
||||
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
|
||||
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
|
||||
}
|
||||
|
||||
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 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
|
||||
|
||||
val defaultPlatform: FXPlatform = when {
|
||||
Os.isFamily(Os.FAMILY_WINDOWS) -> FXPlatform.WINDOWS
|
||||
Os.isFamily(Os.FAMILY_MAC) -> FXPlatform.MAC
|
||||
Os.isFamily(Os.FAMILY_UNIX) -> FXPlatform.LINUX
|
||||
else -> error("Platform not recognized")
|
||||
}
|
||||
|
||||
private fun KotlinDependencyHandler.addFXDependencies(
|
||||
modules: List<FXModule>,
|
||||
configuration: DependencyConfiguration,
|
||||
version: String = "14",
|
||||
platform: FXPlatform = defaultPlatform
|
||||
) {
|
||||
modules.flatMap { it.dependencies.toList() + it }.distinct().forEach {
|
||||
val notation = "org.openjfx:${it.artifact}:$version:${platform.id}"
|
||||
when (configuration) {
|
||||
DependencyConfiguration.API -> api(notation)
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementation(notation)
|
||||
DependencyConfiguration.COMPILE_ONLY -> compileOnly(notation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.useFx(
|
||||
modules: List<FXModule>,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
|
||||
version: String = "14",
|
||||
platform: FXPlatform = defaultPlatform
|
||||
): Unit = afterEvaluate {
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
sourceSets.findByName("jvmMain")?.apply {
|
||||
dependencies {
|
||||
addFXDependencies(modules, configuration = configuration, version = version, platform = platform)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
extensions.findByType<KotlinJvmProjectExtension>()?.apply {
|
||||
sourceSets.findByName("main")?.apply {
|
||||
dependencies {
|
||||
addFXDependencies(modules, configuration = configuration, version = version, platform = platform)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,242 +0,0 @@
|
||||
package ru.mipt.npm.gradle.internal
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.plugins.signing.SigningExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
|
||||
private fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
||||
?: System.getenv(propertyName)
|
||||
|
||||
private fun Project.requestProperty(propertyName: String): String = requestPropertyOrNull(propertyName)
|
||||
?: error("Property $propertyName not defined")
|
||||
|
||||
|
||||
internal fun Project.setupPublication(vcs: String) = allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
|
||||
plugins.withId("ru.mipt.npm.gradle.js") {
|
||||
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
|
||||
|
||||
val sourcesJar: Jar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
from(kotlin.sourceSets["main"].kotlin)
|
||||
}
|
||||
|
||||
publications {
|
||||
create("js", MavenPublication::class) {
|
||||
from(components["kotlin"])
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId("ru.mipt.npm.gradle.jvm") {
|
||||
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
|
||||
|
||||
val sourcesJar: Jar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
from(kotlin.sourceSets["main"].kotlin)
|
||||
}
|
||||
|
||||
publications {
|
||||
create("jvm", MavenPublication::class) {
|
||||
from(components["kotlin"])
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val dokkaJar: Jar by tasks.creating(Jar::class) {
|
||||
group = "documentation"
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.findByName("dokkaHtml"))
|
||||
}
|
||||
|
||||
// Process each publication we have in this project
|
||||
afterEvaluate {
|
||||
publications.withType<MavenPublication>().forEach { publication ->
|
||||
publication.artifact(dokkaJar)
|
||||
publication.pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description ?: project.name)
|
||||
url.set(vcs)
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("http://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("http://npm.mipt.ru")
|
||||
}
|
||||
|
||||
}
|
||||
scm {
|
||||
url.set(vcs)
|
||||
tag.set(project.version.toString())
|
||||
//developerConnection = "scm:git:[fetch=]/*ВАША ССЫЛКА НА .git файл*/[push=]/*Повторить предыдущую ссылку*/"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.isSnapshot() = version.toString().contains("dev") || version.toString().endsWith("SNAPSHOT")
|
||||
|
||||
internal val Project.publicationTarget: String
|
||||
get() {
|
||||
val publicationPlatform = project.findProperty("publishing.platform") as? String
|
||||
return if (publicationPlatform == null) {
|
||||
"AllPublications"
|
||||
} else {
|
||||
publicationPlatform.capitalize() + "Publication"
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.addGithubPublishing(
|
||||
githubOrg: String,
|
||||
githubProject: String
|
||||
) {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping github publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
if (requestPropertyOrNull("publishing.github") == "false") {
|
||||
logger.info("Skipping github publishing because `publishing.github == false`")
|
||||
return
|
||||
}
|
||||
|
||||
val githubUser: String = requestProperty("publishing.github.user")
|
||||
val githubToken: String = requestProperty("publishing.github.token")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
logger.info("Adding github publishing to project [${project.name}]")
|
||||
repositories {
|
||||
maven {
|
||||
name = "github"
|
||||
url = uri("https://maven.pkg.github.com/$githubOrg/$githubProject/")
|
||||
credentials {
|
||||
username = githubUser
|
||||
password = githubToken
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val publicationTask = tasks.getByName("publish${publicationTarget}ToGithubRepository")
|
||||
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.addSpacePublishing(spaceRepo: String) {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping github publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
if (requestPropertyOrNull("publishing.space") == "false") {
|
||||
logger.info("Skipping space publishing because `publishing.space == false`")
|
||||
return
|
||||
}
|
||||
|
||||
val spaceUser: String = requestProperty("publishing.space.user")
|
||||
val spaceToken: String = requestProperty("publishing.space.token")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||
repositories {
|
||||
maven {
|
||||
name = "space"
|
||||
url = uri(spaceRepo)
|
||||
credentials {
|
||||
username = spaceUser
|
||||
password = spaceToken
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
val publicationTask = tasks.getByName("publish${publicationTarget}ToSpaceRepository")
|
||||
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.addSonatypePublishing() {
|
||||
if(requestPropertyOrNull("publishing.enabled")!="true"){
|
||||
logger.info("Skipping github publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
if (isSnapshot()) {
|
||||
logger.info("Sonatype publishing skipped for dev version")
|
||||
return
|
||||
}
|
||||
if (requestPropertyOrNull("publishing.sonatype") == "false") {
|
||||
logger.info("Skipping sonatype publishing because `publishing.sonatype == false`")
|
||||
return
|
||||
}
|
||||
|
||||
val sonatypeUser: String = requestProperty("publishing.sonatype.user")
|
||||
val sonatypePassword: String = requestProperty("publishing.sonatype.password")
|
||||
val signingId: String? = requestPropertyOrNull("publishing.signing.id")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
val sonatypeRepo: String = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
|
||||
if (plugins.findPlugin("signing") == null) {
|
||||
plugins.apply("signing")
|
||||
}
|
||||
extensions.configure<SigningExtension>("signing") {
|
||||
if (!signingId.isNullOrBlank()) {
|
||||
val signingKey: String = requestProperty("publishing.signing.key")
|
||||
val signingPassphrase: String = requestProperty("publishing.signing.passPhrase")
|
||||
|
||||
//if key is provided, use it
|
||||
@Suppress("UnstableApiUsage")
|
||||
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
|
||||
} // else use file signing
|
||||
sign(publications)
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = uri(sonatypeRepo)
|
||||
credentials {
|
||||
username = sonatypeUser
|
||||
password = sonatypePassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val publicationTask = tasks.getByName("publish${publicationTarget}ToSonatypeRepository")
|
||||
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//internal val Project.bintrayPublish: Boolean
|
||||
// get() = (findProperty("publishing.bintray.publish") as? String)?.toBoolean() ?: false
|
||||
//internal val Project.bintrayOrg: String? get() = findProperty("publishing.bintray.org") as? String
|
||||
//internal val Project.bintrayUser: String? get() = findProperty("publishing.bintray.user") as? String
|
||||
//internal val Project.bintrayApiKey: String? get() = findProperty("publishing.bintray.apiKey") as? String
|
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>()
|
||||
}
|
||||
}
|
||||
}
|
262
src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt
Normal file
262
src/main/kotlin/space/kscience/gradle/KScienceProjectPlugin.kt
Normal file
@ -0,0 +1,262 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
import kotlinx.validation.ApiValidationExtension
|
||||
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.maven.MavenPom
|
||||
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.plugins.signing.Sign
|
||||
import org.jetbrains.changelog.ChangelogPlugin
|
||||
import org.jetbrains.changelog.ChangelogPluginExtension
|
||||
import org.jetbrains.dokka.gradle.AbstractDokkaTask
|
||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||
import space.kscience.gradle.internal.*
|
||||
|
||||
/**
|
||||
* Simplifies adding repositories for Maven publishing, responds for releasing tasks for projects.
|
||||
*/
|
||||
public class KSciencePublishingExtension(public val project: Project) {
|
||||
private var isVcsInitialized = false
|
||||
|
||||
/**
|
||||
* Configures Git repository (sources) for the publication.
|
||||
*
|
||||
* @param vcsUrl URL of the repository's web interface.
|
||||
* @param connectionUrl URL of the Git repository.
|
||||
* @param developerConnectionUrl URL of the Git repository for developers.
|
||||
*/
|
||||
public fun pom(
|
||||
vcsUrl: String,
|
||||
connectionUrl: String? = null,
|
||||
developerConnectionUrl: String? = connectionUrl,
|
||||
connectionPrefix: String = "scm:git:",
|
||||
pomConfig: MavenPom.() -> Unit,
|
||||
) {
|
||||
if (!isVcsInitialized) {
|
||||
project.setupPublication {
|
||||
url.set(vcsUrl)
|
||||
|
||||
scm {
|
||||
url.set(vcsUrl)
|
||||
connectionUrl?.let { connection.set("$connectionPrefix$it") }
|
||||
developerConnectionUrl?.let { developerConnection.set("$connectionPrefix$it") }
|
||||
}
|
||||
pomConfig()
|
||||
}
|
||||
|
||||
isVcsInitialized = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds GitHub as VCS and adds GitHub Packages Maven repository to publishing.
|
||||
*
|
||||
* @param githubProject the GitHub project.
|
||||
* @param githubOrg the GitHub user or organization.
|
||||
* @param deploy publish packages in the `deploy` task to the GitHub repository.
|
||||
*/
|
||||
public fun github(
|
||||
githubOrg: String,
|
||||
githubProject: String,
|
||||
deploy: Boolean = project.requestPropertyOrNull("publishing.github") == "true",
|
||||
) {
|
||||
if (deploy) {
|
||||
try {
|
||||
project.addGithubPublishing(githubOrg, githubProject)
|
||||
} catch (t: Throwable) {
|
||||
project.logger.error("Failed to set up github publication", t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Space Packages Maven repository to publishing.
|
||||
*
|
||||
* @param spaceRepo the repository URL.
|
||||
* @param deploy publish packages in the `deploy` task to the Space repository.
|
||||
*/
|
||||
public fun space(
|
||||
spaceRepo: String,
|
||||
) {
|
||||
project.addSpacePublishing(spaceRepo)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Sonatype Maven repository to publishing.
|
||||
*
|
||||
* @param addToRelease publish packages in the `release` task to the Sonatype repository.
|
||||
*/
|
||||
public fun sonatype() {
|
||||
require(isVcsInitialized) { "The project vcs is not set up use 'pom' method to do so" }
|
||||
project.addSonatypePublishing()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies third-party plugins (Dokka, Changelog, binary compatibility validator); configures Maven publishing, README
|
||||
* generation.
|
||||
*/
|
||||
public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project): Unit = target.run {
|
||||
apply<ChangelogPlugin>()
|
||||
apply<DokkaPlugin>()
|
||||
apply<BinaryCompatibilityValidatorPlugin>()
|
||||
|
||||
allprojects{
|
||||
repositories{
|
||||
mavenCentral()
|
||||
maven("https://repo.kotlin.link")
|
||||
maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev")
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/gradle/gradle/issues/15568
|
||||
tasks.withType<AbstractPublishToMaven>().configureEach {
|
||||
mustRunAfter(tasks.withType<Sign>())
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
if (isInDevelopment) {
|
||||
configure<ApiValidationExtension> {
|
||||
validationDisabled = true
|
||||
}
|
||||
} else {
|
||||
configure<ChangelogPluginExtension> {
|
||||
version.set(project.version.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val rootReadmeExtension = KScienceReadmeExtension(this)
|
||||
val ksciencePublish = KSciencePublishingExtension(this)
|
||||
extensions.add("ksciencePublish", ksciencePublish)
|
||||
extensions.add("readme", rootReadmeExtension)
|
||||
|
||||
//Add readme generators to individual subprojects
|
||||
subprojects {
|
||||
val readmeExtension = KScienceReadmeExtension(this)
|
||||
extensions.add("readme", readmeExtension)
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val generateReadme by tasks.creating {
|
||||
group = "documentation"
|
||||
description = "Generate a README file if stub is present"
|
||||
|
||||
if (readmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(readmeExtension.readmeTemplate)
|
||||
}
|
||||
readmeExtension.inputFiles.forEach {
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
|
||||
val readmeFile = this@subprojects.file("README.md")
|
||||
outputs.file(readmeFile)
|
||||
|
||||
doLast {
|
||||
val readmeString = readmeExtension.readmeString()
|
||||
if (readmeString != null) {
|
||||
readmeFile.writeText(readmeString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tasks.withType<AbstractDokkaTask> {
|
||||
// dependsOn(generateReadme)
|
||||
// }
|
||||
}
|
||||
|
||||
val generateReadme by tasks.creating {
|
||||
group = "documentation"
|
||||
description = "Generate a README file and a feature matrix if stub is present"
|
||||
|
||||
subprojects {
|
||||
tasks.findByName("generateReadme")?.let {
|
||||
dependsOn(it)
|
||||
}
|
||||
}
|
||||
|
||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(rootReadmeExtension.readmeTemplate)
|
||||
}
|
||||
|
||||
rootReadmeExtension.inputFiles.forEach {
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
|
||||
val readmeFile = project.file("README.md")
|
||||
outputs.file(readmeFile)
|
||||
|
||||
doLast {
|
||||
// val projects = subprojects.associate {
|
||||
// val normalizedPath = it.path.replaceFirst(":","").replace(":","/")
|
||||
// it.path.replace(":","/") to it.extensions.findByType<KScienceReadmeExtension>()
|
||||
// }
|
||||
|
||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||
|
||||
val modulesString = buildString {
|
||||
subprojects.forEach { subproject ->
|
||||
// val name = subproject.name
|
||||
subproject.extensions.findByType<KScienceReadmeExtension>()?.let { ext ->
|
||||
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
|
||||
appendLine("\n### [$path]($path)")
|
||||
appendLine("> ${ext.description}")
|
||||
appendLine(">\n> **Maturity**: ${ext.maturity}")
|
||||
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
|
||||
if (featureString.isNotBlank()) {
|
||||
appendLine(">\n> **Features:**")
|
||||
appendLine(featureString)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootReadmeExtension.property("modules", modulesString)
|
||||
|
||||
rootReadmeExtension.readmeString()?.let {
|
||||
readmeFile.writeText(it)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<AbstractDokkaTask> {
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
|
||||
tasks.create("version") {
|
||||
group = "publishing"
|
||||
val versionFile = project.buildDir.resolve("project-version.txt")
|
||||
outputs.file(versionFile)
|
||||
doLast {
|
||||
versionFile.createNewFile()
|
||||
versionFile.writeText(project.version.toString())
|
||||
println(project.version)
|
||||
}
|
||||
}
|
||||
|
||||
// Disable API validation for snapshots
|
||||
if (isInDevelopment) {
|
||||
extensions.findByType<ApiValidationExtension>()?.apply {
|
||||
validationDisabled = true
|
||||
logger.warn("API validation is disabled for snapshot or dev version")
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) {
|
||||
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().lockFileDirectory =
|
||||
rootDir.resolve("gradle")
|
||||
}
|
||||
}
|
||||
|
||||
public companion object {
|
||||
public const val DEPLOY_GROUP: String = "deploy"
|
||||
}
|
||||
}
|
180
src/main/kotlin/space/kscience/gradle/KScienceReadmeExtension.kt
Normal file
180
src/main/kotlin/space/kscience/gradle/KScienceReadmeExtension.kt
Normal file
@ -0,0 +1,180 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
import freemarker.cache.StringTemplateLoader
|
||||
import freemarker.template.Configuration
|
||||
import freemarker.template.Template
|
||||
import freemarker.template.TemplateNotFoundException
|
||||
import kotlinx.html.TagConsumer
|
||||
import kotlinx.html.div
|
||||
import kotlinx.html.stream.createHTML
|
||||
import kotlinx.validation.ApiValidationExtension
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import java.io.File
|
||||
import java.io.StringWriter
|
||||
import kotlin.collections.component1
|
||||
import kotlin.collections.component2
|
||||
import kotlin.collections.set
|
||||
|
||||
public enum class Maturity {
|
||||
PROTOTYPE,
|
||||
EXPERIMENTAL,
|
||||
DEVELOPMENT,
|
||||
STABLE,
|
||||
DEPRECATED
|
||||
}
|
||||
|
||||
private fun Template.processToString(args: Map<String, Any?>): String {
|
||||
val writer = StringWriter()
|
||||
process(args, writer)
|
||||
return writer.toString()
|
||||
}
|
||||
|
||||
|
||||
public class KScienceReadmeExtension(public val project: Project) {
|
||||
public var description: String = project.description ?: ""
|
||||
|
||||
public var maturity: Maturity = Maturity.EXPERIMENTAL
|
||||
set(value) {
|
||||
field = value
|
||||
val projectName = project.name
|
||||
if (value == Maturity.EXPERIMENTAL || value == Maturity.PROTOTYPE) {
|
||||
project.rootProject.run {
|
||||
plugins.withId("org.jetbrains.kotlinx.binary-compatibility-validator") {
|
||||
extensions.findByType<ApiValidationExtension>()?.apply {
|
||||
project.logger.warn("$value project $projectName is excluded from API validation")
|
||||
ignoredProjects.add(projectName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, use default templates provided by plugin if override is not defined
|
||||
*/
|
||||
public var useDefaultReadmeTemplate: Boolean = true
|
||||
|
||||
/**
|
||||
* Use this template file if it is provided, otherwise use default template
|
||||
*/
|
||||
public var readmeTemplate: File = project.file("docs/README-TEMPLATE.md")
|
||||
set(value) {
|
||||
field = value
|
||||
if (value.exists()) {
|
||||
fmLoader.putTemplate("readme", value.readText())
|
||||
}
|
||||
}
|
||||
|
||||
private val fmLoader = StringTemplateLoader().apply {
|
||||
putTemplate(
|
||||
"artifact",
|
||||
this@KScienceReadmeExtension.javaClass.getResource("/templates/ARTIFACT-TEMPLATE.md")!!.readText()
|
||||
)
|
||||
if (readmeTemplate.exists()) {
|
||||
putTemplate("readme", readmeTemplate.readText())
|
||||
} else if (useDefaultReadmeTemplate) {
|
||||
putTemplate(
|
||||
"readme",
|
||||
this@KScienceReadmeExtension.javaClass.getResource("/templates/README-TEMPLATE.md")!!.readText()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val fmCfg = Configuration(Configuration.VERSION_2_3_31).apply {
|
||||
defaultEncoding = "UTF-8"
|
||||
templateLoader = fmLoader
|
||||
}
|
||||
|
||||
public data class Feature(val id: String, val description: String, val ref: String?, val name: String = id)
|
||||
|
||||
public val features: MutableList<Feature> = ArrayList()
|
||||
|
||||
public fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
|
||||
features += Feature(id, description(), ref, name)
|
||||
}
|
||||
|
||||
public fun featureWithHtml(
|
||||
id: String,
|
||||
ref: String? = null,
|
||||
name: String = id,
|
||||
htmlBuilder: TagConsumer<String>.() -> Unit,
|
||||
) {
|
||||
val text = createHTML().apply {
|
||||
div("readme-feature") {
|
||||
htmlBuilder()
|
||||
}
|
||||
}.finalize()
|
||||
features += Feature(id, text, ref, name)
|
||||
}
|
||||
|
||||
private val properties: MutableMap<String, () -> Any?> = mutableMapOf(
|
||||
"name" to { project.name },
|
||||
"group" to { project.group },
|
||||
"version" to { project.version },
|
||||
"description" to { project.description ?: "" },
|
||||
"features" to { featuresString() },
|
||||
"published" to { project.plugins.findPlugin("maven-publish") != null },
|
||||
"artifact" to {
|
||||
val projectProperties = mapOf(
|
||||
"name" to project.name,
|
||||
"group" to project.group,
|
||||
"version" to project.version
|
||||
)
|
||||
fmCfg.getTemplate("artifact").processToString(projectProperties)
|
||||
}
|
||||
)
|
||||
|
||||
public fun getPropertyValues(): Map<String, Any?> = properties.mapValues { (_, value) -> value() }
|
||||
|
||||
public fun property(key: String, value: Any?) {
|
||||
properties[key] = { value }
|
||||
}
|
||||
|
||||
public fun property(key: String, value: () -> Any?) {
|
||||
properties[key] = value
|
||||
}
|
||||
|
||||
public fun propertyByTemplate(key: String, templateString: String) {
|
||||
//need to freeze it, otherwise values could change
|
||||
val actual = getPropertyValues()
|
||||
fmLoader.putTemplate(key, templateString)
|
||||
val template = fmCfg.getTemplate(key)
|
||||
|
||||
properties[key] = { template.processToString(actual) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Files that are use in readme generation
|
||||
*/
|
||||
internal val inputFiles = ArrayList<File>()
|
||||
|
||||
public fun propertyByTemplate(key: String, templateFile: File) {
|
||||
//need to freeze it, otherwise values could change
|
||||
val actual = getPropertyValues()
|
||||
fmLoader.putTemplate(key, templateFile.readText())
|
||||
val template: Template = fmCfg.getTemplate(key)
|
||||
|
||||
properties[key] = { template.processToString(actual) }
|
||||
inputFiles += templateFile
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a markdown string listing features
|
||||
*/
|
||||
internal fun featuresString(itemPrefix: String = " - ", pathPrefix: String = ""): String = buildString {
|
||||
features.forEach {
|
||||
appendLine("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description}")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a readme string from the template
|
||||
*/
|
||||
public fun readmeString(): String? = try {
|
||||
fmCfg.getTemplate("readme").processToString(getPropertyValues())
|
||||
} catch (ex: TemplateNotFoundException) {
|
||||
project.logger.warn("Template with name ${ex.templateName} not found in ${project.name}")
|
||||
null
|
||||
}
|
||||
}
|
30
src/main/kotlin/space/kscience/gradle/KScienceVersions.kt
Normal file
30
src/main/kotlin/space/kscience/gradle/KScienceVersions.kt
Normal file
@ -0,0 +1,30 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
|
||||
import org.tomlj.Toml
|
||||
|
||||
/**
|
||||
* Build constants
|
||||
*/
|
||||
public object KScienceVersions {
|
||||
|
||||
private val toml by lazy {
|
||||
Toml.parse(javaClass.getResource("/libs.versions.toml")!!.readText())
|
||||
}
|
||||
|
||||
public val kotlinVersion: String get() = toml.getString("versions.kotlin")!!
|
||||
public val kotlinxNodeVersion: String get() = toml.getString("versions.kotlinx-nodejs")!!
|
||||
public val coroutinesVersion: String get() = toml.getString("versions.kotlinx-coroutines")!!
|
||||
public val serializationVersion: String get() = toml.getString("versions.kotlinx-serialization")!!
|
||||
public val atomicVersion: String get() = toml.getString("versions.atomicfu")!!
|
||||
public val ktorVersion: String get() = toml.getString("versions.ktor")!!
|
||||
public val htmlVersion: String get() = toml.getString("versions.kotlinx-html")!!
|
||||
public val dateTimeVersion: String get() = toml.getString("versions.kotlinx-datetime")!!
|
||||
public val jsBom: String get() = toml.getString("versions.jsBom")!!
|
||||
internal val junit: String get() = toml.getString("versions.junit")!!
|
||||
|
||||
public object Serialization {
|
||||
public val xmlVersion: String get() = toml.getString("versions.xmlutil")!!
|
||||
public val yamlKtVersion: String get() = toml.getString("versions.yamlkt")!!
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import space.kscience.gradle.internal.useCommonDependency
|
||||
|
||||
public class SerializationTargets(
|
||||
public val sourceSet: DependencySourceSet,
|
||||
public val configuration: DependencyConfiguration,
|
||||
) {
|
||||
public fun Project.json(
|
||||
version: String = KScienceVersions.serializationVersion,
|
||||
): Unit = useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-json:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration,
|
||||
)
|
||||
|
||||
public fun Project.cbor(
|
||||
version: String = KScienceVersions.serializationVersion,
|
||||
): Unit = useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-cbor:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration,
|
||||
)
|
||||
|
||||
public fun Project.protobuf(
|
||||
version: String = KScienceVersions.serializationVersion,
|
||||
): Unit = useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration,
|
||||
)
|
||||
|
||||
public fun Project.xml(
|
||||
version: String = KScienceVersions.Serialization.xmlVersion,
|
||||
): Unit = useCommonDependency(
|
||||
"io.github.pdvrieze.xmlutil:serialization:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration,
|
||||
)
|
||||
|
||||
public fun Project.yamlKt(
|
||||
version: String = KScienceVersions.Serialization.yamlKtVersion,
|
||||
): Unit = useCommonDependency(
|
||||
"net.mamoe.yamlkt:yamlkt:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration,
|
||||
)
|
||||
}
|
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.kotlin.dsl.configure
|
||||
@ -6,8 +6,8 @@ import org.gradle.kotlin.dsl.invoke
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import ru.mipt.npm.gradle.DependencyConfiguration
|
||||
import ru.mipt.npm.gradle.DependencySourceSet
|
||||
import space.kscience.gradle.DependencyConfiguration
|
||||
import space.kscience.gradle.DependencySourceSet
|
||||
|
||||
internal fun Project.useDependency(
|
||||
vararg pairs: Pair<String, String>,
|
||||
@ -87,7 +87,6 @@ internal fun Project.useCommonDependency(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
configure<KotlinJvmProjectExtension> {
|
||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||
@ -102,6 +101,7 @@ internal fun Project.useCommonDependency(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
withPlugin("org.jetbrains.kotlin.js") {
|
||||
configure<KotlinJsProjectExtension> {
|
||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
218
src/main/kotlin/space/kscience/gradle/internal/publishing.kt
Normal file
218
src/main/kotlin/space/kscience/gradle/internal/publishing.kt
Normal file
@ -0,0 +1,218 @@
|
||||
package space.kscience.gradle.internal
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPom
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.plugins.signing.SigningExtension
|
||||
import org.gradle.plugins.signing.SigningPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets
|
||||
import space.kscience.gradle.isInDevelopment
|
||||
|
||||
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
||||
?: System.getenv(propertyName)
|
||||
|
||||
internal fun Project.requestProperty(propertyName: String): String = requestPropertyOrNull(propertyName)
|
||||
?: error("Property $propertyName not defined")
|
||||
|
||||
|
||||
internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit = {}) = allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
|
||||
plugins.withId("org.jetbrains.kotlin.js") {
|
||||
val kotlin: KotlinJsProjectExtension = extensions.findByType()!!
|
||||
|
||||
val sourcesJar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
kotlin.sourceSets.forEach {
|
||||
from(it.kotlin)
|
||||
}
|
||||
}
|
||||
|
||||
publications.create<MavenPublication>("js") {
|
||||
kotlin.targets.flatMap { it.components }.forEach {
|
||||
from(it)
|
||||
}
|
||||
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
plugins.withId("org.jetbrains.kotlin.jvm") {
|
||||
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
|
||||
|
||||
val sourcesJar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
kotlin.sourceSets.forEach {
|
||||
from(it.kotlin)
|
||||
}
|
||||
}
|
||||
|
||||
publications.create<MavenPublication>("jvm") {
|
||||
kotlin.target.components.forEach {
|
||||
from(it)
|
||||
}
|
||||
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications.withType<MavenPublication> {
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description ?: project.name)
|
||||
|
||||
scm {
|
||||
tag.set(project.version.toString())
|
||||
}
|
||||
|
||||
mavenPomConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId("org.jetbrains.dokka") {
|
||||
val dokkaJar by tasks.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.addGithubPublishing(
|
||||
githubOrg: String,
|
||||
githubProject: String,
|
||||
) {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping github publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
if (requestPropertyOrNull("publishing.github") != "false") {
|
||||
logger.info("Skipping github publishing because `publishing.github != true`")
|
||||
return
|
||||
}
|
||||
|
||||
val githubUser: String = requestProperty("publishing.github.user")
|
||||
val githubToken: String = requestProperty("publishing.github.token")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
logger.info("Adding github publishing to project [${project.name}]")
|
||||
|
||||
repositories.maven {
|
||||
name = "github"
|
||||
url = uri("https://maven.pkg.github.com/$githubOrg/$githubProject/")
|
||||
|
||||
credentials {
|
||||
username = githubUser
|
||||
password = githubToken
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.addSpacePublishing(spaceRepo: String) {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping space publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
if (requestPropertyOrNull("publishing.space") == "false") {
|
||||
logger.info("Skipping space publishing because `publishing.space == false`")
|
||||
return
|
||||
}
|
||||
|
||||
val spaceUser: String = requestProperty("publishing.space.user")
|
||||
val spaceToken: String = requestProperty("publishing.space.token")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||
|
||||
repositories.maven {
|
||||
name = "space"
|
||||
url = uri(spaceRepo)
|
||||
|
||||
credentials {
|
||||
username = spaceUser
|
||||
password = spaceToken
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.addSonatypePublishing() {
|
||||
if (requestPropertyOrNull("publishing.enabled") != "true") {
|
||||
logger.info("Skipping sonatype publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
if (isInDevelopment) {
|
||||
logger.info("Sonatype publishing skipped for development version")
|
||||
return
|
||||
}
|
||||
|
||||
if (requestPropertyOrNull("publishing.sonatype") == "false") {
|
||||
logger.info("Skipping sonatype publishing because `publishing.sonatype == false`")
|
||||
return
|
||||
}
|
||||
|
||||
val sonatypeUser: String = requestProperty("publishing.sonatype.user")
|
||||
val sonatypePassword: String = requestProperty("publishing.sonatype.password")
|
||||
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
repositories.maven {
|
||||
val sonatypeRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
name = "sonatype"
|
||||
url = uri(sonatypeRepo)
|
||||
|
||||
credentials {
|
||||
username = sonatypeUser
|
||||
password = sonatypePassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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/")
|
||||
}
|
||||
}
|
||||
}
|
26
src/main/resources/templates/ARTIFACT-TEMPLATE.md
Normal file
26
src/main/resources/templates/ARTIFACT-TEMPLATE.md
Normal file
@ -0,0 +1,26 @@
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `${group}:${name}:${version}`.
|
||||
|
||||
**Gradle Groovy:**
|
||||
```groovy
|
||||
repositories {
|
||||
maven { url 'https://repo.kotlin.link' }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation '${group}:${name}:${version}'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
repositories {
|
||||
maven("https://repo.kotlin.link")
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("${group}:${name}:${version}")
|
||||
}
|
||||
```
|
15
src/main/resources/templates/README-TEMPLATE.md
Normal file
15
src/main/resources/templates/README-TEMPLATE.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Module ${name}
|
||||
|
||||
${description}
|
||||
|
||||
<#if features?has_content>
|
||||
## Features
|
||||
|
||||
${features}
|
||||
|
||||
</#if>
|
||||
<#if published>
|
||||
## Usage
|
||||
|
||||
${artifact}
|
||||
</#if>
|
9
src/test/kotlin/TestVersions.kt
Normal file
9
src/test/kotlin/TestVersions.kt
Normal file
@ -0,0 +1,9 @@
|
||||
import org.junit.jupiter.api.Test
|
||||
import space.kscience.gradle.KScienceVersions
|
||||
|
||||
class TestPlugins {
|
||||
@Test
|
||||
fun testVersions() {
|
||||
println(KScienceVersions.coroutinesVersion)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user