Address Gradle warning about Task.project (#3118)
Apparently, this is all that's needed to replace the forbidden `Task.project` accessor, which would be an error in Gradle v10 (it's been deprecated for a while) This will also allow us to use the Configuration Cache if we wanted to.
This commit is contained in:
@@ -2,19 +2,24 @@ package mihon.gradle.tasks
|
|||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.file.DirectoryProperty
|
import org.gradle.api.file.DirectoryProperty
|
||||||
|
import org.gradle.api.model.ObjectFactory
|
||||||
import org.gradle.api.tasks.OutputDirectory
|
import org.gradle.api.tasks.OutputDirectory
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
abstract class GenerateLocalesConfigTask : DefaultTask() {
|
abstract class GenerateLocalesConfigTask : DefaultTask() {
|
||||||
|
|
||||||
|
@get:Inject
|
||||||
|
abstract val objectFactory: ObjectFactory
|
||||||
|
|
||||||
@get:OutputDirectory
|
@get:OutputDirectory
|
||||||
abstract val outputDir: DirectoryProperty
|
abstract val outputDir: DirectoryProperty
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun action() {
|
fun action() {
|
||||||
val locales = project.fileTree("src/commonMain/moko-resources") {
|
val locales = objectFactory.fileTree()
|
||||||
matching { include("**/strings.xml") }
|
.from("src/commonMain/moko-resources")
|
||||||
}
|
.matching { include("**/strings.xml") }
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filterNot { it.readText().contains(emptyResourcesElement) }
|
.filterNot { it.readText().contains(emptyResourcesElement) }
|
||||||
.map {
|
.map {
|
||||||
|
|||||||
Reference in New Issue
Block a user