Skip to content

Commit

Permalink
Update Anvil to fix gradle cache issues (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
denys-vasylenko committed Feb 20, 2024
1 parent bf781a2 commit 0ff5edb
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ android.nonTransitiveRClass=true
# Build Features
android.defaults.buildfeatures.buildconfig=false
android.defaults.buildfeatures.resvalues=false
com.squareup.anvil.trackSourceFiles=true
# Library Information
GROUP=com.deliveryhero.whetstone
VERSION_NAME=0.7.0-SNAPSHOT
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
androidGradle = "8.1.0"
androidxActivity = "1.5.0"
androidxAppCompat = "1.3.1"
androidxCompose = "1.5.3"
androidxComposeCompiler = "1.5.3"
androidxCompose = "1.6.1"
androidxComposeCompiler = "1.5.9"
androidxCore = "1.7.0"
androidxFragment = "1.5.0"
androidxLifecycle = "2.5.0"
androidxWork = "2.7.0"
anvil = "2.4.8"
dagger = "2.48.1"
kotlin = "1.9.10"
anvil = "2.5.0-beta01"
dagger = "2.50"
kotlin = "1.9.22"
kotlinxCoroutines = "1.6.4"
mavenPublish = "0.25.3"
truth = "1.1.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.deliveryhero.whetstone.compiler

import java.io.File

internal class GeneratedFileInfo(
val packageName: String,
val fileName: String,
val content: String
val content: String,
val sourceFile: File,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.deliveryhero.whetstone.compiler
import com.google.auto.service.AutoService
import com.squareup.anvil.compiler.api.AnvilContext
import com.squareup.anvil.compiler.api.CodeGenerator
import com.squareup.anvil.compiler.api.GeneratedFile
import com.squareup.anvil.compiler.api.GeneratedFileWithSources
import com.squareup.anvil.compiler.api.createGeneratedFile
import com.squareup.anvil.compiler.internal.reference.classAndInnerClassReferences
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
Expand All @@ -21,11 +21,18 @@ public class WhetstoneCodeGenerator : CodeGenerator {
codeGenDir: File,
module: ModuleDescriptor,
projectFiles: Collection<KtFile>
): Collection<GeneratedFile> {
): Collection<GeneratedFileWithSources> {
return projectFiles
.classAndInnerClassReferences(module)
.flatMap { clas -> codegenHandlers.mapNotNull { it.processClass(clas, module) } }
.map { info -> createGeneratedFile(codeGenDir, info.packageName, info.fileName, info.content) }
.toList()
.map { info ->
createGeneratedFile(
codeGenDir = codeGenDir,
packageName = info.packageName,
fileName = info.fileName,
content = info.content,
sourceFiles = setOf(info.sourceFile),
)
}.toList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal class AppComponentHandler : CodegenHandler {
writeAppComponent(module, packageName, outputFileName)
}

return GeneratedFileInfo(packageName, outputFileName, content)
return GeneratedFileInfo(packageName, outputFileName, content, clas.containingFileAsJavaFile)
}

private fun FileSpec.Builder.writeAppComponent(module: ModuleDescriptor, packageName: String, className: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internal class BindingsModuleHandler : CodegenHandler {
addType(moduleInterfaceSpec)
}

return GeneratedFileInfo(packageName, outputFileName, content)
return GeneratedFileInfo(packageName, outputFileName, content, clas.containingFileAsJavaFile)
}

private fun <K, V> MutableMap<K, V?>.getOrPutNullable(key: K, func: () -> V?): V? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface ApplicationModule {

@Binds
@ForScope(ApplicationScope::class)
public fun Application.bindContext(): Context
public fun bindContext(application: Application): Context

@Multibinds
public fun membersInjectors(): MembersInjectorMap
Expand Down

0 comments on commit 0ff5edb

Please sign in to comment.