Skip to content

Commit

Permalink
Use proper substitution segments for autofactory and autovalue as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgruber committed Feb 18, 2019
1 parent c87f8d3 commit 0754675
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 96 deletions.
40 changes: 10 additions & 30 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,23 @@ kotlin_repositories()
kt_register_toolchains()


# Description:
# Substitutes the naive maven_jvm_artifact for com.google.dagger:dagger with a flagor that exports the compiler
# plugin. Contains the `dagger_version` substitution variable.
DAGGER_BUILD_SUBSTITUTE_WITH_PLUGIN = """
java_library(
name = "dagger",
exports = [
":dagger_api",
"@maven//javax/inject:javax_inject",
],
exported_plugins = [":dagger_plugin"],
visibility = ["//visibility:public"],
)
maven_jvm_artifact(
name = "dagger_api",
artifact = "com.google.dagger:dagger:{dagger_version}",
)
java_plugin(
name = "dagger_plugin",
processor_class = "dagger.internal.codegen.ComponentProcessor",
generates_api = True,
deps = [":dagger_compiler"],
)
"""

# Setup maven repository handling.
load("@maven_repository_rules//maven:maven.bzl", "maven_repository_specification")
load(":workspace_maven_substitutes.bzl", "snippets")
maven_repository_specification(
name = "maven",
artifacts = {
"args4j:args4j:2.32": { "insecure": True },
"cglib:cglib-nodep:2.2.2": { "insecure": True },
"com.google.auto.factory:auto-factory:1.0-beta6": { "insecure": True },
"com.google.auto.factory:auto-factory:1.0-beta6": {
"insecure": True,
"build_snippet": snippets.AUTO_FACTORY.format(version = "1.0-beta6"),
},
"com.google.auto.value:auto-value-annotations:1.6.3": { "insecure": True },
"com.google.auto.value:auto-value:1.6.3": { "insecure": True },
"com.google.auto.value:auto-value:1.6.3": {
"insecure": True,
"build_snippet": snippets.AUTO_VALUE.format(version = "1.6.3"),
},
"com.google.auto:auto-common:0.10": { "insecure": True },
"com.google.code.findbugs:jsr305:3.0.2": { "insecure": True },
"com.google.code.gson:gson:2.8.1": { "insecure": True },
Expand All @@ -74,7 +54,7 @@ maven_repository_specification(
"com.google.dagger:dagger-spi:2.20": { "insecure": True },
"com.google.dagger:dagger:2.20": {
"insecure": True,
"build_snippet": DAGGER_BUILD_SUBSTITUTE_WITH_PLUGIN.format(dagger_version = "2.20")
"build_snippet": snippets.DAGGER.format(version = "2.20"),
},
"com.google.errorprone:error_prone_annotations:2.3.1": { "insecure": True },
"com.google.errorprone:javac-shaded:9+181-r4173-1": { "insecure": True },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ java_library(
":core",
"//client/src/main/java/com/google/devtools/moe/client/codebase/expressions",
"//client/src/main/java/com/google/devtools/moe/client/qualifiers",
"//tools/auto:factory",
"//tools/auto:value",
"@maven//args4j",
"@maven//com/google/auto/factory",
"@maven//com/google/auto/value",
"@maven//com/google/dagger",
"@maven//joda-time:joda_time",
"@maven//com/google/guava",
"@maven//com/google/code/gson",
"@maven//com/squareup/okhttp",
"@maven//com/mikesamuel:json_sanitizer",
"@maven//com/google/errorprone:error_prone_annotations",
"@maven//com/google/code/findbugs:jsr305",
"@maven//args4j",
"@maven//joda-time:joda_time",
],
)
62 changes: 0 additions & 62 deletions tools/auto/BUILD.bazel

This file was deleted.

91 changes: 91 additions & 0 deletions workspace_maven_substitutes.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

_DAGGER = """
java_library(
name = "dagger",
exports = [
":dagger_api",
"@maven//javax/inject:javax_inject",
],
exported_plugins = [":plugin"],
visibility = ["//visibility:public"],
)
maven_jvm_artifact(
name = "dagger_api",
artifact = "com.google.dagger:dagger:{version}",
visibility = ["//visibility:private"],
)
java_plugin(
name = "plugin",
processor_class = "dagger.internal.codegen.ComponentProcessor",
generates_api = True,
deps = [":dagger_compiler"],
)
"""

_AUTO_FACTORY = """
java_library(
name = "factory",
exports = [
"@maven//com/google/auto/factory:auto_factory",
],
exported_plugins = [":plugin"],
neverlink = True, # this is only needed at compile-time, for code-gen.
visibility = ["//visibility:public"],
)
maven_jvm_artifact(
name = "auto_factory",
artifact = "com.google.auto.factory:auto-factory:{version}",
visibility = ["//visibility:private"],
)
java_plugin(
name = "plugin",
processor_class = "com.google.auto.factory.processor.AutoFactoryProcessor",
generates_api = True,
deps = [":auto_factory"],
)
"""

_AUTO_VALUE = """
java_library(
name = "value",
exports = [
":auto_value_annotations",
"@maven//com/ryanharter/auto/value:auto_value_gson_annotations",
],
exported_plugins = [":plugin", ":gson_plugin"],
visibility = ["//visibility:public"],
)
maven_jvm_artifact(
name = "auto_value",
artifact = "com.google.auto.value:auto-value:{version}",
visibility = ["@maven//com/ryanharter/auto/value:__subpackages__"],
)
java_plugin(
name = "plugin",
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
generates_api = True,
deps = [":auto_value"],
)
java_plugin(
name = "gson_plugin",
processor_class = "com.ryanharter.auto.value.gson.AutoValueGsonAdapterFactoryProcessor",
generates_api = True,
deps = [
"@//tools/auto/generated/javax/annotation:generated", # For compiling with java9+
"@maven//com/ryanharter/auto/value:auto_value_gson",
],
)
"""

snippets = struct(
AUTO_VALUE = _AUTO_VALUE,
AUTO_FACTORY = _AUTO_FACTORY,
DAGGER = _DAGGER,
)

0 comments on commit 0754675

Please sign in to comment.