@@ -54,39 +54,80 @@ tasks.withType<IncrementalSyncTask>().configureEach {
5454 }
5555}
5656
57+ // work-around for missing feature in dependencies block added in Gradle 8.3
58+ // val setupWsl by configurations.registering {
59+ val setupWslExecutable by configurations.creating {
60+ isCanBeConsumed = false
61+ isCanBeResolved = false
62+ isVisible = false
63+ }
64+
65+ val setupWslExecutableFile by configurations.registering {
66+ isCanBeConsumed = false
67+ isCanBeResolved = true
68+ isVisible = false
69+ extendsFrom(setupWslExecutable)
70+ }
71+
72+ dependencies {
73+ setupWslExecutable(project(path = " :" , configuration = " executable" ))
74+ }
75+
5776// work-around for https://youtrack.jetbrains.com/issue/KT-56305
5877tasks.withType<NodeJsExec >().configureEach {
59- abstract class ArgumentProvider @Inject constructor(rootProject : Project ) : CommandLineArgumentProvider {
78+ val output by extra {
79+ layout.buildDirectory.dir(" distributions/$name " )
80+ }
81+
82+ abstract class ArgumentProvider @Inject constructor(
83+ setupWslExecutableFile : Provider <File >,
84+ destinationDirectory : Provider <Directory >
85+ ) : CommandLineArgumentProvider {
6086 @get:InputFile
61- @get:SkipWhenEmpty
6287 abstract val input: RegularFileProperty
6388
6489 @get:OutputDirectory
65- abstract val output : DirectoryProperty
90+ abstract val destinationDirectory : DirectoryProperty
6691
6792 init {
68- input.fileProvider(
69- rootProject
70- .tasks
71- .named<IncrementalSyncTask >(" jsProductionExecutableCompileSync" )
72- .map {
73- it
74- .outputs
75- .files
76- .asFileTree
77- .matching { include(" ${rootProject.name} .js" ) }
78- .singleFile
79- }
80- )
81-
82- output.set(rootProject.layout.buildDirectory.dir(" distributions" ))
93+ input.fileProvider(setupWslExecutableFile)
94+ this .destinationDirectory.set(destinationDirectory)
8395 }
8496
85- override fun asArguments (): MutableIterable <String > =
86- mutableListOf (
97+ override fun asArguments (): Iterable <String > =
98+ listOf (
8799 input.get().asFile.absolutePath,
88- output .get().asFile.absolutePath
100+ destinationDirectory .get().asFile.absolutePath
89101 )
90102 }
91- argumentProviders.add(objects.newInstance<ArgumentProvider >(rootProject))
103+
104+ argumentProviders.add(
105+ objects.newInstance<ArgumentProvider >(
106+ setupWslExecutableFile
107+ .flatMap { it.elements }
108+ .map { it.single().asFile },
109+ output
110+ )
111+ )
112+
113+ doFirst {
114+ output.get().asFile.deleteRecursively()
115+ }
116+ }
117+
118+ val setupWslDistribution by configurations.registering {
119+ isCanBeConsumed = true
120+ isCanBeResolved = false
121+ isVisible = false
122+ }
123+
124+ artifacts {
125+ val jsNodeProductionRun by tasks.existing
126+ add(
127+ setupWslDistribution.name,
128+ jsNodeProductionRun.map {
129+ val output: Provider <Directory > by it.extra
130+ output.get()
131+ }
132+ )
92133}
0 commit comments