-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support test resources in Compose UI tests. (#5122)
1) The PR adds a support test resources in Compose multiplatform projects. 2) The PR adds a support multi-module resources in JVM-only projects. Fixes https://youtrack.jetbrains.com/issue/CMP-1470 Fixes https://youtrack.jetbrains.com/issue/CMP-5963 ## Release Notes ### Features - Resources - Added support of test resources in Compose Multiplatform projects - Added support of multi-module resources in JVM-only projects
- Loading branch information
Showing
25 changed files
with
518 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ns/compose/src/main/kotlin/org/jetbrains/compose/resources/AssembleTargetResourcesTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.jetbrains.compose.resources | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.ConfigurableFileCollection | ||
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.file.DuplicatesStrategy | ||
import org.gradle.api.file.FileSystemOperations | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputFiles | ||
import org.gradle.api.tasks.OutputDirectory | ||
import org.gradle.api.tasks.PathSensitive | ||
import org.gradle.api.tasks.PathSensitivity | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.work.DisableCachingByDefault | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
@DisableCachingByDefault(because = "There is no logic, just copy files") | ||
internal abstract class AssembleTargetResourcesTask : DefaultTask() { | ||
|
||
@get:Inject | ||
abstract val fileSystem: FileSystemOperations | ||
|
||
@get:InputFiles | ||
@get:PathSensitive(PathSensitivity.RELATIVE) | ||
abstract val resourceDirectories: ConfigurableFileCollection | ||
|
||
@get:Input | ||
abstract val relativeResourcePlacement: Property<File> | ||
|
||
@get:OutputDirectory | ||
abstract val outputDirectory: DirectoryProperty | ||
|
||
@TaskAction | ||
fun action() { | ||
val outputDirectoryFile = outputDirectory.get().asFile | ||
if (outputDirectoryFile.exists()) { | ||
outputDirectoryFile.deleteRecursively() | ||
} | ||
outputDirectoryFile.mkdirs() | ||
|
||
fileSystem.copy { copy -> | ||
resourceDirectories.files.forEach { dir -> | ||
copy.from(dir) | ||
} | ||
copy.into(outputDirectoryFile.resolve(relativeResourcePlacement.get())) | ||
copy.duplicatesStrategy = DuplicatesStrategy.INCLUDE | ||
} | ||
|
||
if (outputDirectoryFile.listFiles()?.isEmpty() != false) { | ||
// Output an empty directory for the zip task | ||
outputDirectoryFile.resolve(relativeResourcePlacement.get()).mkdirs() | ||
} | ||
} | ||
} |
Oops, something went wrong.