Compare commits
No commits in common. "master" and "v0.11.3-kotlin-1.6.20" have entirely different histories.
master
...
v0.11.3-ko
6
.github/workflows/publish.yml
vendored
6
.github/workflows/publish.yml
vendored
@ -19,6 +19,6 @@ jobs:
|
||||
- uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: |
|
||||
publishAllPublicationsToSpaceRepository
|
||||
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }}
|
||||
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }}
|
||||
publishAllPublicationsToSpaceRepository
|
||||
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }}
|
||||
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }}
|
43
.space.kts
43
.space.kts
@ -1,43 +0,0 @@
|
||||
import kotlin.io.path.readText
|
||||
|
||||
job("Build") {
|
||||
gradlew("openjdk:11", "build")
|
||||
}
|
||||
|
||||
job("Publish"){
|
||||
startOn {
|
||||
gitPush { enabled = false }
|
||||
}
|
||||
container("openjdk:11") {
|
||||
env["SPACE_USER"] = Secrets("space_user")
|
||||
env["SPACE_TOKEN"] = Secrets("space_token")
|
||||
kotlinScript { api ->
|
||||
|
||||
val spaceUser = System.getenv("SPACE_USER")
|
||||
val spaceToken = System.getenv("SPACE_TOKEN")
|
||||
|
||||
// write version to the build directory
|
||||
api.gradlew("version")
|
||||
|
||||
//read version from build file
|
||||
val version = java.nio.file.Path.of("build/project-version.txt").readText()
|
||||
|
||||
api.space().projects.automation.deployments.start(
|
||||
project = api.projectIdentifier(),
|
||||
targetIdentifier = TargetIdentifier.Key("gradle-tools"),
|
||||
version = version,
|
||||
// automatically update deployment status based on a status of a job
|
||||
syncWithAutomationJob = true
|
||||
)
|
||||
try {
|
||||
api.gradlew(
|
||||
"publishAllPublicationsToSpaceRepository",
|
||||
"-Ppublishing.space.user=\"$spaceUser\"",
|
||||
"-Ppublishing.space.token=\"$spaceToken\"",
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
println("Publish failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
124
CHANGELOG.md
124
CHANGELOG.md
@ -1,14 +1,20 @@
|
||||
# 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
|
||||
- Coroutine tests as default dependency for tests
|
||||
- Context receiver flag
|
||||
|
||||
### Changed
|
||||
- Separate release tasks for each target
|
||||
- Kotlin 1.6.20
|
||||
- Context receivers enabled
|
||||
- Ktor 2.0
|
||||
|
||||
### Deprecated
|
||||
|
||||
@ -18,116 +24,52 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Security
|
||||
|
||||
## 0.14.4-kotlin-1.8.20-RC - 2023-03-12
|
||||
|
||||
### Added
|
||||
- Easier dependency handling in `kscience` block
|
||||
- Customizable base jdk version
|
||||
|
||||
### Changed
|
||||
- MPP does not use JVM and JS(IR) targets anymore. They could be turned manually via `js()`, `jvm()` or `fullStack()`
|
||||
- Signing is not applied if signingId is not provided
|
||||
|
||||
### Removed
|
||||
- FX plugins
|
||||
- Unnecessary library shortcuts (html and datetime)
|
||||
- deploy/release tasks
|
||||
|
||||
### Fixed
|
||||
- Gradle 8 compatibility
|
||||
- Dokka publication
|
||||
- issues with test sourcesets
|
||||
|
||||
## 0.13.4-kotlin-1.8.0 - 2022-12-31
|
||||
|
||||
### Added
|
||||
- Public `isInDevelopment` project flag
|
||||
|
||||
### Changed
|
||||
- Require manual pom config for publications
|
||||
- Kotlin 1.8.0
|
||||
- Versions update
|
||||
- Project group changed to `space.kscience`
|
||||
- Moved `yarn.lock` to `gradle` directory
|
||||
|
||||
### Deprecated
|
||||
- FX configuration
|
||||
|
||||
### Removed
|
||||
- Xjdk-release flag because it is broken until https://youtrack.jetbrains.com/issue/KT-52823
|
||||
- Use CSS loader in JS by default
|
||||
|
||||
## 0.11.6-kotlin-1.7.0
|
||||
|
||||
### Changed
|
||||
- Coroutines tests are applied only when explicit `useCoroutines` is used.
|
||||
|
||||
### Removed
|
||||
- Atomicfu support inside the plugin
|
||||
|
||||
### Fixed
|
||||
- Rollback coroutines to 1.6.1
|
||||
|
||||
## 0.11.5-kotlin-1.7.0
|
||||
|
||||
### Added
|
||||
- Coroutine tests as default dependency for tests
|
||||
- Context receiver flag
|
||||
|
||||
### Changed
|
||||
- Separate release tasks for each target
|
||||
- Kotlin 1.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
|
||||
|
||||
## [0.11.1-kotlin-1.6.10]
|
||||
### Added
|
||||
- Default templates for README and ARTIFACT
|
||||
|
||||
### Changed
|
||||
- Replaced Groovy templates by FreeMarker
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
- JS publication sources jar
|
||||
|
||||
## 0.10.9-kotlin-1.6.10
|
||||
### Security
|
||||
|
||||
## [0.10.9-kotlin-1.6.10]
|
||||
### Added
|
||||
- html builders for readme
|
||||
|
||||
### Changed
|
||||
- Kotlin 1.6.0
|
||||
- Use indy lambdas by default #32
|
||||
- Use indy lambdas by default #32
|
||||
- Change version scheme to `<version>-kotlin-<kotlin version>`
|
||||
|
||||
### Fixed
|
||||
- remove `nativeMain` dependency from `nativeTest`
|
||||
|
||||
## 0.10.4
|
||||
|
||||
## [0.10.4]
|
||||
### Changed
|
||||
- Kotlin 1.6
|
||||
|
||||
### Fixed
|
||||
- Some issues with opt-ins
|
||||
|
||||
## 0.10.2
|
||||
|
||||
## [0.10.2]
|
||||
### Added
|
||||
- Experimental automatic JS project bundling in MPP
|
||||
|
||||
### Changed
|
||||
- Remove vcs requirement for Space publication
|
||||
|
||||
## 0.10.0
|
||||
### Fixed
|
||||
-Release task (#19)
|
||||
|
||||
## [0.10.0]
|
||||
### Added
|
||||
- Lazy readme properties
|
||||
- BOM for kotlin-wrappers on JS
|
||||
@ -140,8 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Removed
|
||||
- bson support
|
||||
|
||||
## 0.9.5
|
||||
|
||||
## [0.9.5]
|
||||
### Added
|
||||
- Disable API validation for snapshots
|
||||
- `-Xjvm-default=all` on JVM
|
||||
@ -158,8 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Fixed
|
||||
- Removed unnecessary `afterEvaluate` for compatibility with gradle 7.0
|
||||
|
||||
## 0.9.0
|
||||
|
||||
## [0.9.0]
|
||||
### Added
|
||||
- Skip sonatype publishing for dev versions
|
||||
|
||||
@ -173,8 +113,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Removed
|
||||
- Bintray publishing
|
||||
|
||||
## 0.8.4
|
||||
|
||||
## [0.8.4]
|
||||
### Added
|
||||
- Adaptive support for host OS in native
|
||||
- CSS support for JS targets
|
||||
@ -188,8 +127,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Release task
|
||||
- Readme generation for multi-module project
|
||||
|
||||
## 0.8.1
|
||||
|
||||
## [0.8.1]
|
||||
### Added
|
||||
- Ktor version to versions
|
||||
- Add sonatype publishing
|
||||
@ -209,8 +147,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
|
||||
|
||||
## 0.7.4
|
||||
|
||||
## [0.7.4]
|
||||
### Added
|
||||
- Changelog plugin automatically applied to `project`.
|
||||
- Feature matrix and Readme generation task for a `project` plugin.
|
||||
@ -236,15 +173,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Removed
|
||||
- `useDokka` method. Documentation jar should be added manually if needed.
|
||||
|
||||
## 0.6.0
|
||||
|
||||
## [0.6.0]
|
||||
### Added
|
||||
- Migrate to kotlin 1.4.0
|
||||
- Separate Native (current platform) and nodeJs plugins.
|
||||
- Add `application()` toggle in plugin configuration to produce binaries on JS and applicaion plugin on jvm.
|
||||
- Add `publish` to expose publishing configuration.
|
||||
|
||||
## 0.5.2
|
||||
### Changed
|
||||
-Publishing in bintray now is automatic.
|
||||
|
||||
## [0.5.2]
|
||||
### Added
|
||||
- Copy resources for jvm modules and jvm source sets in mpp.
|
||||
- Copy resources for jvm modules and jvm source sets in mpp.
|
26
README.md
26
README.md
@ -1,28 +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)
|
||||
[![Maven Central](https://img.shields.io/maven-central/v/ru.mipt.npm.gradle.project/ru.mipt.npm.gradle.project.gradle.plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22ru.mipt.npm.gradle.project%22%20AND%20a:%22ru.mipt.npm.gradle.project.gradle.plugin%22)
|
||||
|
||||
# KScience build tools
|
||||
|
||||
A collection of gradle plugins for building and publish in *kscience* and *dataforge* projects.
|
||||
|
||||
## space.kscience.gradle.common
|
||||
## ru.mipt.npm.gradle.common
|
||||
A primary plugin. When used with kotlin-jvm, kotlin-js or kotlin-mulitplatform configures the project for appropriate target.
|
||||
|
||||
## space.kscience.gradle.project
|
||||
## ru.mipt.npm.gradle.project
|
||||
Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool.
|
||||
|
||||
## space.kscience.gradle.mpp
|
||||
`= kotlin("multiplatform") + space.kscience.gradle.common`
|
||||
## ru.mipt.npm.gradle.mpp
|
||||
`= kotlin("multiplatform") + ru.mipt.npm.gradle.common`
|
||||
|
||||
Includes JVM-IR and JS-IR-Browser targets.
|
||||
|
||||
## space.kscience.gradle.jvm
|
||||
`= kotlin("jvm") + space.kscience.gradle.common`
|
||||
## ru.mipt.npm.gradle.jvm
|
||||
`= kotlin("jvm") + ru.mipt.npm.gradle.common`
|
||||
|
||||
## space.kscience.gradle.js
|
||||
`= kotlin("js") + space.kscience.gradle.common`
|
||||
## ru.mipt.npm.gradle.js
|
||||
`= kotlin("js") + ru.mipt.npm.gradle.common`
|
||||
|
||||
## space.kscience.gradle.native
|
||||
add default native targets to `space.kscience.gradle.mpp`
|
||||
## ru.mipt.npm.gradle.native
|
||||
add default native targets to `ru.mipt.npm.gradle.mpp`
|
||||
|
||||
## space.kscience.gradle.node
|
||||
add node target to `space.kscience.gradle.mpp`
|
||||
## ru.mipt.npm.gradle.node
|
||||
add node target to `ru.mipt.npm.gradle.mpp`
|
||||
|
235
build.gradle.kts
235
build.gradle.kts
@ -1,17 +1,17 @@
|
||||
plugins {
|
||||
alias(libs.plugins.changelog)
|
||||
alias(libs.plugins.dokka)
|
||||
`java-gradle-plugin`
|
||||
`kotlin-dsl`
|
||||
`maven-publish`
|
||||
signing
|
||||
`version-catalog`
|
||||
alias(libs.plugins.changelog)
|
||||
alias(libs.plugins.dokka)
|
||||
}
|
||||
|
||||
group = "space.kscience"
|
||||
group = "ru.mipt.npm"
|
||||
version = libs.versions.tools.get()
|
||||
|
||||
description = "Build tools for kotlin for science projects"
|
||||
description = "Build tools for DataForge and kscience projects"
|
||||
|
||||
changelog.version.set(project.version.toString())
|
||||
|
||||
@ -21,17 +21,20 @@ repositories {
|
||||
maven("https://repo.kotlin.link")
|
||||
}
|
||||
|
||||
java.targetCompatibility = JavaVersion.VERSION_11
|
||||
|
||||
kotlin.explicitApiWarning()
|
||||
|
||||
dependencies {
|
||||
api(libs.kotlin.gradle)
|
||||
implementation(libs.atomicfu.gradle)
|
||||
implementation(libs.binary.compatibility.validator)
|
||||
implementation(libs.changelog.gradle)
|
||||
implementation(libs.dokka.gradle)
|
||||
implementation(libs.kotlin.jupyter.gradle)
|
||||
implementation(libs.kotlin.serialization)
|
||||
implementation(libs.kotlinx.html)
|
||||
implementation("org.tomlj:tomlj:1.1.0")
|
||||
implementation("org.tomlj:tomlj:1.0.0")
|
||||
// // nexus publishing plugin
|
||||
// implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
|
||||
|
||||
@ -48,45 +51,53 @@ tasks.test {
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("common") {
|
||||
id = "ru.mipt.npm.gradle.common"
|
||||
description = "The generalized kscience plugin that works in conjunction with any kotlin plugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin"
|
||||
}
|
||||
|
||||
create("project") {
|
||||
id = "space.kscience.gradle.project"
|
||||
id = "ru.mipt.npm.gradle.project"
|
||||
description = "The root plugin for multi-module project infrastructure"
|
||||
implementationClass = "space.kscience.gradle.KScienceProjectPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
|
||||
}
|
||||
|
||||
create("mpp") {
|
||||
id = "space.kscience.gradle.mpp"
|
||||
id = "ru.mipt.npm.gradle.mpp"
|
||||
description = "Pre-configured multiplatform project"
|
||||
implementationClass = "space.kscience.gradle.KScienceMPPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
|
||||
}
|
||||
|
||||
create("jvm") {
|
||||
id = "space.kscience.gradle.jvm"
|
||||
id = "ru.mipt.npm.gradle.jvm"
|
||||
description = "Pre-configured JVM project"
|
||||
implementationClass = "space.kscience.gradle.KScienceJVMPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
|
||||
}
|
||||
|
||||
create("js") {
|
||||
id = "space.kscience.gradle.js"
|
||||
id = "ru.mipt.npm.gradle.js"
|
||||
description = "Pre-configured JS project"
|
||||
implementationClass = "space.kscience.gradle.KScienceJSPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//publishing version catalog
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
catalog.versionCatalog {
|
||||
from(files("gradle/libs.versions.toml"))
|
||||
}
|
||||
@ -104,126 +115,110 @@ val javadocsJar by tasks.creating(Jar::class) {
|
||||
from(tasks.dokkaHtml)
|
||||
}
|
||||
|
||||
val emptyJavadocJar by tasks.creating(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
archiveBaseName.set("empty")
|
||||
archiveClassifier.set("javadoc")
|
||||
}
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
val vcs = "https://github.com/mipt-npm/gradle-tools"
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications {
|
||||
create<MavenPublication>("catalog") {
|
||||
from(components["versionCatalog"])
|
||||
artifactId = "version-catalog"
|
||||
|
||||
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 {
|
||||
create<MavenPublication>("catalog") {
|
||||
from(components["versionCatalog"])
|
||||
artifactId = "version-catalog"
|
||||
|
||||
pom {
|
||||
name.set("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)
|
||||
withType<MavenPublication> {
|
||||
artifact(sourcesJar)
|
||||
artifact(javadocsJar)
|
||||
|
||||
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set(vcs)
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
distribution.set("repo")
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id.set("MIPT-NPM")
|
||||
name.set("MIPT nuclear physics methods laboratory")
|
||||
organization.set("MIPT")
|
||||
organizationUrl.set("https://npm.mipt.ru")
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set(vcs)
|
||||
tag.set(project.version.toString())
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
distribution.set("repo")
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id.set("MIPT-NPM")
|
||||
name.set("MIPT nuclear physics methods laboratory")
|
||||
organization.set("MIPT")
|
||||
organizationUrl.set("https://npm.mipt.ru")
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
url.set(vcs)
|
||||
tag.set(project.version.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val spaceRepo = "https://maven.pkg.jetbrains.space/spc/p/sci/maven"
|
||||
val spaceUser: String? = findProperty("publishing.space.user") as? String
|
||||
val spaceToken: String? = findProperty("publishing.space.token") as? String
|
||||
val spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
|
||||
val spaceUser: String? = project.findProperty("publishing.space.user") as? String
|
||||
val spaceToken: String? = project.findProperty("publishing.space.token") as? String
|
||||
|
||||
if (spaceUser != null && spaceToken != null) {
|
||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||
if (spaceUser != null && spaceToken != null) {
|
||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||
|
||||
repositories.maven {
|
||||
name = "space"
|
||||
url = uri(spaceRepo)
|
||||
repositories.maven {
|
||||
name = "space"
|
||||
url = uri(spaceRepo)
|
||||
|
||||
credentials {
|
||||
username = spaceUser
|
||||
password = spaceToken
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String
|
||||
val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String
|
||||
|
||||
if (sonatypeUser != null && sonatypePassword != null) {
|
||||
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
|
||||
"https://oss.sonatype.org/content/repositories/snapshots"
|
||||
} else {
|
||||
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
}
|
||||
|
||||
repositories.maven {
|
||||
name = "sonatype"
|
||||
url = uri(sonatypeRepo)
|
||||
|
||||
credentials {
|
||||
username = sonatypeUser
|
||||
password = sonatypePassword
|
||||
credentials {
|
||||
username = spaceUser
|
||||
password = spaceToken
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
//useGpgCmd()
|
||||
sign(publications)
|
||||
val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String
|
||||
val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String
|
||||
|
||||
if (sonatypeUser != null && sonatypePassword != null) {
|
||||
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
|
||||
"https://oss.sonatype.org/content/repositories/snapshots"
|
||||
} else {
|
||||
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
}
|
||||
|
||||
repositories.maven {
|
||||
name = "sonatype"
|
||||
url = uri(sonatypeRepo)
|
||||
|
||||
credentials {
|
||||
username = sonatypeUser
|
||||
password = sonatypePassword
|
||||
}
|
||||
}
|
||||
|
||||
if (plugins.findPlugin("signing") == null) {
|
||||
apply<SigningPlugin>()
|
||||
}
|
||||
|
||||
signing {
|
||||
//useGpgCmd()
|
||||
sign(publications)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
kotlin {
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(11))
|
||||
}
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "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,26 +1,25 @@
|
||||
[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"
|
||||
tools = "0.11.3-kotlin-1.6.20"
|
||||
kotlin = "1.6.20"
|
||||
atomicfu = "0.17.1"
|
||||
binary-compatibility-validator = "0.8.0"
|
||||
changelog = "1.3.1"
|
||||
dokka = "1.6.10"
|
||||
kotlin-jupyter = "0.11.0-71"
|
||||
kotlinx-benchmark = "0.4.2"
|
||||
kotlinx-cli = "0.3.4"
|
||||
kotlinx-collections-immutable = "0.3.5"
|
||||
kotlinx-coroutines = "1.6.1"
|
||||
kotlinx-datetime = "0.3.2"
|
||||
kotlinx-html = "0.7.3"
|
||||
kotlinx-knit = "0.3.0"
|
||||
kotlinx-nodejs = "0.0.7"
|
||||
kotlinx-serialization = "1.4.1"
|
||||
ktor = "2.2.3"
|
||||
xmlutil = "0.84.3"
|
||||
yamlkt = "0.12.0"
|
||||
jsBom = "1.0.0-pre.509"
|
||||
junit = "5.9.2"
|
||||
compose = "1.3.0"
|
||||
logback = "1.4.5"
|
||||
kotlinx-serialization = "1.3.2"
|
||||
ktor = "2.0.0"
|
||||
xmlutil = "0.84.1"
|
||||
yamlkt = "0.10.2"
|
||||
jsBom = "0.0.1-pre.313-kotlin-1.6.10"
|
||||
junit = "5.8.2"
|
||||
|
||||
[libraries]
|
||||
atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" }
|
||||
@ -39,6 +38,8 @@ kotlin-jupyter-gradle = { module = "org.jetbrains.kotlin:kotlin-jupyter-api-grad
|
||||
|
||||
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
|
||||
|
||||
kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinx-collections-immutable" }
|
||||
|
||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-coroutines-debug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "kotlinx-coroutines" }
|
||||
@ -72,6 +73,60 @@ kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-seria
|
||||
kotlinx-serialization-properties = { module = "org.jetbrains.kotlinx:kotlinx-serialization-properties", version.ref = "kotlinx-serialization" }
|
||||
|
||||
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
|
||||
ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktor" }
|
||||
ktor-client-apache = { module = "io.ktor:ktor-client-apache", version.ref = "ktor" }
|
||||
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
|
||||
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
||||
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
|
||||
ktor-client-auth-basic = { module = "io.ktor:ktor-client-auth-basic", version.ref = "ktor" }
|
||||
ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" }
|
||||
ktor-client-encoding = { module = "io.ktor:ktor-client-encoding", version.ref = "ktor" }
|
||||
ktor-client-json = { module = "io.ktor:ktor-client-json", version.ref = "ktor" }
|
||||
ktor-client-gson = { module = "io.ktor:ktor-client-gson", version.ref = "ktor" }
|
||||
ktor-client-jackson = { module = "io.ktor:ktor-client-jackson", version.ref = "ktor" }
|
||||
ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
|
||||
ktor-client-logging = { module = "io.ktor:ktor-client-loggin", version.ref = "ktor" }
|
||||
ktor-client-tracing = { module = "io.ktor:ktor-client-tracing", version.ref = "ktor" }
|
||||
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
|
||||
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
|
||||
ktor-client-jetty = { module = "io.ktor:ktor-client-jetty", version.ref = "ktor" }
|
||||
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
|
||||
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
|
||||
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
|
||||
ktor-auth-jwt = { module = "io.ktor:ktor-auth-jwt", version.ref = "ktor" }
|
||||
ktor-auth-ldap = { module = "io.ktor:ktor-auth-ldap", version.ref = "ktor" }
|
||||
ktor-auth = { module = "io.ktor:ktor-auth", version.ref = "ktor" }
|
||||
ktor-freemaker = { module = "io.ktor:ktor-freemaker", version.ref = "ktor" }
|
||||
ktor-gson = { module = "io.ktor:ktor-gson", version.ref = "ktor" }
|
||||
ktor-html-builder = { module = "io.ktor:ktor-html-builder", version.ref = "ktor" }
|
||||
ktor-jackson = { module = "io.ktor:ktor-jackson", version.ref = "ktor" }
|
||||
ktor-locations = { module = "io.ktor:ktor-locations", version.ref = "ktor" }
|
||||
ktor-metrics-micrometer = { module = "io.ktor:ktor-metrics-micrometer", version.ref = "ktor" }
|
||||
ktor-metrics = { module = "io.ktor:ktor-metrics", version.ref = "ktor" }
|
||||
ktor-mustache = { module = "io.ktor:ktor-mustache", version.ref = "ktor" }
|
||||
ktor-pebble = { module = "io.ktor:ktor-pebble", version.ref = "ktor" }
|
||||
ktor-serialization = { module = "io.ktor:ktor-serialization", version.ref = "ktor" }
|
||||
ktor-server-sessions = { module = "io.ktor:ktor-server-sessions", version.ref = "ktor" }
|
||||
ktor-thymeleaf = { module = "io.ktor:ktor-thymeleaf", version.ref = "ktor" }
|
||||
ktor-velocity = { module = "io.ktor:ktor-velocity", version.ref = "ktor" }
|
||||
ktor-webjars = { module = "io.ktor:ktor-webjars", version.ref = "ktor" }
|
||||
ktor-websockets = { module = "io.ktor:ktor-websockets", version.ref = "ktor" }
|
||||
ktor-http = { module = "io.ktor:ktor-http", version.ref = "ktor" }
|
||||
ktor-http-cio = { module = "io.ktor:ktor-http-cio", version.ref = "ktor" }
|
||||
ktor-io = { module = "io.ktor:ktor-io", version.ref = "ktor" }
|
||||
ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" }
|
||||
ktor-network-tls = { module = "io.ktor:ktor-network-tls", version.ref = "ktor" }
|
||||
ktor-network-tls-certificates = { module = "io.ktor:ktor-network-tls-certificates", version.ref = "ktor" }
|
||||
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
|
||||
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
|
||||
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
|
||||
ktor-server-jetty = { module = "io.ktor:ktor-server-jetty", version.ref = "ktor" }
|
||||
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
|
||||
ktor-server-servlet = { module = "io.ktor:ktor-server-servlet", version.ref = "ktor" }
|
||||
ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
|
||||
ktor-server-tomcat = { module = "io.ktor:ktor-server-tomcat", version.ref = "ktor" }
|
||||
ktor-test-dispatcher = { module = "io.ktor:ktor-test-dispatcher", version.ref = "ktor" }
|
||||
ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor" }
|
||||
|
||||
xmlutil-core = { module = "io.github.pdvrieze.xmlutil:core", version.ref = "xmlutil" }
|
||||
xmlutil-ktor = { module = "io.github.pdvrieze.xmlutil:ktor", version.ref = "xmlutil" }
|
||||
@ -79,21 +134,18 @@ xmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", v
|
||||
|
||||
yamlkt = { module = "net.mamoe.yamlkt:yamlkt", version.ref = "yamlkt" }
|
||||
|
||||
logback-classic = {module = "ch.qos.logback:logback-classic", version.ref = "logback"}
|
||||
|
||||
[plugins]
|
||||
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
|
||||
|
||||
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||
compose = {id = "org.jetbrains.compose", version.ref = "compose"}
|
||||
|
||||
gradle-common = { id = "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" }
|
||||
gradle-common = { id = "ru.mipt.npm.gradle.common", version.ref = "tools" }
|
||||
gradle-project = { id = "ru.mipt.npm.gradle.project", version.ref = "tools" }
|
||||
gradle-mpp = { id = "ru.mipt.npm.gradle.mpp", version.ref = "tools" }
|
||||
gradle-jvm = { id = "ru.mipt.npm.gradle.jvm", version.ref = "tools" }
|
||||
gradle-js = { id = "ru.mipt.npm.gradle.js", version.ref = "tools" }
|
||||
gradle-native = { id = "ru.mipt.npm.gradle.native", version.ref = "tools" }
|
||||
gradle-node = { id = "ru.mipt.npm.gradle.node", version.ref = "tools" }
|
||||
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlin" }
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
11
src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt
Normal file
11
src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt
Normal file
@ -0,0 +1,11 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
public open class KScienceCommonPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.configureKScience(
|
||||
KotlinVersion(1, 6, 10)
|
||||
)
|
||||
}
|
188
src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt
Normal file
188
src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt
Normal file
@ -0,0 +1,188 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import kotlinx.atomicfu.plugin.gradle.AtomicFUGradlePlugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.ApplicationPlugin
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
import org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask
|
||||
import ru.mipt.npm.gradle.internal.defaultPlatform
|
||||
import ru.mipt.npm.gradle.internal.useCommonDependency
|
||||
import ru.mipt.npm.gradle.internal.useFx
|
||||
|
||||
public enum class FXModule(public val artifact: String, public vararg val dependencies: FXModule) {
|
||||
BASE("javafx-base"),
|
||||
GRAPHICS("javafx-graphics", BASE),
|
||||
CONTROLS("javafx-controls", GRAPHICS, BASE),
|
||||
FXML("javafx-fxml", BASE),
|
||||
MEDIA("javafx-media", GRAPHICS, BASE),
|
||||
SWING("javafx-swing", GRAPHICS, BASE),
|
||||
WEB("javafx-web", CONTROLS, GRAPHICS, BASE)
|
||||
}
|
||||
|
||||
public enum class FXPlatform(public val id: String) {
|
||||
WINDOWS("win"),
|
||||
LINUX("linux"),
|
||||
MAC("mac")
|
||||
}
|
||||
|
||||
public enum class DependencyConfiguration {
|
||||
API,
|
||||
IMPLEMENTATION,
|
||||
COMPILE_ONLY,
|
||||
}
|
||||
|
||||
public enum class DependencySourceSet(public val setName: String, public val suffix: String) {
|
||||
MAIN("main", "Main"),
|
||||
TEST("test", "Test")
|
||||
}
|
||||
|
||||
|
||||
public class KScienceExtension(public val project: Project) {
|
||||
/**
|
||||
* Use coroutines-core with default version or [version]
|
||||
*/
|
||||
public fun useCoroutines(
|
||||
version: String = KScienceVersions.coroutinesVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||
): Unit = project.useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
|
||||
/**
|
||||
* Use kotlinx-atomicfu plugin and library
|
||||
*/
|
||||
public fun useAtomic(
|
||||
version: String = KScienceVersions.atomicVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION,
|
||||
): Unit = project.run {
|
||||
apply<AtomicFUGradlePlugin>()
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:atomicfu:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Use core serialization library and configure targets
|
||||
*/
|
||||
public fun useSerialization(
|
||||
version: String = KScienceVersions.serializationVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||
block: SerializationTargets.() -> Unit = {},
|
||||
): Unit = project.run {
|
||||
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
|
||||
val artifactName = if (version.startsWith("0")) {
|
||||
"kotlinx-serialization-runtime"
|
||||
} else {
|
||||
"kotlinx-serialization-core"
|
||||
}
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:$artifactName:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
SerializationTargets(sourceSet, configuration).block()
|
||||
}
|
||||
|
||||
/**
|
||||
* Add platform-specific JavaFX dependencies with given list of [FXModule]s
|
||||
*/
|
||||
public fun useFx(
|
||||
vararg modules: FXModule,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
|
||||
version: String = "11",
|
||||
platform: FXPlatform = defaultPlatform,
|
||||
): Unit = project.useFx(modules.toList(), configuration, version, platform)
|
||||
|
||||
/**
|
||||
* Add dependency on kotlinx-html library
|
||||
*/
|
||||
public fun useHtml(
|
||||
version: String = KScienceVersions.htmlVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||
): Unit = project.useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-html:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
|
||||
/**
|
||||
* Use kotlinx-datetime library with default version or [version]
|
||||
*/
|
||||
public fun useDateTime(
|
||||
version: String = KScienceVersions.dateTimeVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||
): Unit = project.useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-datetime:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
|
||||
/**
|
||||
* Apply jupyter plugin
|
||||
*/
|
||||
@Deprecated("Use jupyterLibrary")
|
||||
public fun useJupyter() {
|
||||
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply jupyter plugin and add entry point for the jupyter library.
|
||||
* If left empty applies a plugin without declaring library producers
|
||||
*/
|
||||
public fun jupyterLibrary(vararg pluginClasses: String) {
|
||||
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
|
||||
project.tasks.named("processJupyterApiResources", JupyterApiResourcesTask::class.java) {
|
||||
libraryProducers = pluginClasses.toList()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark this module as an application module. JVM application should be enabled separately
|
||||
*/
|
||||
public fun application() {
|
||||
project.extensions.findByType<KotlinProjectExtension>()?.apply {
|
||||
explicitApi = null
|
||||
}
|
||||
|
||||
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
project.apply<ApplicationPlugin>()
|
||||
}
|
||||
|
||||
project.extensions.findByType<KotlinJsProjectExtension>()?.apply {
|
||||
js {
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
|
||||
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
js {
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
targets.withType<KotlinNativeTarget> {
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.registerKScienceExtension() {
|
||||
if (extensions.findByType<KScienceExtension>() == null) {
|
||||
extensions.add("kscience", KScienceExtension(this))
|
||||
}
|
||||
}
|
17
src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt
Normal file
17
src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
|
||||
public open class KScienceJSPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.js")) {
|
||||
plugins.apply("org.jetbrains.kotlin.js")
|
||||
} else {
|
||||
logger.info("Kotlin JS plugin is already present")
|
||||
}
|
||||
|
||||
apply<KScienceCommonPlugin>()
|
||||
}
|
||||
}
|
16
src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt
Normal file
16
src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt
Normal file
@ -0,0 +1,16 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
|
||||
public open class KScienceJVMPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm"))
|
||||
plugins.apply("org.jetbrains.kotlin.jvm")
|
||||
else
|
||||
logger.info("Kotlin JVM plugin is already present")
|
||||
|
||||
apply<KScienceCommonPlugin>()
|
||||
}
|
||||
}
|
20
src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt
Normal file
20
src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.hasPlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
||||
|
||||
public open class KScienceMPPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
if (!plugins.hasPlugin(KotlinMultiplatformPlugin::class)) {
|
||||
//apply<KotlinMultiplatformPlugin>() for some reason it does not work
|
||||
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
} else {
|
||||
logger.info("Kotlin MPP plugin is already present")
|
||||
}
|
||||
|
||||
apply<KScienceCommonPlugin>()
|
||||
}
|
||||
}
|
59
src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt
Normal file
59
src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt
Normal file
@ -0,0 +1,59 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
public class KScienceNativePlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
//Apply multiplatform plugin is not applied, apply it
|
||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
|
||||
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
if (!plugins.hasPlugin(KScienceCommonPlugin::class)) {
|
||||
logger.info("KScience plugin is not resolved. Adding it automatically")
|
||||
apply<KScienceCommonPlugin>()
|
||||
}
|
||||
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
val nativeTargets = setOf(
|
||||
linuxX64(),
|
||||
mingwX64(),
|
||||
macosX64(),
|
||||
iosX64(),
|
||||
iosArm64()
|
||||
)
|
||||
|
||||
sourceSets {
|
||||
val commonMain = findByName("commonMain")!!
|
||||
val commonTest = findByName("commonTest")!!
|
||||
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
val nativeTest by creating {
|
||||
//should NOT depend on nativeMain because automatic dependency by plugin
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
configure(nativeTargets) {
|
||||
compilations["main"]?.apply {
|
||||
configure(kotlinSourceSets) {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
}
|
||||
|
||||
compilations["test"]?.apply {
|
||||
configure(kotlinSourceSets) {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
57
src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt
Normal file
57
src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt
Normal file
@ -0,0 +1,57 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.findPlugin
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
/**
|
||||
* Create a separate target for node
|
||||
*/
|
||||
public class KScienceNodePlugin : Plugin<Project> {
|
||||
override fun apply(target: Project): Unit = target.run {
|
||||
//Apply multiplatform plugin is not applied, apply it
|
||||
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
||||
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
||||
logger.info("KScience plugin is not resolved. Adding it automatically")
|
||||
apply<KScienceCommonPlugin>()
|
||||
}
|
||||
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
js(name = "node", compiler = IR) {
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain = findByName("commonMain")!!
|
||||
val commonTest = findByName("commonTest")!!
|
||||
|
||||
val jsCommonMain = create("jsCommonMain").apply {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
val jsCommonTest = create("jsCommonTest").apply {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
findByName("jsMain")?.dependsOn(jsCommonMain)
|
||||
findByName("jsTest")?.dependsOn(jsCommonTest)
|
||||
|
||||
findByName("nodeMain")?.apply {
|
||||
dependsOn(jsCommonMain)
|
||||
dependencies {
|
||||
api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}")
|
||||
}
|
||||
}
|
||||
findByName("nodeTest")?.dependsOn(jsCommonMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +1,35 @@
|
||||
package space.kscience.gradle
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import kotlinx.validation.ApiValidationExtension
|
||||
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.maven.MavenPom
|
||||
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
|
||||
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
|
||||
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.*
|
||||
import ru.mipt.npm.gradle.internal.*
|
||||
|
||||
/**
|
||||
* Simplifies adding repositories for Maven publishing, responds for releasing tasks for projects.
|
||||
*/
|
||||
public class KSciencePublishingExtension(public val project: Project) {
|
||||
private var isVcsInitialized = false
|
||||
internal val repositoryNames = mutableSetOf<String>()
|
||||
|
||||
@Deprecated("Use git function and report an issue if other VCS is used.")
|
||||
public fun vcs(vcsUrl: String) {
|
||||
if (!isVcsInitialized) {
|
||||
project.setupPublication {
|
||||
url.set(vcsUrl)
|
||||
scm { url.set(vcsUrl) }
|
||||
}
|
||||
|
||||
isVcsInitialized = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures Git repository (sources) for the publication.
|
||||
@ -27,23 +38,16 @@ public class KSciencePublishingExtension(public val project: Project) {
|
||||
* @param connectionUrl URL of the Git repository.
|
||||
* @param developerConnectionUrl URL of the Git repository for developers.
|
||||
*/
|
||||
public fun pom(
|
||||
vcsUrl: String,
|
||||
connectionUrl: String? = null,
|
||||
developerConnectionUrl: String? = connectionUrl,
|
||||
connectionPrefix: String = "scm:git:",
|
||||
pomConfig: MavenPom.() -> Unit,
|
||||
) {
|
||||
public fun git(vcsUrl: String, connectionUrl: String? = null, developerConnectionUrl: String? = connectionUrl) {
|
||||
if (!isVcsInitialized) {
|
||||
project.setupPublication {
|
||||
url.set(vcsUrl)
|
||||
|
||||
scm {
|
||||
url.set(vcsUrl)
|
||||
connectionUrl?.let { connection.set("$connectionPrefix$it") }
|
||||
developerConnectionUrl?.let { developerConnection.set("$connectionPrefix$it") }
|
||||
connectionUrl?.let { connection.set("scm:git:$it") }
|
||||
developerConnectionUrl?.let { developerConnection.set("scm:git:$it") }
|
||||
}
|
||||
pomConfig()
|
||||
}
|
||||
|
||||
isVcsInitialized = true
|
||||
@ -55,16 +59,22 @@ public class KSciencePublishingExtension(public val project: Project) {
|
||||
*
|
||||
* @param githubProject the GitHub project.
|
||||
* @param githubOrg the GitHub user or organization.
|
||||
* @param deploy publish packages in the `deploy` task to the GitHub repository.
|
||||
* @param addToRelease publish packages in the `release` task to the GitHub repository.
|
||||
*/
|
||||
public fun github(
|
||||
githubOrg: String,
|
||||
githubProject: String,
|
||||
deploy: Boolean = project.requestPropertyOrNull("publishing.github") == "true",
|
||||
githubOrg: String = "mipt-npm",
|
||||
addToRelease: Boolean = project.requestPropertyOrNull("publishing.github") == "true",
|
||||
) {
|
||||
if (deploy) {
|
||||
// Automatically initialize VCS using GitHub
|
||||
if (!isVcsInitialized) {
|
||||
git("https://github.com/$githubOrg/${githubProject}", "https://github.com/$githubOrg/${githubProject}.git")
|
||||
}
|
||||
|
||||
if (addToRelease) {
|
||||
try {
|
||||
project.addGithubPublishing(githubOrg, githubProject)
|
||||
repositoryNames += "github"
|
||||
} catch (t: Throwable) {
|
||||
project.logger.error("Failed to set up github publication", t)
|
||||
}
|
||||
@ -75,12 +85,15 @@ public class KSciencePublishingExtension(public val project: Project) {
|
||||
* Adds Space Packages Maven repository to publishing.
|
||||
*
|
||||
* @param spaceRepo the repository URL.
|
||||
* @param deploy publish packages in the `deploy` task to the Space repository.
|
||||
* @param addToRelease publish packages in the `release` task to the Space repository.
|
||||
*/
|
||||
public fun space(
|
||||
spaceRepo: String,
|
||||
spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven",
|
||||
addToRelease: Boolean = project.requestPropertyOrNull("publishing.space") != "false",
|
||||
) {
|
||||
project.addSpacePublishing(spaceRepo)
|
||||
|
||||
if (addToRelease) repositoryNames += "space"
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,9 +101,13 @@ public class KSciencePublishingExtension(public val project: Project) {
|
||||
*
|
||||
* @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" }
|
||||
public fun sonatype(
|
||||
addToRelease: Boolean = (project.requestPropertyOrNull("publishing.sonatype") != "false"),
|
||||
) {
|
||||
require(isVcsInitialized) { "The project vcs is not set up use 'git' method to do so" }
|
||||
project.addSonatypePublishing()
|
||||
|
||||
if (addToRelease) repositoryNames += "sonatype"
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,21 +121,8 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
apply<DokkaPlugin>()
|
||||
apply<BinaryCompatibilityValidatorPlugin>()
|
||||
|
||||
allprojects{
|
||||
repositories{
|
||||
mavenCentral()
|
||||
maven("https://repo.kotlin.link")
|
||||
maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev")
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/gradle/gradle/issues/15568
|
||||
tasks.withType<AbstractPublishToMaven>().configureEach {
|
||||
mustRunAfter(tasks.withType<Sign>())
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
if (isInDevelopment) {
|
||||
if (isSnapshot()) {
|
||||
configure<ApiValidationExtension> {
|
||||
validationDisabled = true
|
||||
}
|
||||
@ -138,8 +142,6 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
subprojects {
|
||||
val readmeExtension = KScienceReadmeExtension(this)
|
||||
extensions.add("readme", readmeExtension)
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val generateReadme by tasks.creating {
|
||||
group = "documentation"
|
||||
description = "Generate a README file if stub is present"
|
||||
@ -202,10 +204,11 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
|
||||
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)")
|
||||
val name = subproject.name
|
||||
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
|
||||
val ext = subproject.extensions.findByType<KScienceReadmeExtension>()
|
||||
appendLine("\n### [$name]($path)")
|
||||
if (ext != null) {
|
||||
appendLine("> ${ext.description}")
|
||||
appendLine(">\n> **Maturity**: ${ext.maturity}")
|
||||
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
|
||||
@ -231,32 +234,49 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
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)
|
||||
|
||||
val releaseAll by tasks.creating {
|
||||
group = RELEASE_GROUP
|
||||
description = "Publish development or production release based on version suffix"
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
afterEvaluate {
|
||||
ksciencePublish.repositoryNames.forEach { repositoryName ->
|
||||
val repositoryNameCapitalized = repositoryName.capitalize()
|
||||
|
||||
val pattern = "publish(?<publication>.*)PublicationTo${repositoryNameCapitalized}Repository"
|
||||
.toRegex()
|
||||
|
||||
tasks.withType<PublishToMavenRepository>().toList().forEach forEachPublication@ {
|
||||
val matchResult = pattern.matchEntire(it.name) ?: return@forEachPublication
|
||||
val publicationName = matchResult.groups["publication"]!!.value.capitalize()
|
||||
val releaseTaskName = "release$publicationName"
|
||||
|
||||
val targetReleaseTask = rootProject.tasks.findByName(releaseTaskName) ?: rootProject.tasks.create(releaseTaskName) {
|
||||
group = RELEASE_GROUP
|
||||
description = "Publish platform release artifact for $publicationName to all repositories"
|
||||
}
|
||||
|
||||
releaseAll.dependsOn(targetReleaseTask)
|
||||
|
||||
targetReleaseTask.dependsOn(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable API validation for snapshots
|
||||
if (isInDevelopment) {
|
||||
if (isSnapshot()) {
|
||||
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"
|
||||
public const val RELEASE_GROUP: String = "release"
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package space.kscience.gradle
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import freemarker.cache.StringTemplateLoader
|
||||
import freemarker.template.Configuration
|
||||
@ -90,6 +90,11 @@ public class KScienceReadmeExtension(public val project: Project) {
|
||||
|
||||
public val features: MutableList<Feature> = ArrayList()
|
||||
|
||||
@Deprecated("Use lambda builder instead.")
|
||||
public fun feature(id: String, description: String, ref: String? = null, name: String = id) {
|
||||
features += Feature(id, description, ref, name)
|
||||
}
|
||||
|
||||
public fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
|
||||
features += Feature(id, description(), ref, name)
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package space.kscience.gradle
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.tomlj.Toml
|
||||
|
||||
/**
|
||||
@ -23,6 +24,8 @@ public object KScienceVersions {
|
||||
public val jsBom: String get() = toml.getString("versions.jsBom")!!
|
||||
internal val junit: String get() = toml.getString("versions.junit")!!
|
||||
|
||||
public val JVM_TARGET: JavaVersion = JavaVersion.VERSION_11
|
||||
|
||||
public object Serialization {
|
||||
public val xmlVersion: String get() = toml.getString("versions.xmlutil")!!
|
||||
public val yamlKtVersion: String get() = toml.getString("versions.yamlkt")!!
|
@ -1,7 +1,7 @@
|
||||
package space.kscience.gradle
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import space.kscience.gradle.internal.useCommonDependency
|
||||
import ru.mipt.npm.gradle.internal.useCommonDependency
|
||||
|
||||
public class SerializationTargets(
|
||||
public val sourceSet: DependencySourceSet,
|
169
src/main/kotlin/ru/mipt/npm/gradle/commonConfigurations.kt
Normal file
169
src/main/kotlin/ru/mipt/npm/gradle/commonConfigurations.kt
Normal file
@ -0,0 +1,169 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import ru.mipt.npm.gradle.internal.applyRepos
|
||||
import ru.mipt.npm.gradle.internal.applySettings
|
||||
import ru.mipt.npm.gradle.internal.fromJsDependencies
|
||||
|
||||
|
||||
private val defaultJvmArgs: List<String> = listOf("-Xjvm-default=all", "-Xlambdas=indy", "-Xcontext-receivers")
|
||||
|
||||
public fun Project.configureKScience(
|
||||
kotlinVersion: KotlinVersion
|
||||
){
|
||||
//Common configuration
|
||||
registerKScienceExtension()
|
||||
repositories.applyRepos()
|
||||
|
||||
//Configuration for K-JVM plugin
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
//logger.info("Applying KScience configuration for JVM project")
|
||||
configure<KotlinJvmProjectExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings(kotlinVersion)
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<KotlinJvmCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
|
||||
}
|
||||
}
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||
//logger.info("Applying KScience configuration for JS project")
|
||||
configure<KotlinJsProjectExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
js(IR) {
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings(kotlinVersion)
|
||||
}
|
||||
|
||||
sourceSets["main"].apply {
|
||||
dependencies {
|
||||
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(tasks.findByName("processResources") as? Copy)?.apply {
|
||||
fromJsDependencies("runtimeClasspath")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
js(IR) {
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-common"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
|
||||
}
|
||||
}
|
||||
val jvmMain by getting
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
||||
}
|
||||
}
|
||||
val jsMain by getting
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings(kotlinVersion)
|
||||
}
|
||||
|
||||
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
|
||||
fromJsDependencies("jsRuntimeClasspath")
|
||||
}
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// apply dokka for all projects
|
||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||
apply<DokkaPlugin>()
|
||||
}
|
||||
}
|
103
src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt
Normal file
103
src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt
Normal file
@ -0,0 +1,103 @@
|
||||
package ru.mipt.npm.gradle.internal
|
||||
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.getByName
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||
|
||||
internal fun LanguageSettingsBuilder.applySettings(
|
||||
kotlinVersion: KotlinVersion
|
||||
) {
|
||||
val versionString = "${kotlinVersion.major}.${kotlinVersion.minor}"
|
||||
languageVersion = versionString
|
||||
apiVersion = versionString
|
||||
progressiveMode = true
|
||||
|
||||
optIn("kotlin.RequiresOptIn")
|
||||
optIn("kotlin.ExperimentalUnsignedTypes")
|
||||
optIn("kotlin.ExperimentalStdlibApi")
|
||||
optIn("kotlin.time.ExperimentalTime")
|
||||
optIn("kotlin.contracts.ExperimentalContracts")
|
||||
optIn("kotlin.js.ExperimentalJsExport")
|
||||
}
|
||||
|
||||
internal fun RepositoryHandler.applyRepos() {
|
||||
mavenCentral()
|
||||
maven("https://repo.kotlin.link")
|
||||
}
|
||||
|
||||
internal fun Copy.fromJsDependencies(configurationName: String) = project.run {
|
||||
val configuration = configurations[configurationName]
|
||||
?: error("Configuration with name $configurationName could not be resolved.")
|
||||
val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map {
|
||||
it.dependencyProject
|
||||
}
|
||||
projectDeps.forEach { dep ->
|
||||
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
dep.tasks.findByName("jsProcessResources")?.let { task ->
|
||||
dependsOn(task)
|
||||
from(task)
|
||||
}
|
||||
}
|
||||
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||
dep.tasks.findByName("processResources")?.let { task ->
|
||||
dependsOn(task)
|
||||
from(task)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun KotlinMultiplatformExtension.bundleJsBinaryAsResource(bundleName: String = "js/bundle.js") {
|
||||
js {
|
||||
binaries.executable()
|
||||
browser {
|
||||
webpackTask {
|
||||
outputFileName = bundleName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jvm {
|
||||
val processResourcesTaskName =
|
||||
compilations[org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.MAIN_COMPILATION_NAME]
|
||||
.processResourcesTaskName
|
||||
|
||||
val jsBrowserDistribution = project.tasks.getByName("jsBrowserDistribution")
|
||||
|
||||
project.tasks.getByName<ProcessResources>(processResourcesTaskName) {
|
||||
duplicatesStrategy = DuplicatesStrategy.WARN
|
||||
dependsOn(jsBrowserDistribution)
|
||||
from(jsBrowserDistribution)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate {
|
||||
// val projectDeps = configuration.allDependencies
|
||||
// .filterIsInstance<ProjectDependency>()
|
||||
// .map { it.dependencyProject }
|
||||
//
|
||||
// projectDeps.forEach { dep ->
|
||||
// dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
// dep.tasks.findByName("jvmProcessResources")?.let { task ->
|
||||
// dependsOn(task)
|
||||
// from(task)
|
||||
// }
|
||||
// }
|
||||
// dep.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
// dep.tasks.findByName("processResources")?.let { task ->
|
||||
// dependsOn(task)
|
||||
// from(task)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,4 +1,4 @@
|
||||
package space.kscience.gradle.internal
|
||||
package ru.mipt.npm.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 space.kscience.gradle.DependencyConfiguration
|
||||
import space.kscience.gradle.DependencySourceSet
|
||||
import ru.mipt.npm.gradle.DependencyConfiguration
|
||||
import ru.mipt.npm.gradle.DependencySourceSet
|
||||
|
||||
internal fun Project.useDependency(
|
||||
vararg pairs: Pair<String, String>,
|
61
src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt
Normal file
61
src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt
Normal file
@ -0,0 +1,61 @@
|
||||
package ru.mipt.npm.gradle.internal
|
||||
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||
import ru.mipt.npm.gradle.DependencyConfiguration
|
||||
import ru.mipt.npm.gradle.FXModule
|
||||
import ru.mipt.npm.gradle.FXPlatform
|
||||
|
||||
internal val defaultPlatform: FXPlatform = when {
|
||||
Os.isFamily(Os.FAMILY_WINDOWS) -> FXPlatform.WINDOWS
|
||||
Os.isFamily(Os.FAMILY_MAC) -> FXPlatform.MAC
|
||||
Os.isFamily(Os.FAMILY_UNIX) -> FXPlatform.LINUX
|
||||
else -> error("Platform not recognized")
|
||||
}
|
||||
|
||||
private fun KotlinDependencyHandler.addFXDependencies(
|
||||
modules: List<FXModule>,
|
||||
configuration: DependencyConfiguration,
|
||||
version: String = "14",
|
||||
platform: FXPlatform = defaultPlatform
|
||||
) {
|
||||
modules.flatMap { it.dependencies.toList() + it }.distinct().forEach {
|
||||
val notation = "org.openjfx:${it.artifact}:$version:${platform.id}"
|
||||
when (configuration) {
|
||||
DependencyConfiguration.API -> api(notation)
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementation(notation)
|
||||
DependencyConfiguration.COMPILE_ONLY -> compileOnly(notation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.useFx(
|
||||
modules: List<FXModule>,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
|
||||
version: String = "14",
|
||||
platform: FXPlatform = defaultPlatform
|
||||
): Unit = afterEvaluate {
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
sourceSets.findByName("jvmMain")?.apply {
|
||||
dependencies {
|
||||
addFXDependencies(modules, configuration = configuration, version = version, platform = platform)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
extensions.findByType<KotlinJvmProjectExtension>()?.apply {
|
||||
sourceSets.findByName("main")?.apply {
|
||||
dependencies {
|
||||
addFXDependencies(modules, configuration = configuration, version = version, platform = platform)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package space.kscience.gradle.internal
|
||||
package ru.mipt.npm.gradle.internal
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
@ -10,8 +10,6 @@ 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)
|
||||
@ -33,9 +31,8 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
|
||||
from(it.kotlin)
|
||||
}
|
||||
}
|
||||
|
||||
publications.create<MavenPublication>("js") {
|
||||
kotlin.targets.flatMap { it.components }.forEach {
|
||||
kotlin.js().components.forEach {
|
||||
from(it)
|
||||
}
|
||||
|
||||
@ -63,12 +60,37 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
val dokkaJar by tasks.creating(Jar::class) {
|
||||
group = "documentation"
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.findByName("dokkaHtml"))
|
||||
}
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications.withType<MavenPublication> {
|
||||
artifact(dokkaJar)
|
||||
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description ?: project.name)
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
distribution.set("repo")
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id.set("MIPT-NPM")
|
||||
name.set("MIPT nuclear physics methods laboratory")
|
||||
organization.set("MIPT")
|
||||
organizationUrl.set("https://npm.mipt.ru")
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
tag.set(project.version.toString())
|
||||
}
|
||||
@ -76,42 +98,12 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
|
||||
mavenPomConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId("org.jetbrains.dokka") {
|
||||
val dokkaJar by tasks.creating(Jar::class) {
|
||||
group = "documentation"
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.findByName("dokkaHtml"))
|
||||
}
|
||||
publications.withType<MavenPublication> {
|
||||
artifact(dokkaJar)
|
||||
}
|
||||
}
|
||||
|
||||
if (requestPropertyOrNull("publishing.signing.id") != null || requestPropertyOrNull("signing.gnupg.keyName") != null) {
|
||||
|
||||
if (!plugins.hasPlugin("signing")) {
|
||||
apply<SigningPlugin>()
|
||||
}
|
||||
|
||||
extensions.configure<SigningExtension>("signing") {
|
||||
val signingId: String? = requestPropertyOrNull("publishing.signing.id")
|
||||
if (!signingId.isNullOrBlank()) {
|
||||
val signingKey: String = requestProperty("publishing.signing.key")
|
||||
val signingPassphrase: String = requestProperty("publishing.signing.passPhrase")
|
||||
|
||||
// if key is provided, use it
|
||||
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
|
||||
} // else use agent signing
|
||||
sign(publications)
|
||||
}
|
||||
} else {
|
||||
logger.warn("Signing information is not provided. Skipping artefact signing.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.isSnapshot() = "dev" in version.toString() || version.toString().endsWith("SNAPSHOT")
|
||||
|
||||
internal fun Project.addGithubPublishing(
|
||||
githubOrg: String,
|
||||
githubProject: String,
|
||||
@ -186,8 +178,8 @@ internal fun Project.addSonatypePublishing() {
|
||||
return
|
||||
}
|
||||
|
||||
if (isInDevelopment) {
|
||||
logger.info("Sonatype publishing skipped for development version")
|
||||
if (isSnapshot()) {
|
||||
logger.info("Sonatype publishing skipped for dev version")
|
||||
return
|
||||
}
|
||||
|
||||
@ -202,8 +194,24 @@ internal fun Project.addSonatypePublishing() {
|
||||
allprojects {
|
||||
plugins.withId("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
if (!plugins.hasPlugin("signing")) {
|
||||
apply<SigningPlugin>()
|
||||
}
|
||||
|
||||
extensions.configure<SigningExtension>("signing") {
|
||||
val signingId: String? = requestPropertyOrNull("publishing.signing.id")
|
||||
if (!signingId.isNullOrBlank()) {
|
||||
val signingKey: String = requestProperty("publishing.signing.key")
|
||||
val signingPassphrase: String = requestProperty("publishing.signing.passPhrase")
|
||||
|
||||
// if key is provided, use it
|
||||
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
|
||||
} // else use file signing
|
||||
sign(publications)
|
||||
}
|
||||
|
||||
repositories.maven {
|
||||
val sonatypeRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
val sonatypeRepo = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||
name = "sonatype"
|
||||
url = uri(sonatypeRepo)
|
||||
|
@ -1,548 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
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>()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
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>()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.hasPlugin
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
||||
import space.kscience.gradle.internal.applySettings
|
||||
|
||||
public open class KScienceMPPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
if (!plugins.hasPlugin(KotlinMultiplatformPlugin::class)) {
|
||||
//apply<KotlinMultiplatformPlugin>() for some reason it does not work
|
||||
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
} else {
|
||||
logger.info("Kotlin MPP plugin is already present")
|
||||
}
|
||||
|
||||
registerKScienceExtension(::KScienceMppExtension)
|
||||
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
|
||||
sourceSets {
|
||||
getByName("commonMain"){
|
||||
dependencies {
|
||||
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
||||
}
|
||||
}
|
||||
getByName("commonTest"){
|
||||
dependencies {
|
||||
implementation(kotlin("test-common"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings()
|
||||
}
|
||||
|
||||
if (explicitApi == null) explicitApiWarning()
|
||||
}
|
||||
|
||||
|
||||
// apply dokka for all projects
|
||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||
apply<DokkaPlugin>()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
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,24 +0,0 @@
|
||||
package space.kscience.gradle
|
||||
|
||||
import org.gradle.api.publish.maven.MavenPom
|
||||
|
||||
public fun MavenPom.useApache2Licence(){
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache Software License, Version 2.0")
|
||||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
distribution.set("repo")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public fun MavenPom.useSPCTeam(){
|
||||
developers {
|
||||
developer {
|
||||
id.set("SPC")
|
||||
name.set("Scientific programming centre")
|
||||
organization.set("MIPT")
|
||||
organizationUrl.set("https://sciprog.center/")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import space.kscience.gradle.KScienceVersions
|
||||
|
||||
class TestPlugins {
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user