[Gradle, JS] Add configureLibrary
^KT-41566 fixed
This commit is contained in:
+24
@@ -92,6 +92,30 @@ constructor(
|
||||
}
|
||||
)
|
||||
|
||||
// For Groovy DSL
|
||||
@JvmOverloads
|
||||
fun library(
|
||||
compilation: KotlinJsCompilation = defaultCompilation
|
||||
): List<JsBinary> {
|
||||
if (target is KotlinJsIrTarget) {
|
||||
target.whenBrowserConfigured {
|
||||
(this as KotlinJsIrSubTarget).produceLibrary()
|
||||
}
|
||||
|
||||
target.whenNodejsConfigured {
|
||||
(this as KotlinJsIrSubTarget).produceLibrary()
|
||||
}
|
||||
|
||||
return createBinaries(
|
||||
compilation = compilation,
|
||||
jsBinaryType = KotlinJsBinaryType.LIBRARY,
|
||||
create = ::Library
|
||||
)
|
||||
}
|
||||
|
||||
throw GradleException("Library can be produced only for IR compiler")
|
||||
}
|
||||
|
||||
internal fun getIrBinaries(
|
||||
mode: KotlinJsBinaryMode
|
||||
): DomainObjectSet<JsIrBinary> =
|
||||
|
||||
+17
-2
@@ -79,6 +79,14 @@ abstract class KotlinJsIrSubTarget(
|
||||
produceExecutable
|
||||
}
|
||||
|
||||
private val produceLibrary: Unit by lazy {
|
||||
configureLibrary()
|
||||
}
|
||||
|
||||
internal fun produceLibrary() {
|
||||
produceLibrary
|
||||
}
|
||||
|
||||
override fun testTask(body: KotlinJsTest.() -> Unit) {
|
||||
testRuns.getByName(KotlinTargetWithTests.DEFAULT_TEST_RUN_NAME).executionTask.configure(body)
|
||||
}
|
||||
@@ -176,14 +184,21 @@ abstract class KotlinJsIrSubTarget(
|
||||
private fun configureMain(compilation: KotlinJsIrCompilation) {
|
||||
configureRun(compilation)
|
||||
configureBuild(compilation)
|
||||
configureLibrary(compilation)
|
||||
}
|
||||
|
||||
protected abstract fun configureRun(compilation: KotlinJsIrCompilation)
|
||||
|
||||
protected abstract fun configureBuild(compilation: KotlinJsIrCompilation)
|
||||
|
||||
protected fun configureLibrary(compilation: KotlinJsIrCompilation) {
|
||||
private fun configureLibrary() {
|
||||
target.compilations.all { compilation ->
|
||||
if (compilation.isMain()) {
|
||||
configureLibrary(compilation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun configureLibrary(compilation: KotlinJsIrCompilation) {
|
||||
val project = compilation.target.project
|
||||
|
||||
val processResourcesTask = target.project.tasks.named(compilation.processResourcesTaskName)
|
||||
|
||||
Reference in New Issue
Block a user