Skip to content

Commit 1479eea

Browse files
committed
Add a Bazel example with source generator
1 parent 1df5ede commit 1479eea

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

examples/bazel-example/WORKSPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ maven_install(
6969
artifacts = [
7070
"com.google.protobuf:protobuf-java:3.15.6", # Required dependency by scip-java.
7171
"com.google.protobuf:protobuf-java-util:3.15.6", # Required dependency by scip-java.
72-
"com.google.guava:guava:31.0-jre", # Not required dependency, only used by tests.
72+
# These dependencies are only required for the tests
73+
"com.google.guava:guava:31.0-jre",
74+
"com.google.auto.value:auto-value:1.5.3",
7375
],
7476
repositories = [
7577
"https://repo1.maven.org/maven2",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import com.google.auto.value.AutoValue;
3+
4+
@AutoValue
5+
abstract class Animal {
6+
static Animal create(String name, int numberOfLegs) {
7+
return new AutoValue_Animal(name, numberOfLegs);
8+
}
9+
10+
abstract String name();
11+
abstract int numberOfLegs();
12+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
load("@scip_java//semanticdb-javac:defs.bzl", "java_library")
2+
load("@rules_java//java:defs.bzl", "java_plugin")
3+
4+
package(
5+
default_visibility = ["//visibility:public"],
6+
)
7+
8+
java_library(
9+
name = "animal",
10+
srcs = ["Animal.java"],
11+
deps = [
12+
":autovalue",
13+
],
14+
)
15+
16+
java_plugin(
17+
name = "autovalue_plugin",
18+
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
19+
deps = [
20+
"@maven//:com_google_auto_value_auto_value",
21+
],
22+
)
23+
24+
java_library(
25+
name = "autovalue",
26+
exported_plugins = [
27+
":autovalue_plugin",
28+
],
29+
neverlink = 1,
30+
exports = [
31+
"@maven//:com_google_auto_value_auto_value",
32+
],
33+
)
34+

0 commit comments

Comments
 (0)