Checkin generated proto example jars

Bug: b/270105162
Bug: b/291194000
Change-Id: Ie7af712272ea2548f918249a959d5e665f1e0b91
diff --git a/build.gradle b/build.gradle
index a26a459..ee9b462 100644
--- a/build.gradle
+++ b/build.gradle
@@ -161,14 +161,6 @@
         }
         output.resourcesDir = 'build/classes/examplesAndroidP'
     }
-    examplesProto {
-        java {
-            srcDirs = ['src/test/examplesProto']
-        }
-        compileClasspath = files("third_party/protobuf-lite/libprotobuf_lite.jar")
-        compileClasspath += fileTree(dir: "build/generated/test/proto", include: "*.jar")
-        output.resourcesDir = 'build/classes/examplesProto'
-    }
     kotlinR8TestResources {
         java {
             srcDirs = ['src/test/kotlinR8TestResources']
@@ -1212,55 +1204,6 @@
     targetCompatibility = JavaVersion.VERSION_1_8
 }
 
-task buildProtoGeneratedSources {
-    def examplesProtoDir = file("src/test/examplesProto")
-    examplesProtoDir.eachDir { dir ->
-        def name = dir.getName()
-        task "compile_proto_generated_source_${name}"(type: JavaCompile) {
-            source = {
-                file('third_party/proto').listFiles()
-                        .findAll { it.name.startsWith(name) && it.name.endsWith('-src.jar') }
-                        .collect { zipTree(it) }
-            }
-            destinationDir = file("build/generated/test/proto/${name}_classes")
-            classpath = files("third_party/protobuf-lite/libprotobuf_lite.jar")
-            sourceCompatibility = JavaVersion.VERSION_1_8
-            targetCompatibility = JavaVersion.VERSION_1_8
-        }
-        task "jar_proto_generated_source_${name}"(type: Jar, dependsOn: "compile_proto_generated_source_${name}") {
-            archiveName = "${name}.jar"
-            destinationDir = file("build/generated/test/proto")
-            from "build/generated/test/proto/${name}_classes"
-            include "/**/*.class"
-        }
-        dependsOn "jar_proto_generated_source_${name}"
-    }
-}
-
-task buildExamplesProto {
-    def examplesProtoDir = file("src/test/examplesProto")
-    def examplesProtoOutputDir = file("build/test/examplesProto");
-    dependsOn buildProtoGeneratedSources
-    task "compile_examples_proto"(type: JavaCompile) {
-        source = fileTree(dir: examplesProtoDir, include: "**/*.java")
-        destinationDir = file("build/test/examplesProto/classes")
-        classpath = files("third_party/protobuf-lite/libprotobuf_lite.jar")
-        classpath += fileTree(dir: "build/generated/test/proto", include: "*.jar")
-        sourceCompatibility = JavaVersion.VERSION_1_8
-        targetCompatibility = JavaVersion.VERSION_1_8
-    }
-    examplesProtoDir.eachDir { dir ->
-        def name = dir.getName()
-        task "jar_examples_proto_${name}"(type: Jar, dependsOn: "compile_examples_proto") {
-            archiveName = "${name}.jar"
-            destinationDir = examplesProtoOutputDir
-            from "build/test/examplesProto/classes"
-            include name + "/**/*.class"
-        }
-        dependsOn "jar_examples_proto_${name}"
-    }
-}
-
 // Proto lite generated code yields warnings when compiling with javac.
 // We change the options passed to javac to ignore it.
 compileExamplesJava.options.compilerArgs = ["-Xlint:none"]
@@ -2108,8 +2051,6 @@
     }
     if (project.hasProperty('no_internal')) {
         exclude "com/android/tools/r8/internal/**"
-    } else {
-        dependsOn buildExamplesProto
     }
     if (project.hasProperty('only_internal')) {
         include "com/android/tools/r8/internal/**"
diff --git a/src/test/examplesProto/README.txt b/src/test/examplesProto/README.txt
new file mode 100644
index 0000000..9330b92
--- /dev/null
+++ b/src/test/examplesProto/README.txt
@@ -0,0 +1,11 @@
+// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+The proto source set is no longer included in build.gradle after transitioning
+to gradle v8. If we need to update the project, one should generate new jars and
+place in third_party/proto or make a direct dependency on the generated jars.
+
+See this commit where we check in the generated proto jars to get a sense of
+how to compile the source sets:
+https://r8-review.git.corp.google.com/c/r8/+/82460
diff --git a/src/test/java/com/android/tools/r8/internal/proto/ProtoShrinkingTestBase.java b/src/test/java/com/android/tools/r8/internal/proto/ProtoShrinkingTestBase.java
index 81a54bc..8018e79 100644
--- a/src/test/java/com/android/tools/r8/internal/proto/ProtoShrinkingTestBase.java
+++ b/src/test/java/com/android/tools/r8/internal/proto/ProtoShrinkingTestBase.java
@@ -42,21 +42,21 @@
   public static final Path PROTOBUF_LITE_PROGUARD_RULES =
       Paths.get(ToolHelper.THIRD_PARTY_DIR, "protobuf-lite/lite_proguard.pgcfg");
 
-  // Test classes for proto2.
+  // Test classes for proto2. Use a checked in version of the built examples.
   public static final Path PROTO2_EXAMPLES_JAR =
-      Paths.get(ToolHelper.EXAMPLES_PROTO_BUILD_DIR).resolve("proto2.jar");
+      Paths.get(ToolHelper.THIRD_PARTY_DIR, "proto", "examplesProto2.jar");
 
   // Proto definitions used by test classes for proto2.
   public static final Path PROTO2_PROTO_JAR =
-      Paths.get(ToolHelper.GENERATED_PROTO_BUILD_DIR).resolve("proto2.jar");
+      Paths.get(ToolHelper.THIRD_PARTY_DIR, "proto", "examplesGeneratedProto2.jar");
 
   // Test classes for proto3.
   public static final Path PROTO3_EXAMPLES_JAR =
-      Paths.get(ToolHelper.EXAMPLES_PROTO_BUILD_DIR).resolve("proto3.jar");
+      Paths.get(ToolHelper.THIRD_PARTY_DIR, "proto", "examplesProto3.jar");
 
   // Proto definitions used by test classes for proto3.
   public static final Path PROTO3_PROTO_JAR =
-      Paths.get(ToolHelper.GENERATED_PROTO_BUILD_DIR).resolve("proto3.jar");
+      Paths.get(ToolHelper.THIRD_PARTY_DIR, "proto", "examplesGeneratedProto3.jar");
 
   public static void assertRewrittenProtoSchemasMatch(
       CodeInspector expectedInspector, CodeInspector actualInspector) throws Exception {
diff --git a/third_party/proto.tar.gz.sha1 b/third_party/proto.tar.gz.sha1
index d18398f..44b3c71 100644
--- a/third_party/proto.tar.gz.sha1
+++ b/third_party/proto.tar.gz.sha1
@@ -1 +1 @@
-25a84e6afdc9906e7795b58ac4dda5d8526e209f
\ No newline at end of file
+f2bd592b60141c7aaed2a3f0d14c19ffbc0639c8
\ No newline at end of file