2020-08-20 10:02:28 +03:00
|
|
|
package ru.mipt.npm.gradle
|
2019-07-21 17:40:08 +03:00
|
|
|
|
|
|
|
import org.gradle.api.Plugin
|
|
|
|
import org.gradle.api.Project
|
2019-11-20 10:41:37 +03:00
|
|
|
import org.gradle.api.plugins.JavaPluginExtension
|
2020-04-07 12:49:40 +03:00
|
|
|
import org.gradle.api.tasks.testing.Test
|
2020-10-20 09:56:01 +03:00
|
|
|
import org.gradle.kotlin.dsl.configure
|
|
|
|
import org.gradle.kotlin.dsl.findByType
|
|
|
|
import org.gradle.kotlin.dsl.get
|
|
|
|
import org.gradle.kotlin.dsl.withType
|
2019-07-21 18:17:40 +03:00
|
|
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
2019-07-21 17:40:08 +03:00
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
|
|
|
2020-08-20 10:02:28 +03:00
|
|
|
open class KScienceJVMPlugin : Plugin<Project> {
|
2020-07-05 14:39:35 +03:00
|
|
|
override fun apply(project: Project): Unit = project.run {
|
|
|
|
plugins.apply("org.jetbrains.kotlin.jvm")
|
2020-09-09 11:40:49 +03:00
|
|
|
registerKScienceExtension()
|
2019-07-21 17:40:08 +03:00
|
|
|
|
2020-07-05 14:39:35 +03:00
|
|
|
repositories.applyRepos()
|
2019-07-21 17:40:08 +03:00
|
|
|
|
2020-07-05 14:39:35 +03:00
|
|
|
extensions.findByType<JavaPluginExtension>()?.apply {
|
2020-08-20 10:02:28 +03:00
|
|
|
targetCompatibility = KScienceVersions.JVM_TARGET
|
2020-10-20 09:56:01 +03:00
|
|
|
withSourcesJar()
|
|
|
|
//withJavadocJar()
|
2020-07-05 14:39:35 +03:00
|
|
|
}
|
2019-11-20 10:41:37 +03:00
|
|
|
|
2020-07-05 14:39:35 +03:00
|
|
|
tasks.withType<KotlinCompile> {
|
|
|
|
kotlinOptions {
|
2020-08-31 12:40:13 +03:00
|
|
|
// useIR = true
|
2020-08-20 10:02:28 +03:00
|
|
|
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
2019-07-21 17:40:08 +03:00
|
|
|
}
|
2020-07-05 14:39:35 +03:00
|
|
|
}
|
2019-07-21 17:40:08 +03:00
|
|
|
|
2020-07-05 14:39:35 +03:00
|
|
|
configure<KotlinJvmProjectExtension> {
|
2020-08-20 10:02:28 +03:00
|
|
|
explicitApiWarning()
|
2020-07-05 14:39:35 +03:00
|
|
|
val sourceSet = sourceSets["main"].apply {
|
|
|
|
languageSettings.applySettings()
|
|
|
|
}
|
2019-08-09 11:51:30 +03:00
|
|
|
|
2020-07-05 14:39:35 +03:00
|
|
|
sourceSets["test"].apply {
|
|
|
|
languageSettings.applySettings()
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("test-junit5"))
|
|
|
|
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
2019-11-01 22:06:41 +03:00
|
|
|
}
|
2020-07-05 14:39:35 +03:00
|
|
|
}
|
2019-07-21 17:40:08 +03:00
|
|
|
}
|
2020-07-06 09:52:54 +03:00
|
|
|
|
|
|
|
tasks.apply {
|
|
|
|
withType<Test>() {
|
|
|
|
useJUnitPlatform()
|
|
|
|
}
|
2020-10-02 19:07:10 +03:00
|
|
|
//
|
|
|
|
// val processResources by getting(Copy::class)
|
|
|
|
// processResources.copyJVMResources(configurations["runtimeClasspath"])
|
2020-07-05 14:39:35 +03:00
|
|
|
}
|
2019-07-21 17:40:08 +03:00
|
|
|
}
|
2020-07-05 14:39:35 +03:00
|
|
|
|
|
|
|
}
|