@@ -54,39 +54,80 @@ tasks.withType<IncrementalSyncTask>().configureEach {
54
54
}
55
55
}
56
56
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
+
57
76
// work-around for https://youtrack.jetbrains.com/issue/KT-56305
58
77
tasks.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 {
60
86
@get:InputFile
61
- @get:SkipWhenEmpty
62
87
abstract val input: RegularFileProperty
63
88
64
89
@get:OutputDirectory
65
- abstract val output : DirectoryProperty
90
+ abstract val destinationDirectory : DirectoryProperty
66
91
67
92
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)
83
95
}
84
96
85
- override fun asArguments (): MutableIterable <String > =
86
- mutableListOf (
97
+ override fun asArguments (): Iterable <String > =
98
+ listOf (
87
99
input.get().asFile.absolutePath,
88
- output .get().asFile.absolutePath
100
+ destinationDirectory .get().asFile.absolutePath
89
101
)
90
102
}
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
+ )
92
133
}
0 commit comments