Skip to content

Commit 2c048d3

Browse files
committed
Adopt Compose wasm multi module compilation.
Use stable versions of compose
1 parent ced957c commit 2c048d3

File tree

16 files changed

+389
-327
lines changed

16 files changed

+389
-327
lines changed

build.gradle.kts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ setOf(
3939
}
4040
}
4141

42-
val kotlinComposeWasmStdlibFile: Configuration by configurations.creating {
42+
val kotlinComposeWasmRuntime: Configuration by configurations.creating {
4343
isTransitive = false
4444
isCanBeResolved = true
4545
isCanBeConsumed = false
@@ -48,10 +48,6 @@ val kotlinComposeWasmStdlibFile: Configuration by configurations.creating {
4848
Category.CATEGORY_ATTRIBUTE,
4949
objects.categoryComposeCache
5050
)
51-
attribute(
52-
CacheAttribute.cacheAttribute,
53-
CacheAttribute.WASM
54-
)
5551
}
5652
}
5753

@@ -93,7 +89,7 @@ dependencies {
9389
}
9490
testImplementation(libs.kotlinx.coroutines.test)
9591

96-
kotlinComposeWasmStdlibFile(project(":cache-maker"))
92+
kotlinComposeWasmRuntime(project(":cache-maker"))
9793
composeWasmStaticResources(project(":resource-server"))
9894
}
9995

@@ -121,26 +117,20 @@ fun Project.generateProperties(
121117
)
122118

123119
val propertiesGenerator by tasks.registering(PropertiesGenerator::class) {
124-
dependsOn(kotlinComposeWasmStdlibFile)
120+
dependsOn(kotlinComposeWasmRuntime)
125121
propertiesFile.fileValue(rootDir.resolve("src/main/resources/${propertyFile}"))
126-
hashableFile.fileProvider(
127-
provider {
128-
kotlinComposeWasmStdlibFile.singleFile
129-
}
122+
hashableDir.from(
123+
kotlinComposeWasmRuntime
130124
)
131125
generateProperties().forEach { (name, value) ->
132126
propertiesMap.put(name, value)
133127
}
134128
}
135129

136130
val lambdaPropertiesGenerator by tasks.registering(PropertiesGenerator::class) {
137-
dependsOn(kotlinComposeWasmStdlibFile)
131+
dependsOn(kotlinComposeWasmRuntime)
138132
propertiesFile.set(layout.buildDirectory.file("tmp/propertiesGenerator/${propertyFile}"))
139-
hashableFile.fileProvider(
140-
provider {
141-
kotlinComposeWasmStdlibFile.singleFile
142-
}
143-
)
133+
hashableDir.from(kotlinComposeWasmRuntime)
144134

145135
generateProperties(lambdaPrefix).forEach { (name, value) ->
146136
propertiesMap.put(name, value)
@@ -186,7 +176,7 @@ val buildLambda by tasks.creating(Zip::class) {
186176
from(libJVMFolder) { into(libJVM) }
187177
from(compilerPluginsForJVMFolder) { into(compilerPluginsForJVM) }
188178
from(libComposeWasmCompilerPluginsFolder) { into(libComposeWasmCompilerPlugins) }
189-
dependsOn(kotlinComposeWasmStdlibFile)
179+
dependsOn(kotlinComposeWasmRuntime)
190180
into("lib") {
191181
from(configurations.compileClasspath) { exclude("tomcat-embed-*") }
192182
}

buildSrc/src/main/kotlin/CacheAttribute.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

buildSrc/src/main/kotlin/PropertiesUpdater.kt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import org.gradle.api.DefaultTask
2+
import org.gradle.api.file.ConfigurableFileCollection
23
import org.gradle.api.file.RegularFileProperty
34
import org.gradle.api.provider.MapProperty
4-
import org.gradle.api.tasks.Input
5-
import org.gradle.api.tasks.InputFile
6-
import org.gradle.api.tasks.OutputFile
7-
import org.gradle.api.tasks.TaskAction
5+
import org.gradle.api.tasks.*
86
import java.io.File
97
import java.io.FileInputStream
108
import java.security.MessageDigest
119

1210
abstract class PropertiesGenerator : DefaultTask() {
1311

14-
@get:InputFile
15-
abstract val hashableFile: RegularFileProperty
12+
@get:InputFiles
13+
@get:Classpath
14+
abstract val hashableDir: ConfigurableFileCollection
1615

1716
@get:Input
1817
abstract val propertiesMap: MapProperty<String, String>
@@ -34,23 +33,26 @@ abstract class PropertiesGenerator : DefaultTask() {
3433
}
3534

3635
file.appendText(
37-
"\ndependencies.compose.wasm=${hashFileContent(hashableFile.get().asFile.absolutePath)}"
36+
"\ndependencies.compose-wasm=${hashFileContent(hashableDir.singleFile)}"
3837
)
3938
}
4039
}
4140

42-
fun hashFileContent(filePath: String, hashAlgorithm: String = "SHA-256"): String {
43-
val file = File(filePath)
41+
fun hashFileContent(files: File, hashAlgorithm: String = "SHA-256"): String {
4442
val digest = MessageDigest.getInstance(hashAlgorithm)
4543

46-
// Read the file content in chunks and update the digest
47-
FileInputStream(file).use { fileInputStream ->
48-
val buffer = ByteArray(1024)
49-
var bytesRead: Int
50-
while (fileInputStream.read(buffer).also { bytesRead = it } != -1) {
51-
digest.update(buffer, 0, bytesRead)
44+
files.listFiles()
45+
.filter { it.isFile }
46+
.forEach { file ->
47+
// Read the file content in chunks and update the digest
48+
FileInputStream(file).use { fileInputStream ->
49+
val buffer = ByteArray(1024)
50+
var bytesRead: Int
51+
while (fileInputStream.read(buffer).also { bytesRead = it } != -1) {
52+
digest.update(buffer, 0, bytesRead)
53+
}
54+
}
5255
}
53-
}
5456

5557
// Convert the resulting byte array to a readable hex string
5658
return digest.digest().joinToString("") { "%02x".format(it) }

0 commit comments

Comments
 (0)