diff --git a/build.gradle.kts b/build.gradle.kts index c43ecf9..55e810f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.6.2-dev-1.4.20-M1" +version = "0.6.3-dev-1.4.20-M1" repositories { gradlePluginPortal() diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt index bacfbcd..579abc6 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt @@ -40,17 +40,8 @@ open class KScienceJSPlugin : Plugin { } tasks.apply { - - val processResources by getting(Copy::class) - 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}") - } - } + val processResources by getting(Copy::class) { + fromDependencies("runtimeClasspath") } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt index 0c6d26e..f3a6d1b 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt @@ -5,7 +5,6 @@ import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginExtension 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.* @@ -78,9 +77,9 @@ open class KScienceJVMPlugin : Plugin { withType() { useJUnitPlatform() } - - val processResources by getting(Copy::class) - processResources.copyJVMResources(configurations["runtimeClasspath"]) +// +// val processResources by getting(Copy::class) +// processResources.copyJVMResources(configurations["runtimeClasspath"]) } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt index eda2baf..bebd47a 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -89,20 +89,10 @@ open class KScienceMPPlugin : Plugin { useJUnitPlatform() } - val jsProcessResources by getting(Copy::class) - jsProcessResources.copyJSResources(configurations["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}") - } - } + val jsProcessResources by getting(Copy::class) { + fromDependencies("jsRuntimeClasspath") } + } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/common.kt b/src/main/kotlin/ru/mipt/npm/gradle/common.kt index 9b33cb5..1cbfebc 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/common.kt @@ -1,13 +1,11 @@ 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.dsl.RepositoryHandler import org.gradle.api.tasks.Copy +import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.maven import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder -import java.io.File internal fun LanguageSettingsBuilder.applySettings(): Unit { progressiveMode = true @@ -31,73 +29,54 @@ internal fun RepositoryHandler.applyRepos(): Unit { maven("https://dl.bintray.com/mipt-npm/dataforge") } - -internal fun Copy.copyJSResources(configuration: Configuration): Unit = project.afterEvaluate { - val projectDeps = configuration - .allDependencies - .filterIsInstance() - .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) - } - } +internal fun Copy.fromDependencies(configurationName: String) = project.afterEvaluate { + val configuration = configurations[configurationName] + ?: error("Configuration with name $configurationName could not be resolved.") + val projectDeps = configuration.allDependencies.filterIsInstance().map { + it.dependencyProject } -} - -internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate { - val projectDeps = configuration - .allDependencies - .filterIsInstance() - .map { it.dependencyProject } - - val destination = destinationDir - + into(buildDir.resolve("processedResources/js")) 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.afterEvaluate { + dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { + dep.tasks.findByName("jsProcessResources")?.let { task -> + dependsOn(task) + from(task) + //from(dep.buildDir.resolve("processedResources/js")) + } + //from(dep.buildDir.resolve("processedResources/js")) } - } - 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) + dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") { + dep.tasks.findByName("processResources")?.let { task -> + dependsOn(task) + from(task) + //from(dep.buildDir.resolve("processedResources/js")) + } + // from(dep.buildDir.resolve("processedResources/js")) } } } } -val Project.jsDistDirectory: File - get() { - val distributionName = listOf( - name, - "js", - version.toString() - ).joinToString("-") - - return buildDir.resolve( - "distributions/$distributionName" - ) - } \ No newline at end of file +// +//internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate { +// val projectDeps = configuration.allDependencies +// .filterIsInstance() +// .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) +// } +// } +// } +//} \ No newline at end of file