aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Herhut <herhut@google.com>2017-10-24 13:11:39 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-10-24 13:11:39 +0000
commit47e5d54239bd2b717e67842eda75f0b8d336a41e (patch)
tree5408a50c521d6f89b50acc51d5e9295138914993
parent5933e7c18c7f8d6955fa90b6ecd1399006602ac0 (diff)
parent52cb10263772a25543efeefd0c66c053cc0a91e7 (diff)
downloadr8-47e5d54239bd2b717e67842eda75f0b8d336a41e.tar.gz
Merge "Add support for AutoValue in examples."
-rw-r--r--build.gradle6
-rw-r--r--src/test/examples/autovalue/SimpleAutoValue.java54
2 files changed, 60 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle
index 35da63e27..ef09f766e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,6 +10,7 @@ apply plugin: 'idea'
apply plugin: 'com.google.protobuf'
apply plugin: 'com.cookpad.android.licensetools'
apply plugin: 'net.ltgt.errorprone-base'
+apply plugin: "net.ltgt.apt"
def errorProneConfiguration = [
'-XepDisableAllChecks',
@@ -51,6 +52,7 @@ buildscript {
// classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
classpath files("third_party/shadow/shadow-2.0.1.jar")
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
+ classpath "net.ltgt.gradle:gradle-apt-plugin:0.12"
}
}
@@ -169,12 +171,16 @@ dependencies {
jctfTestsCompile sourceSets.jctfCommon.output
examplesAndroidOCompile group: 'org.ow2.asm', name: 'asm', version: '6.0'
examplesAndroidPCompile group: 'org.ow2.asm', name: 'asm', version: '6.0'
+ // Import Guava for @Nullable annotation
+ examplesCompile 'com.google.guava:guava:23.0'
examplesCompile 'com.google.protobuf:protobuf-lite:3.0.0'
+ examplesCompileOnly "com.google.auto.value:auto-value:1.5"
examplesRuntime 'com.google.protobuf:protobuf-lite:3.0.0'
supportLibs 'com.android.support:support-v4:25.4.0'
supportLibs 'junit:junit:4.12'
supportLibs 'com.android.support.test.espresso:espresso-core:3.0.0'
debugTestResourcesKotlinCompileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.1.4-3'
+ apt 'com.google.auto.value:auto-value:1.5'
}
licenseTools {
diff --git a/src/test/examples/autovalue/SimpleAutoValue.java b/src/test/examples/autovalue/SimpleAutoValue.java
new file mode 100644
index 000000000..2c0b2c659
--- /dev/null
+++ b/src/test/examples/autovalue/SimpleAutoValue.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2017, 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.
+package autovalue;
+
+import com.google.auto.value.AutoValue;
+import javax.annotation.Nullable;
+
+public class SimpleAutoValue {
+
+ @AutoValue
+ static abstract class Pair {
+
+ Pair() {
+ // Intentionally left empty.
+ }
+
+ abstract int getOne();
+
+ @Nullable
+ abstract String getOther();
+
+ abstract String getRequiredOther();
+
+ static Builder builder() {
+ return new AutoValue_SimpleAutoValue_Pair.Builder();
+ }
+
+ @AutoValue.Builder
+ abstract static class Builder {
+
+ abstract Builder setOne(int value);
+
+ abstract Builder setOther(String value);
+
+ abstract Builder setRequiredOther(String value);
+
+ abstract Pair build();
+ }
+ }
+
+ public static void main(String... args) {
+ Pair.Builder builder = Pair.builder();
+ builder.setOne(42);
+ builder.setRequiredOther("123");
+ System.out.println(builder.build());
+ builder = Pair.builder();
+ try {
+ builder.build();
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+}