Migrate to kScience and kotlin 1.4
This commit is contained in:
parent
589ac77c2b
commit
6464d9d926
@ -7,8 +7,8 @@ plugins {
|
||||
id("org.jetbrains.changelog") version "0.3.2"
|
||||
}
|
||||
|
||||
group = "scientifik"
|
||||
version = "0.5.2"
|
||||
group = "ru.mipt.npm"
|
||||
version = "0.6.0"
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
@ -17,7 +17,7 @@ repositories {
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
}
|
||||
|
||||
val kotlinVersion = "1.3.72"
|
||||
val kotlinVersion = "1.4.0"
|
||||
|
||||
java {
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
@ -27,34 +27,47 @@ java {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.3")
|
||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1")
|
||||
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.4")
|
||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.0-rc")
|
||||
implementation("org.jetbrains.dokka:dokka-core:1.4.0-rc")
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("scientifik-publish") {
|
||||
id = "scientifik.publish"
|
||||
create("kscience-publish") {
|
||||
id = "kscience.publish"
|
||||
description = "The publication plugin for bintray and github"
|
||||
implementationClass = "scientifik.ScientifikPublishPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KSciencePublishPlugin"
|
||||
}
|
||||
|
||||
create("scientifik-mpp") {
|
||||
id = "scientifik.mpp"
|
||||
create("kscience.mpp") {
|
||||
id = "kscience.mpp"
|
||||
description = "Pre-configured multiplatform project"
|
||||
implementationClass = "scientifik.ScientifikMPPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
|
||||
}
|
||||
|
||||
create("scientifik-jvm") {
|
||||
id = "scientifik.jvm"
|
||||
create("kscience.jvm") {
|
||||
id = "kscience.jvm"
|
||||
description = "Pre-configured JVM project"
|
||||
implementationClass = "scientifik.ScientifikJVMPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
|
||||
}
|
||||
|
||||
create("scientifik-js") {
|
||||
id = "scientifik.js"
|
||||
create("kscience.js") {
|
||||
id = "kscience.js"
|
||||
description = "Pre-configured JS project"
|
||||
implementationClass = "scientifik.ScientifikJSPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
|
||||
}
|
||||
|
||||
create("kscience.native") {
|
||||
id = "kscience.native"
|
||||
description = "Additional native targets to be use alongside mpp"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
|
||||
}
|
||||
|
||||
create("kscience.node") {
|
||||
id = "kscience.node"
|
||||
description = "NodeJS target for kotlin-mpp and kotlin-js"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,7 +119,7 @@ publishing {
|
||||
// this is a problem of this plugin
|
||||
pkg.apply {
|
||||
userOrg = "mipt-npm"
|
||||
repo = if (project.version.toString().contains("dev")) "dev" else "scientifik"
|
||||
repo = if (project.version.toString().contains("dev")) "dev" else "kscience"
|
||||
name = project.name
|
||||
issueTrackerUrl = "$vcs/issues"
|
||||
setLicenses("Apache-2.0")
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
2
gradlew
vendored
2
gradlew
vendored
@ -130,7 +130,7 @@ fi
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
|
21
gradlew.bat
vendored
21
gradlew.bat
vendored
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@ -54,7 +54,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@ -64,21 +64,6 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
@ -1,18 +0,0 @@
|
||||
import org.gradle.api.JavaVersion
|
||||
|
||||
/**
|
||||
* Build constants
|
||||
*/
|
||||
object Scientifik {
|
||||
const val coroutinesVersion = "1.3.7"
|
||||
const val serializationVersion = "0.20.0"
|
||||
const val atomicVersion = "0.14.3"
|
||||
|
||||
val JVM_TARGET = JavaVersion.VERSION_1_8
|
||||
|
||||
object Serialization{
|
||||
const val xmlVersion = "0.20.0.1"
|
||||
const val yamlVersion = "0.16.1"
|
||||
const val bsonVersion = "0.2.1"
|
||||
}
|
||||
}
|
65
src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt
Normal file
65
src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt
Normal file
@ -0,0 +1,65 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
import org.gradle.kotlin.dsl.findPlugin
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
|
||||
class KScienceExtension(val project: Project) {
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
fun useAtomic(version: String = KScienceVersions.atomicVersion): Unit = project.run {
|
||||
plugins.apply("kotlinx-atomicfu")
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:atomicfu:$version"
|
||||
)
|
||||
}
|
||||
|
||||
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")
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-core:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
SerializationTargets(sourceSet, configuration).apply(block)
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate publishing and configure it
|
||||
*/
|
||||
fun publishing(block: Publishing.() -> Unit) = Publishing().apply(block)
|
||||
|
||||
inner class Publishing {
|
||||
init {
|
||||
if (project.plugins.findPlugin(KSciencePublishPlugin::class) == null) {
|
||||
project.plugins.apply(KSciencePublishPlugin::class)
|
||||
}
|
||||
}
|
||||
|
||||
var githubOrg: String? by project.extra
|
||||
var githubProject: String? by project.extra
|
||||
var spaceRepo: String? by project.extra
|
||||
var spaceUser: String? by project.extra
|
||||
var spaceToken: String? by project.extra
|
||||
var bintrayOrg: String? by project.extra
|
||||
var bintrayUser: String? by project.extra
|
||||
var bintrayApiKey: String? by project.extra
|
||||
var bintrayRepo: String? by project.extra
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package scientifik
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
@ -9,14 +9,16 @@ import org.gradle.kotlin.dsl.getValue
|
||||
import org.gradle.kotlin.dsl.getting
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
|
||||
open class ScientifikJSPlugin : Plugin<Project> {
|
||||
open class KScienceJSPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
plugins.apply("org.jetbrains.kotlin.js")
|
||||
val extension = extensions.add("kscience", KScienceExtension(this))
|
||||
|
||||
repositories.applyRepos()
|
||||
|
||||
configure<KotlinJsProjectExtension> {
|
||||
target {
|
||||
explicitApiWarning()
|
||||
js(IR) {
|
||||
browser {
|
||||
webpackTask {
|
||||
outputFileName = "main.bundle.js"
|
||||
@ -47,18 +49,14 @@ open class ScientifikJSPlugin : Plugin<Project> {
|
||||
val processResources by getting(Copy::class)
|
||||
processResources.copyJSResources(configurations["runtimeClasspath"])
|
||||
|
||||
val browserDistribution by getting {
|
||||
findByName("jsBrowserDistribution")?.apply {
|
||||
doLast {
|
||||
val indexFile = project.jsDistDirectory.resolve("index.html")
|
||||
if (indexFile.exists()) {
|
||||
println("Run JS distribution at: ${indexFile.canonicalPath}")
|
||||
}
|
||||
}
|
||||
group = "distribution"
|
||||
}
|
||||
|
||||
// findByName("assemble")?.dependsOn(installJsDist)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package scientifik
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import Scientifik
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaBasePlugin
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
@ -15,36 +13,33 @@ import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
open class ScientifikJVMPlugin : Plugin<Project> {
|
||||
open class KScienceJVMPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
plugins.apply("org.jetbrains.kotlin.jvm")
|
||||
val extension = extensions.add("kscience", KScienceExtension(this))
|
||||
|
||||
repositories.applyRepos()
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = Scientifik.JVM_TARGET
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = Scientifik.JVM_TARGET.toString()
|
||||
useIR = true
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
}
|
||||
}
|
||||
|
||||
configure<KotlinJvmProjectExtension> {
|
||||
|
||||
explicitApiWarning()
|
||||
val sourceSet = sourceSets["main"].apply {
|
||||
languageSettings.applySettings()
|
||||
dependencies {
|
||||
api(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
languageSettings.applySettings()
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
// implementation(kotlin("test-junit"))
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
||||
}
|
||||
@ -69,23 +64,10 @@ open class ScientifikJVMPlugin : Plugin<Project> {
|
||||
pluginManager.withPlugin("org.jetbrains.dokka") {
|
||||
logger.info("Adding dokka functionality to project ${project.name}")
|
||||
|
||||
val dokka by tasks.getting(DokkaTask::class) {
|
||||
outputFormat = "html"
|
||||
outputDirectory = "$buildDir/javadoc"
|
||||
}
|
||||
|
||||
val kdocJar by tasks.registering(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
dependsOn(dokka)
|
||||
archiveClassifier.set("javadoc")
|
||||
from("$buildDir/javadoc")
|
||||
}
|
||||
|
||||
configure<PublishingExtension> {
|
||||
publications {
|
||||
getByName("jvm") {
|
||||
this as MavenPublication
|
||||
artifact(kdocJar.get())
|
||||
val dokkaHtml by tasks.getting(DokkaTask::class){
|
||||
dokkaSourceSets {
|
||||
configureEach {
|
||||
jdkVersion = 11
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +1,34 @@
|
||||
package scientifik
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import Scientifik
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaBasePlugin
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
open class ScientifikMPPlugin : Plugin<Project> {
|
||||
open class KScienceMPPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
|
||||
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
val extension = extensions.add("kscience", KScienceExtension(this))
|
||||
|
||||
repositories.applyRepos()
|
||||
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = Scientifik.JVM_TARGET.toString()
|
||||
useIR = true
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val js = js {
|
||||
js(IR) {
|
||||
browser {
|
||||
webpackTask {
|
||||
outputFileName = "main.bundle.js"
|
||||
@ -42,35 +40,21 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
sourceSets.invoke {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib"))
|
||||
}
|
||||
}
|
||||
val commonMain by getting
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-common"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
// implementation(kotlin("test-junit"))
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-js"))
|
||||
}
|
||||
}
|
||||
val jsMain by getting
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
@ -86,29 +70,11 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.dokka") {
|
||||
logger.info("Adding dokka functionality to project ${this@run.name}")
|
||||
val dokka by tasks.getting(DokkaTask::class) {
|
||||
outputFormat = "html"
|
||||
outputDirectory = "$buildDir/javadoc"
|
||||
multiplatform {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val kdocJar by tasks.registering(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
dependsOn(dokka)
|
||||
archiveClassifier.set("javadoc")
|
||||
from("$buildDir/javadoc")
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("maven-publish") {
|
||||
configure<PublishingExtension> {
|
||||
|
||||
targets.all {
|
||||
val publication = publications.findByName(name) as MavenPublication
|
||||
|
||||
// Patch publications with fake javadoc
|
||||
publication.artifact(kdocJar.get())
|
||||
val dokkaHtml by tasks.getting(DokkaTask::class) {
|
||||
dokkaSourceSets {
|
||||
configureEach {
|
||||
jdkVersion = 11
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,14 +91,13 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
val jvmProcessResources by getting(Copy::class)
|
||||
jvmProcessResources.copyJVMResources(configurations["jvmRuntimeClasspath"])
|
||||
|
||||
val jsBrowserDistribution by getting {
|
||||
findByName("jsBrowserDistribution")?.apply {
|
||||
doLast {
|
||||
val indexFile = project.jsDistDirectory.resolve("index.html")
|
||||
if (indexFile.exists()) {
|
||||
println("Run JS distribution at: ${indexFile.canonicalPath}")
|
||||
}
|
||||
}
|
||||
group = "distribution"
|
||||
}
|
||||
}
|
||||
|
33
src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt
Normal file
33
src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt
Normal file
@ -0,0 +1,33 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.findPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
class KScienceNativePlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) = target.run {
|
||||
if (plugins.findPlugin(KScienceMPPlugin::class) == null) {
|
||||
pluginManager.apply(KScienceMPPlugin::class)
|
||||
}
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
val hostOs = System.getProperty("os.name")
|
||||
val isMingwX64 = hostOs.startsWith("Windows")
|
||||
|
||||
val nativeTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("native")
|
||||
hostOs == "Linux" -> linuxX64("native")
|
||||
isMingwX64 -> mingwX64("native")
|
||||
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
|
||||
}
|
||||
//
|
||||
// sourceSets {
|
||||
// val nativeMain by getting
|
||||
// val nativeTest by getting
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
28
src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt
Normal file
28
src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt
Normal file
@ -0,0 +1,28 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
class KScienceNodePlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) = target.run{
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||
configure<KotlinJsProjectExtension> {
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package scientifik
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
@ -9,16 +9,17 @@ import org.gradle.kotlin.dsl.provideDelegate
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
|
||||
|
||||
open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
open class KSciencePublishPlugin : Plugin<Project> {
|
||||
|
||||
override fun apply(project: Project) {
|
||||
|
||||
project.plugins.apply("maven-publish")
|
||||
|
||||
project.afterEvaluate {
|
||||
val githubProject = findProperty("githubProject") as? String
|
||||
val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm"
|
||||
val githubProject: String? by project
|
||||
val vcs = findProperty("vcs") as? String
|
||||
?: githubProject?.let { "https://github.com/mipt-npm/$it" }
|
||||
?: githubProject?.let { "https://github.com/$githubOrg/$it" }
|
||||
|
||||
if (vcs == null) {
|
||||
project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.")
|
||||
@ -95,8 +96,8 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
|
||||
val bintrayUser = project.findProperty("bintrayUser") as? String
|
||||
val bintrayKey = project.findProperty("bintrayApiKey") as? String
|
||||
val bintrayUser: String? by project
|
||||
val bintrayApiKey: String? by project
|
||||
|
||||
|
||||
val bintrayRepo = if (project.version.toString().contains("dev")) {
|
||||
@ -107,7 +108,7 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
|
||||
val projectName = project.name
|
||||
|
||||
if (bintrayRepo != null && bintrayUser != null && bintrayKey != null) {
|
||||
if (bintrayRepo != null && bintrayUser != null && bintrayApiKey != null) {
|
||||
project.logger.info("Adding bintray publishing to project [$projectName]")
|
||||
|
||||
repositories {
|
||||
@ -118,7 +119,7 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
)
|
||||
credentials {
|
||||
username = bintrayUser
|
||||
password = bintrayKey
|
||||
password = bintrayApiKey
|
||||
}
|
||||
}
|
||||
}
|
20
src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt
Normal file
20
src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.JavaVersion
|
||||
|
||||
/**
|
||||
* Build constants
|
||||
*/
|
||||
object KScienceVersions {
|
||||
const val coroutinesVersion = "1.3.9"
|
||||
const val serializationVersion = "1.0.0-RC"
|
||||
const val atomicVersion = "0.14.4"
|
||||
|
||||
val JVM_TARGET = JavaVersion.VERSION_11
|
||||
|
||||
object Serialization{
|
||||
const val xmlVersion = "0.20.0.1"
|
||||
const val yamlVersion = "0.16.1"
|
||||
const val bsonVersion = "0.2.1"
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package scientifik
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
@ -23,9 +23,10 @@ internal fun RepositoryHandler.applyRepos(): Unit {
|
||||
jcenter()
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
maven("https://kotlin.bintray.com/kotlinx")
|
||||
maven("https://dl.bintray.com/mipt-npm/scientifik")
|
||||
maven("https://dl.bintray.com/mipt-npm/dev")
|
||||
maven("https://kotlin.bintray.com/kotlin-js-wrappers/")
|
||||
maven("https://dl.bintray.com/mipt-npm/scientifik")
|
||||
maven("https://dl.bintray.com/mipt-npm/kscience")
|
||||
maven("https://dl.bintray.com/mipt-npm/dev")
|
||||
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package scientifik
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import Scientifik
|
||||
import kotlinx.atomicfu.plugin.gradle.sourceSets
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
@ -33,7 +32,7 @@ internal fun Project.useDependency(
|
||||
when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> api(dep)
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementation(dep)
|
||||
DependencyConfiguration.COMPILE_ONLY-> compileOnly(dep)
|
||||
DependencyConfiguration.COMPILE_ONLY -> compileOnly(dep)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,7 +48,7 @@ internal fun Project.useDependency(
|
||||
val configurationName = when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> apiConfigurationName
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||
DependencyConfiguration.COMPILE_ONLY-> compileOnlyConfigurationName
|
||||
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
||||
}
|
||||
add(configurationName, dep.second)
|
||||
}
|
||||
@ -64,7 +63,7 @@ internal fun Project.useDependency(
|
||||
val configurationName = when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> apiConfigurationName
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||
DependencyConfiguration.COMPILE_ONLY-> compileOnlyConfigurationName
|
||||
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
||||
}
|
||||
add(configurationName, dep.second)
|
||||
}
|
||||
@ -73,25 +72,46 @@ internal fun Project.useDependency(
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.useCoroutines(
|
||||
version: String = Scientifik.coroutinesVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.API
|
||||
) = useDependency(
|
||||
"common" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$version",
|
||||
"jvm" to "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
|
||||
"js" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$version",
|
||||
"native" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
|
||||
fun Project.useAtomic(version: String = Scientifik.atomicVersion) {
|
||||
plugins.apply("kotlinx-atomicfu")
|
||||
useDependency(
|
||||
"commonMain" to "org.jetbrains.kotlinx:atomicfu-common:$version",
|
||||
"jvmMain" to "org.jetbrains.kotlinx:atomicfu:$version",
|
||||
"jsMain" to "org.jetbrains.kotlinx:atomicfu-js:$version",
|
||||
"nativeMain" to "org.jetbrains.kotlinx:atomicfu-native:$version"
|
||||
)
|
||||
}
|
||||
internal fun Project.useCommonDependency(
|
||||
dep: String,
|
||||
dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
|
||||
): Unit = pluginManager.run{
|
||||
withPlugin("org.jetbrains.kotlin.multiplatform"){
|
||||
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
sourceSets.findByName("common${dependencySourceSet.suffix}")?.apply {
|
||||
dependencies {
|
||||
when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> api(dep)
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementation(dep)
|
||||
DependencyConfiguration.COMPILE_ONLY -> compileOnly(dep)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||
dependencies.apply {
|
||||
val configurationName = when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> apiConfigurationName
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
||||
}
|
||||
add(configurationName, dep)
|
||||
}
|
||||
}
|
||||
}
|
||||
withPlugin("org.jetbrains.kotlin.js") {
|
||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||
dependencies.apply {
|
||||
val configurationName = when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> apiConfigurationName
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
||||
}
|
||||
add(configurationName, dep)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package scientifik
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.gradle.api.Project
|
65
src/main/kotlin/ru/mipt/npm/gradle/serialization.kt
Normal file
65
src/main/kotlin/ru/mipt/npm/gradle/serialization.kt
Normal file
@ -0,0 +1,65 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
|
||||
class SerializationTargets(
|
||||
val sourceSet: DependencySourceSet,
|
||||
val configuration: DependencyConfiguration
|
||||
) {
|
||||
fun Project.cbor(
|
||||
version: String = KScienceVersions.serializationVersion
|
||||
) {
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-cbor:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.protobuf(
|
||||
version: String = KScienceVersions.serializationVersion
|
||||
) {
|
||||
useCommonDependency(
|
||||
"org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.xml(
|
||||
version: String = KScienceVersions.Serialization.xmlVersion
|
||||
) {
|
||||
repositories {
|
||||
maven("https://dl.bintray.com/pdvrieze/maven")
|
||||
}
|
||||
useDependency(
|
||||
"common" to "net.devrieze:xmlutil-serialization:$version",
|
||||
"jvm" to "net.devrieze:xmlutil-serialization:$version",
|
||||
"js" to "net.devrieze:xmlutil-serialization:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.yaml(
|
||||
version: String = KScienceVersions.Serialization.yamlVersion
|
||||
) {
|
||||
useDependency(
|
||||
"jvm" to "com.charleskorn.kaml:kaml:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.bson(
|
||||
version: String = KScienceVersions.Serialization.bsonVersion
|
||||
) {
|
||||
useDependency(
|
||||
"jvm" to "com.github.jershell:kbson:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package scientifik
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
class ScientifikNativePlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) {
|
||||
target.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
target.configure<KotlinMultiplatformExtension> {
|
||||
linuxX64()
|
||||
mingwX64()
|
||||
|
||||
sourceSets.apply {
|
||||
val commonMain by getting {}
|
||||
|
||||
val native by creating {
|
||||
dependsOn(commonMain)
|
||||
|
||||
dependencies {
|
||||
api(kotlin("native"))
|
||||
//TODO add stdlib here
|
||||
}
|
||||
}
|
||||
|
||||
mingwX64().compilations["main"].defaultSourceSet {
|
||||
dependsOn(native)
|
||||
}
|
||||
|
||||
linuxX64().compilations["main"].defaultSourceSet {
|
||||
dependsOn(native)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package scientifik
|
||||
|
||||
import Scientifik
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
|
||||
class SerializationTargets(
|
||||
val sourceSet: DependencySourceSet,
|
||||
val configuration: DependencyConfiguration
|
||||
) {
|
||||
fun Project.cbor(
|
||||
version: String = Scientifik.serializationVersion
|
||||
) {
|
||||
useDependency(
|
||||
"common" to "org.jetbrains.kotlinx:kotlinx-serialization-cbor-common:$version",
|
||||
"jvm" to "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$version",
|
||||
"js" to "org.jetbrains.kotlinx:kotlinx-serialization-cbor-js:$version",
|
||||
"native" to "org.jetbrains.kotlinx:kotlinx-serialization-cbor-native:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.protobuf(
|
||||
version: String = Scientifik.serializationVersion
|
||||
) {
|
||||
useDependency(
|
||||
"common" to "org.jetbrains.kotlinx:kotlinx-serialization-protobuf-common:$version",
|
||||
"jvm" to "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$version",
|
||||
"js" to "org.jetbrains.kotlinx:kotlinx-serialization-protobuf-js:$version",
|
||||
"native" to "org.jetbrains.kotlinx:kotlinx-serialization-protobuf-native:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.xml(
|
||||
version: String = Scientifik.Serialization.xmlVersion
|
||||
) {
|
||||
repositories {
|
||||
maven("https://dl.bintray.com/pdvrieze/maven")
|
||||
}
|
||||
useDependency(
|
||||
"common" to "net.devrieze:xmlutil-serialization:$version",
|
||||
"jvm" to "net.devrieze:xmlutil-serialization:$version",
|
||||
"js" to "net.devrieze:xmlutil-serialization:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.yaml(
|
||||
version: String = Scientifik.Serialization.yamlVersion
|
||||
) {
|
||||
useDependency(
|
||||
"jvm" to "com.charleskorn.kaml:kaml:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.bson(
|
||||
version: String = Scientifik.Serialization.bsonVersion
|
||||
) {
|
||||
useDependency(
|
||||
"jvm" to "com.github.jershell:kbson:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.useSerialization(
|
||||
version: String = Scientifik.serializationVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||
block: SerializationTargets.() -> Unit = {}
|
||||
) {
|
||||
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
|
||||
useDependency(
|
||||
"common" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$version",
|
||||
"jvm" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$version",
|
||||
"js" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$version",
|
||||
"native" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
SerializationTargets(sourceSet, configuration).apply(block)
|
||||
}
|
Loading…
Reference in New Issue
Block a user