Move Kotlin R8 optimization test resources

This CL moves the resources for tests com.android.tools.r8.kotlin.*
from the examplesKotlin directory into its own module.

In the future, we will also compile these tests with the Kotlin 1.8
backend. However the resources in examplesKotlin directory are also
compiled to .dex files with dx which cannot handle 1.8 output files
without desugaring.

Finally, we no longer compile the test resources to dex using gradle
because it's only used to compare runtime execution output. We will
compare with Java execution output instead.

Change-Id: I7a5e88643a1e5431bcdffaf84a5c0505491c2aa0
diff --git a/build.gradle b/build.gradle
index e0d28fa..d0a5968 100644
--- a/build.gradle
+++ b/build.gradle
@@ -179,6 +179,12 @@
             ]
         }
     }
+    kotlinR8TestResources {
+        java {
+            srcDirs = ['src/test/kotlinR8TestResources']
+        }
+        output.resourcesDir = 'build/classes/kotlinR8TestResources'
+    }
 }
 
 configurations {
@@ -226,6 +232,7 @@
     apiUsageSampleCompile sourceSets.main.output
     debugTestResourcesKotlinCompileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.2.0'
     examplesKotlinCompileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.2.0'
+    kotlinR8TestResourcesCompileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.2.0'
     apt 'com.google.auto.value:auto-value:1.5'
 }
 
@@ -1133,6 +1140,19 @@
     }
 }
 
+task buildKotlinR8TestResources {
+    def examplesDir = file("src/test/kotlinR8TestResources")
+    examplesDir.eachDir { dir ->
+        def name = dir.getName()
+        def taskName = "jar_kotlinR8TestResources_${name}"
+        task "${taskName}"(type: kotlin.Kotlinc) {
+            source = fileTree(dir: file("${examplesDir}/${name}"), include: '**/*.kt')
+            destination = file("build/test/kotlinR8TestResources/${name}.jar")
+        }
+        dependsOn taskName
+    }
+}
+
 task buildExamples {
     if (OperatingSystem.current().isMacOsX() || OperatingSystem.current().isWindows()) {
         logger.lifecycle("WARNING: Testing (including building examples) is only partially supported on your " +
@@ -1359,6 +1379,7 @@
         dependsOn downloadDeps
         dependsOn buildExamples
         dependsOn buildExamplesKotlin
+        dependsOn buildKotlinR8TestResources
         dependsOn buildSmali
         dependsOn jctfCommonJar
         dependsOn jctfTestsClasses