2020-08-20 10:02:28 +03:00
|
|
|
package ru.mipt.npm.gradle
|
2019-07-24 15:03:12 +03:00
|
|
|
|
2020-03-14 14:42:11 +03:00
|
|
|
import org.gradle.api.Project
|
2020-05-04 19:57:27 +03:00
|
|
|
import org.gradle.api.artifacts.Configuration
|
|
|
|
import org.gradle.api.artifacts.ProjectDependency
|
2019-07-24 15:03:12 +03:00
|
|
|
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
2020-05-04 19:57:27 +03:00
|
|
|
import org.gradle.api.tasks.Copy
|
2019-07-24 15:03:12 +03:00
|
|
|
import org.gradle.kotlin.dsl.maven
|
|
|
|
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
2020-03-14 14:42:11 +03:00
|
|
|
import java.io.File
|
2019-07-24 15:03:12 +03:00
|
|
|
|
|
|
|
internal fun LanguageSettingsBuilder.applySettings(): Unit {
|
|
|
|
progressiveMode = true
|
2020-04-07 12:49:40 +03:00
|
|
|
enableLanguageFeature("InlineClasses")
|
2019-12-01 19:59:29 +03:00
|
|
|
useExperimentalAnnotation("kotlin.Experimental")
|
2019-09-12 09:42:08 +03:00
|
|
|
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
|
|
|
useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
|
|
|
useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
2020-08-31 12:40:13 +03:00
|
|
|
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
2019-07-24 15:03:12 +03:00
|
|
|
}
|
|
|
|
|
2020-03-14 14:42:11 +03:00
|
|
|
internal fun RepositoryHandler.applyRepos(): Unit {
|
2019-07-24 15:03:12 +03:00
|
|
|
mavenCentral()
|
|
|
|
jcenter()
|
|
|
|
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
2020-09-09 10:18:00 +03:00
|
|
|
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
2019-07-24 15:03:12 +03:00
|
|
|
maven("https://kotlin.bintray.com/kotlinx")
|
2020-08-20 10:02:28 +03:00
|
|
|
maven("https://kotlin.bintray.com/kotlin-js-wrappers/")
|
|
|
|
maven("https://dl.bintray.com/mipt-npm/kscience")
|
2019-07-24 15:03:12 +03:00
|
|
|
maven("https://dl.bintray.com/mipt-npm/dev")
|
2019-10-04 17:50:48 +03:00
|
|
|
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
2020-03-14 14:42:11 +03:00
|
|
|
}
|
|
|
|
|
2020-05-04 19:57:27 +03:00
|
|
|
|
|
|
|
internal fun Copy.copyJSResources(configuration: Configuration): Unit = project.afterEvaluate {
|
|
|
|
val projectDeps = configuration
|
|
|
|
.allDependencies
|
|
|
|
.filterIsInstance<ProjectDependency>()
|
|
|
|
.map { it.dependencyProject }
|
|
|
|
|
|
|
|
val destination = destinationDir
|
|
|
|
|
|
|
|
projectDeps.forEach { dep ->
|
|
|
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
|
|
|
dep.tasks.findByName("jsProcessResources")?.let { task ->
|
|
|
|
val sourceDir = (task as Copy).destinationDir
|
|
|
|
inputs.files(sourceDir)
|
|
|
|
dependsOn(task)
|
|
|
|
from(sourceDir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
|
|
|
dep.tasks.findByName("processResources")?.let { task ->
|
|
|
|
val sourceDir = (task as Copy).destinationDir
|
|
|
|
inputs.files(sourceDir)
|
|
|
|
dependsOn(task)
|
|
|
|
from(sourceDir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-06 09:52:54 +03:00
|
|
|
internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate {
|
|
|
|
val projectDeps = configuration
|
|
|
|
.allDependencies
|
|
|
|
.filterIsInstance<ProjectDependency>()
|
|
|
|
.map { it.dependencyProject }
|
|
|
|
|
|
|
|
val destination = destinationDir
|
|
|
|
|
|
|
|
projectDeps.forEach { dep ->
|
|
|
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
|
|
|
dep.tasks.findByName("jvmProcessResources")?.let { task ->
|
|
|
|
val sourceDir = (task as Copy).destinationDir
|
|
|
|
inputs.files(sourceDir)
|
|
|
|
dependsOn(task)
|
|
|
|
from(sourceDir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
|
|
|
dep.tasks.findByName("processResources")?.let { task ->
|
|
|
|
val sourceDir = (task as Copy).destinationDir
|
|
|
|
inputs.files(sourceDir)
|
|
|
|
dependsOn(task)
|
|
|
|
from(sourceDir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-04 19:57:27 +03:00
|
|
|
|
2020-03-14 14:42:11 +03:00
|
|
|
val Project.jsDistDirectory: File
|
|
|
|
get() {
|
|
|
|
val distributionName = listOf(
|
|
|
|
name,
|
|
|
|
"js",
|
|
|
|
version.toString()
|
|
|
|
).joinToString("-")
|
|
|
|
|
|
|
|
return buildDir.resolve(
|
2020-03-16 20:56:23 +03:00
|
|
|
"distributions/$distributionName"
|
2020-03-14 14:42:11 +03:00
|
|
|
)
|
|
|
|
}
|