Repository: square/anvil
Issue: generateDaggerFactories doesn't seem to work on windows (?)

https://github.com/ursusursus/AnvilRepro

:base contains the flag, and has removed the dagger compiler, and kapt altogether
dagger compiler and kapt is still present in :app

I think this is the correct usage, and therefore a bug in the library

```
> Task :base:compileDebugKotlin FAILED
e: C:\\Users\\ursus\\AndroidStudioProjects\\MyApplication9\\base\\build\\anvil\\src-gen-compileDebugKotlin\\sk\\foo\\base\\di\\BaseModule_BarFactory.kt: (8, 14): Unresolved reference: annotation
e: C:\\Users\\ursus\\AndroidStudioProjects\\MyApplication9\\base\\build\\anvil\\src-gen-compileDebugKotlin\\sk\\foo\\base\\di\\BaseModule_BarFactory.kt: (16, 2): Unresolved reference: Generated
```

In my real project I kept getting

```
error: incompatible types: NonExistentClass cannot be converted to Annotation` 
```
on a similar setup

Changed files:
compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt
compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt
compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt
compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt
compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt

diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt
index 27dd438..f98bb07 100644
--- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt
+++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KotlinPoet.kt
@@ -12,7 +12,6 @@ import com.squareup.kotlinpoet.FileSpec
 import com.squareup.kotlinpoet.ParameterizedTypeName
 import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
 import com.squareup.kotlinpoet.TypeName
-import com.squareup.kotlinpoet.TypeSpec
 import com.squareup.kotlinpoet.TypeVariableName
 import com.squareup.kotlinpoet.asClassName
 import com.squareup.kotlinpoet.jvm.jvmSuppressWildcards
@@ -27,7 +26,6 @@ import org.jetbrains.kotlin.psi.KtTypeProjection
 import org.jetbrains.kotlin.psi.KtTypeReference
 import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
 import java.io.ByteArrayOutputStream
-import javax.annotation.Generated
 import javax.inject.Provider
 
 internal fun KtClassOrObject.asTypeName(): TypeName = requireFqName().asTypeName()
@@ -139,9 +137,11 @@ internal fun <T : KtCallableDeclaration> TypeName.withJvmSuppressWildcardsIfNeed
 // Notice the empty member. Instead of generating `@JvmSuppressWildcards Type` it generates
 // `@JvmSuppressWildcards() Type`. This is necessary to avoid KT-31734 where the type is a function.
 private fun TypeName.jvmSuppressWildcardsKt31734() =
-  copy(annotations = this.annotations + AnnotationSpec.builder(JvmSuppressWildcards::class)
-    .addMember("")
-    .build())
+  copy(
+      annotations = this.annotations + AnnotationSpec.builder(JvmSuppressWildcards::class)
+          .addMember("")
+          .build()
+  )
 
 internal fun List<Parameter>.asArgumentList(
   asProvider: Boolean,
@@ -180,13 +180,12 @@ private fun TypeName.wrapInLazy(): ParameterizedTypeName {
   return Lazy::class.asClassName().parameterizedBy(this)
 }
 
-internal fun TypeSpec.Builder.addAnvilAnnotation(): TypeSpec.Builder {
-  return addAnnotation(
-      AnnotationSpec.builder(Generated::class)
-          .addMember("value = [%S]", AnvilComponentRegistrar::class.java.canonicalName)
-          .addMember("comments = %S", "https://github.com/square/anvil")
-          .build()
-  )
+internal fun String.addGeneratedByComment(): String {
+  return """
+  // Generated by ${AnvilComponentRegistrar::class.java.canonicalName}
+  // https://github.com/square/anvil
+  
+  """.trimIndent() + this
 }
 
 internal fun FileSpec.writeToString(): String {
diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt
index 385cc19..af65518 100644
--- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt
+++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt
@@ -2,7 +2,7 @@ package com.squareup.anvil.compiler.codegen.dagger
 
 import com.squareup.anvil.compiler.codegen.CodeGenerator
 import com.squareup.anvil.compiler.codegen.CodeGenerator.GeneratedFile
-import com.squareup.anvil.compiler.codegen.addAnvilAnnotation
+import com.squareup.anvil.compiler.codegen.addGeneratedByComment
 import com.squareup.anvil.compiler.codegen.asArgumentList
 import com.squareup.anvil.compiler.codegen.asTypeName
 import com.squareup.anvil.compiler.codegen.classesAndInnerClasses
@@ -68,7 +68,6 @@ internal class InjectConstructorFactoryGenerator : CodeGenerator {
         .addType(
             TypeSpec
                 .classBuilder(factoryClass)
-                .addAnvilAnnotation()
                 .addSuperinterface(Factory::class.asClassName().parameterizedBy(classType))
                 .apply {
                   if (parameters.isNotEmpty()) {
@@ -168,6 +167,7 @@ internal class InjectConstructorFactoryGenerator : CodeGenerator {
         .build()
         .writeToString()
         .replaceImports(clazz)
+        .addGeneratedByComment()
 
     val directory = File(codeGenDir, packageName.replace('.', File.separatorChar))
     val file = File(directory, "$className.kt")
diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt
index 40a8a17..a9f7c0b 100644
--- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt
+++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt
@@ -2,7 +2,7 @@ package com.squareup.anvil.compiler.codegen.dagger
 
 import com.squareup.anvil.compiler.codegen.CodeGenerator
 import com.squareup.anvil.compiler.codegen.CodeGenerator.GeneratedFile
-import com.squareup.anvil.compiler.codegen.addAnvilAnnotation
+import com.squareup.anvil.compiler.codegen.addGeneratedByComment
 import com.squareup.anvil.compiler.codegen.asTypeName
 import com.squareup.anvil.compiler.codegen.classesAndInnerClasses
 import com.squareup.anvil.compiler.codegen.hasAnnotation
@@ -88,7 +88,6 @@ internal class MembersInjectorGenerator : CodeGenerator {
         .addType(
             TypeSpec
                 .classBuilder(memberInjectorClass)
-                .addAnvilAnnotation()
                 .addSuperinterface(MembersInjector::class.asClassName().parameterizedBy(classType))
                 .apply {
                   primaryConstructor(
@@ -179,6 +178,7 @@ internal class MembersInjectorGenerator : CodeGenerator {
         .build()
         .writeToString()
         .replaceImports(clazz)
+        .addGeneratedByComment()
 
     val directory = File(codeGenDir, packageName.replace('.', File.separatorChar))
     val file = File(directory, "$className.kt")
diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt
index e801ecf..3901c06 100644
--- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt
+++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt
@@ -2,7 +2,7 @@ package com.squareup.anvil.compiler.codegen.dagger
 
 import com.squareup.anvil.compiler.codegen.CodeGenerator
 import com.squareup.anvil.compiler.codegen.CodeGenerator.GeneratedFile
-import com.squareup.anvil.compiler.codegen.addAnvilAnnotation
+import com.squareup.anvil.compiler.codegen.addGeneratedByComment
 import com.squareup.anvil.compiler.codegen.asArgumentList
 import com.squareup.anvil.compiler.codegen.asTypeName
 import com.squareup.anvil.compiler.codegen.classesAndInnerClasses
@@ -105,8 +105,7 @@ internal class ProvidesMethodFactoryGenerator : CodeGenerator {
             TypeSpec.classBuilder(factoryClass)
           }
 
-          classBuilder.addAnvilAnnotation()
-              .addSuperinterface(Factory::class.asClassName().parameterizedBy(returnType))
+          classBuilder.addSuperinterface(Factory::class.asClassName().parameterizedBy(returnType))
               .apply {
                 if (!canGenerateAnObject) {
                   primaryConstructor(
@@ -241,6 +240,7 @@ internal class ProvidesMethodFactoryGenerator : CodeGenerator {
         .build()
         .writeToString()
         .replaceImports(clazz)
+        .addGeneratedByComment()
 
     val directory = File(codeGenDir, packageName.replace('.', File.separatorChar))
     val file = File(directory, "$className.kt")
diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt b/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt
index 204d586..fb0e66d 100644
--- a/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt
+++ b/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt
@@ -10,6 +10,7 @@ import dagger.Component
 import dagger.Module
 import dagger.Subcomponent
 import dagger.internal.codegen.ComponentProcessor
+import org.jetbrains.kotlin.config.JvmTarget
 import org.jetbrains.kotlin.name.FqName
 import org.junit.Assume.assumeTrue
 import java.io.File
@@ -27,6 +28,7 @@ internal fun compile(
         compilerPlugins = listOf(AnvilComponentRegistrar())
         useIR = false
         inheritClassPath = true
+        jvmTarget = JvmTarget.JVM_1_8.description
 
         if (enableDaggerAnnotationProcessor) {
           annotationProcessors = listOf(ComponentProcessor())