Skip to content

Commit

Permalink
#535 remove unused fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ExNDY committed Dec 15, 2023
1 parent d473e3d commit cf20b2f
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ abstract class AssetsGenerator(

override fun createJsGenerator(): AssetsGenerator = JsAssetsGenerator(
ownResourcesFileTree = settings.ownResourcesFileTree,
lowerResourcesFileTree = settings.lowerResourcesFileTree,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ abstract class ColorsGenerator(
)

override fun createJsGenerator(): ColorsGenerator = JsColorsGenerator(
project = project,
resourcesFileTree = settings.ownResourcesFileTree,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import org.gradle.api.file.FileTree
import java.io.File

abstract class FilesGenerator(
project: Project,
private val inputFileTree: FileTree
private val inputFileTree: FileTree,
) : MRGenerator.Generator {

override val inputFiles: Iterable<File> get() = inputFileTree.files
override val inputFiles: Iterable<File>
get() = inputFileTree.matching { it.include("files/**") }
override val resourceClassName = ClassName("dev.icerock.moko.resources", "FileResource")
override val mrObjectName: String = "files"

Expand Down Expand Up @@ -66,7 +66,7 @@ abstract class FilesGenerator(
override fun getImports(): List<ClassName> = emptyList()

private fun generateFileProperty(
fileSpec: FileSpec
fileSpec: FileSpec,
): PropertySpec {
@Suppress("SpreadOperator")
return PropertySpec.builder(fileSpec.key, resourceClassName)
Expand All @@ -79,12 +79,12 @@ abstract class FilesGenerator(

protected open fun beforeGenerate(
objectBuilder: TypeSpec.Builder,
files: List<FileSpec>
files: List<FileSpec>,
) = Unit

protected open fun generateResources(
resourcesGenerationDir: File,
files: List<FileSpec>
files: List<FileSpec>,
) = Unit

private fun processKey(key: String): String {
Expand All @@ -99,46 +99,33 @@ abstract class FilesGenerator(

data class FileSpec(
val key: String,
val file: File
val file: File,
)

class Feature(
val project: Project,
private val settings: MRGenerator.Settings
private val settings: MRGenerator.Settings,
) : ResourceGeneratorFeature<FilesGenerator> {

// private val fileTree: FileTree = settings.ownResourcesFileTree
// .matching { it.include("files/**") }

override fun createCommonGenerator(): FilesGenerator = CommonFilesGenerator(
project = project,
ownInputFileTree = settings.ownResourcesFileTree,
upperInputFileTree = settings.upperResourcesFileTree
)

override fun createAppleGenerator(): FilesGenerator = AppleFilesGenerator(
project = project,
ownInputFileTree = settings.ownResourcesFileTree,
lowerInputFileTree = settings.lowerResourcesFileTree
)

override fun createAndroidGenerator(): FilesGenerator = AndroidFilesGenerator(
project = project,
ownInputFileTree = settings.ownResourcesFileTree,
lowerInputFileTree = settings.lowerResourcesFileTree,
androidRClassPackage = settings.androidRClassPackage,
)

override fun createJsGenerator(): FilesGenerator = JsFilesGenerator(
project = project,
ownInputFileTree = settings.ownResourcesFileTree,
lowerInputFileTree = settings.lowerResourcesFileTree
)

override fun createJvmGenerator(): FilesGenerator = JvmFilesGenerator(
project = project,
ownInputFileTree = settings.ownResourcesFileTree,
lowerInputFileTree = settings.lowerResourcesFileTree,
settings = settings
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ abstract class FontsGenerator(

override fun createJsGenerator(): FontsGenerator = JsFontsGenerator(
ownInputFileTree = settings.ownResourcesFileTree,
lowerInputFileTree = settings.lowerResourcesFileTree,
mrClassPackage = settings.packageName
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ import com.squareup.kotlinpoet.KModifier
import dev.icerock.gradle.generator.FilesGenerator
import dev.icerock.gradle.generator.NOPObjectBodyExtendable
import dev.icerock.gradle.generator.ObjectBodyExtendable
import org.gradle.api.Project
import org.gradle.api.file.FileTree
import org.gradle.api.provider.Provider
import java.io.File
import java.util.Locale

class AndroidFilesGenerator(
project: Project,
ownInputFileTree: FileTree,
lowerInputFileTree: FileTree,
private val androidRClassPackage: Provider<String>,
) : FilesGenerator(project, ownInputFileTree), ObjectBodyExtendable by NOPObjectBodyExtendable() {
) : FilesGenerator(ownInputFileTree), ObjectBodyExtendable by NOPObjectBodyExtendable() {
override fun getClassModifiers(): Array<KModifier> = arrayOf(KModifier.ACTUAL)

override fun getPropertyModifiers(): Array<KModifier> = arrayOf(KModifier.ACTUAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import com.squareup.kotlinpoet.CodeBlock
import com.squareup.kotlinpoet.KModifier
import dev.icerock.gradle.generator.FilesGenerator
import dev.icerock.gradle.generator.ObjectBodyExtendable
import org.gradle.api.Project
import org.gradle.api.file.FileTree
import java.io.File

class AppleFilesGenerator(
project: Project,
ownInputFileTree: FileTree,
lowerInputFileTree: FileTree,
) : FilesGenerator(project, inputFileTree = ownInputFileTree), ObjectBodyExtendable by AppleGeneratorHelper() {
) : FilesGenerator(inputFileTree = ownInputFileTree), ObjectBodyExtendable by AppleGeneratorHelper() {

override fun getClassModifiers(): Array<KModifier> = arrayOf(KModifier.ACTUAL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import com.squareup.kotlinpoet.KModifier
import dev.icerock.gradle.generator.FilesGenerator
import dev.icerock.gradle.generator.NOPObjectBodyExtendable
import dev.icerock.gradle.generator.ObjectBodyExtendable
import org.gradle.api.Project
import org.gradle.api.file.FileTree

class CommonFilesGenerator(
project: Project,
ownInputFileTree: FileTree,
upperInputFileTree: FileTree,
) : FilesGenerator(project, ownInputFileTree), ObjectBodyExtendable by NOPObjectBodyExtendable() {
) : FilesGenerator(ownInputFileTree), ObjectBodyExtendable by NOPObjectBodyExtendable() {
override fun getClassModifiers(): Array<KModifier> = emptyArray()

override fun getPropertyModifiers(): Array<KModifier> = emptyArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import java.io.File

class JsAssetsGenerator(
ownResourcesFileTree: FileTree,
lowerResourcesFileTree: FileTree,
) : AssetsGenerator(ownResourcesFileTree), ObjectBodyExtendable by NOPObjectBodyExtendable() {

override fun getClassModifiers(): Array<KModifier> = arrayOf(KModifier.ACTUAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import dev.icerock.gradle.generator.ColorsGenerator
import dev.icerock.gradle.generator.NOPObjectBodyExtendable
import dev.icerock.gradle.generator.ObjectBodyExtendable
import dev.icerock.gradle.generator.jsJvmCommon.createColorResourceInitializer
import org.gradle.api.Project
import org.gradle.api.file.FileTree

class JsColorsGenerator(
project: Project,
resourcesFileTree: FileTree,
) : ColorsGenerator(resourcesFileTree), ObjectBodyExtendable by NOPObjectBodyExtendable() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ import com.squareup.kotlinpoet.TypeSpec
import dev.icerock.gradle.generator.FilesGenerator
import dev.icerock.gradle.generator.NOPObjectBodyExtendable
import dev.icerock.gradle.generator.ObjectBodyExtendable
import org.gradle.api.Project
import org.gradle.api.file.FileTree
import java.io.File

class JsFilesGenerator(
project: Project,
ownInputFileTree: FileTree,
lowerInputFileTree: FileTree,
) : FilesGenerator(project,ownInputFileTree), ObjectBodyExtendable by NOPObjectBodyExtendable() {
) : FilesGenerator(
inputFileTree = ownInputFileTree
), ObjectBodyExtendable by NOPObjectBodyExtendable() {

override fun getClassModifiers(): Array<KModifier> = arrayOf(KModifier.ACTUAL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import java.io.File

class JsFontsGenerator(
ownInputFileTree: FileTree,
lowerInputFileTree: FileTree,
mrClassPackage: String,
) : FontsGenerator(ownInputFileTree), ObjectBodyExtendable by NOPObjectBodyExtendable() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ import com.squareup.kotlinpoet.KModifier
import dev.icerock.gradle.generator.FilesGenerator
import dev.icerock.gradle.generator.MRGenerator
import dev.icerock.gradle.generator.ObjectBodyExtendable
import org.gradle.api.Project
import org.gradle.api.file.FileTree
import java.io.File

class JvmFilesGenerator(
project: Project,
ownInputFileTree: FileTree,
lowerInputFileTree: FileTree,
settings: MRGenerator.Settings
) : FilesGenerator(project, ownInputFileTree),
settings: MRGenerator.Settings,
) : FilesGenerator(ownInputFileTree),
ObjectBodyExtendable by ClassLoaderExtender(settings.className) {

override fun getClassModifiers(): Array<KModifier> = arrayOf(KModifier.ACTUAL)
Expand All @@ -32,7 +29,7 @@ class JvmFilesGenerator(

override fun generateResources(
resourcesGenerationDir: File,
files: List<FileSpec>
files: List<FileSpec>,
) {
val fileResDir = File(resourcesGenerationDir, FILES_DIR).apply { mkdirs() }
files.forEach { fileSpec ->
Expand Down

0 comments on commit cf20b2f

Please sign in to comment.