Fix JS resource copy
This commit is contained in:
parent
774596bbf6
commit
2fc4bb1f3d
@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "ru.mipt.npm"
|
group = "ru.mipt.npm"
|
||||||
version = "0.6.2-dev-1.4.20-M1"
|
version = "0.6.3-dev-1.4.20-M1"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
@ -40,17 +40,8 @@ open class KScienceJSPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.apply {
|
tasks.apply {
|
||||||
|
val processResources by getting(Copy::class) {
|
||||||
val processResources by getting(Copy::class)
|
fromDependencies("runtimeClasspath")
|
||||||
processResources.copyJSResources(configurations["runtimeClasspath"])
|
|
||||||
|
|
||||||
findByName("jsBrowserDistribution")?.apply {
|
|
||||||
doLast {
|
|
||||||
val indexFile = project.jsDistDirectory.resolve("index.html")
|
|
||||||
if (indexFile.exists()) {
|
|
||||||
println("Run JS distribution at: ${indexFile.canonicalPath}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import org.gradle.api.Project
|
|||||||
import org.gradle.api.plugins.JavaPluginExtension
|
import org.gradle.api.plugins.JavaPluginExtension
|
||||||
import org.gradle.api.publish.PublishingExtension
|
import org.gradle.api.publish.PublishingExtension
|
||||||
import org.gradle.api.publish.maven.MavenPublication
|
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.bundling.Jar
|
||||||
import org.gradle.api.tasks.testing.Test
|
import org.gradle.api.tasks.testing.Test
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
@ -78,9 +77,9 @@ open class KScienceJVMPlugin : Plugin<Project> {
|
|||||||
withType<Test>() {
|
withType<Test>() {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
//
|
||||||
val processResources by getting(Copy::class)
|
// val processResources by getting(Copy::class)
|
||||||
processResources.copyJVMResources(configurations["runtimeClasspath"])
|
// processResources.copyJVMResources(configurations["runtimeClasspath"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,20 +89,10 @@ open class KScienceMPPlugin : Plugin<Project> {
|
|||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsProcessResources by getting(Copy::class)
|
val jsProcessResources by getting(Copy::class) {
|
||||||
jsProcessResources.copyJSResources(configurations["jsRuntimeClasspath"])
|
fromDependencies("jsRuntimeClasspath")
|
||||||
|
}
|
||||||
|
|
||||||
val jvmProcessResources by getting(Copy::class)
|
|
||||||
jvmProcessResources.copyJVMResources(configurations["jvmRuntimeClasspath"])
|
|
||||||
|
|
||||||
findByName("jsBrowserDistribution")?.apply {
|
|
||||||
doLast {
|
|
||||||
val indexFile = project.jsDistDirectory.resolve("index.html")
|
|
||||||
if (indexFile.exists()) {
|
|
||||||
println("Run JS distribution at: ${indexFile.canonicalPath}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.artifacts.Configuration
|
|
||||||
import org.gradle.api.artifacts.ProjectDependency
|
import org.gradle.api.artifacts.ProjectDependency
|
||||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||||
import org.gradle.api.tasks.Copy
|
import org.gradle.api.tasks.Copy
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
import org.gradle.kotlin.dsl.maven
|
import org.gradle.kotlin.dsl.maven
|
||||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
internal fun LanguageSettingsBuilder.applySettings(): Unit {
|
internal fun LanguageSettingsBuilder.applySettings(): Unit {
|
||||||
progressiveMode = true
|
progressiveMode = true
|
||||||
@ -31,73 +29,54 @@ internal fun RepositoryHandler.applyRepos(): Unit {
|
|||||||
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun Copy.fromDependencies(configurationName: String) = project.afterEvaluate {
|
||||||
internal fun Copy.copyJSResources(configuration: Configuration): Unit = project.afterEvaluate {
|
val configuration = configurations[configurationName]
|
||||||
val projectDeps = configuration
|
?: error("Configuration with name $configurationName could not be resolved.")
|
||||||
.allDependencies
|
val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map {
|
||||||
.filterIsInstance<ProjectDependency>()
|
it.dependencyProject
|
||||||
.map { it.dependencyProject }
|
}
|
||||||
|
into(buildDir.resolve("processedResources/js"))
|
||||||
val destination = destinationDir
|
|
||||||
|
|
||||||
projectDeps.forEach { dep ->
|
projectDeps.forEach { dep ->
|
||||||
|
dep.afterEvaluate {
|
||||||
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
dep.tasks.findByName("jsProcessResources")?.let { task ->
|
dep.tasks.findByName("jsProcessResources")?.let { task ->
|
||||||
val sourceDir = (task as Copy).destinationDir
|
|
||||||
inputs.files(sourceDir)
|
|
||||||
dependsOn(task)
|
dependsOn(task)
|
||||||
from(sourceDir)
|
from(task)
|
||||||
|
//from(dep.buildDir.resolve("processedResources/js"))
|
||||||
}
|
}
|
||||||
|
//from(dep.buildDir.resolve("processedResources/js"))
|
||||||
}
|
}
|
||||||
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
dep.tasks.findByName("processResources")?.let { task ->
|
dep.tasks.findByName("processResources")?.let { task ->
|
||||||
val sourceDir = (task as Copy).destinationDir
|
|
||||||
inputs.files(sourceDir)
|
|
||||||
dependsOn(task)
|
dependsOn(task)
|
||||||
from(sourceDir)
|
from(task)
|
||||||
|
//from(dep.buildDir.resolve("processedResources/js"))
|
||||||
}
|
}
|
||||||
}
|
// from(dep.buildDir.resolve("processedResources/js"))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val Project.jsDistDirectory: File
|
//
|
||||||
get() {
|
//internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate {
|
||||||
val distributionName = listOf(
|
// val projectDeps = configuration.allDependencies
|
||||||
name,
|
// .filterIsInstance<ProjectDependency>()
|
||||||
"js",
|
// .map { it.dependencyProject }
|
||||||
version.toString()
|
//
|
||||||
).joinToString("-")
|
// projectDeps.forEach { dep ->
|
||||||
|
// dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
return buildDir.resolve(
|
// dep.tasks.findByName("jvmProcessResources")?.let { task ->
|
||||||
"distributions/$distributionName"
|
// dependsOn(task)
|
||||||
)
|
// from(task)
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
// dep.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
|
// dep.tasks.findByName("processResources")?.let { task ->
|
||||||
|
// dependsOn(task)
|
||||||
|
// from(task)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
Loading…
Reference in New Issue
Block a user