Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add support for gradle's incremental annotation processing
Fixes #1120

RELNOTES=Add support for gradle's incremental annotation processing. This can be enabled by passing `-Adagger.gradle.incremental` to `javac`

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=211815034
  • Loading branch information
ronshapiro committed Sep 7, 2018
commit 6baf304a7c27e3ee43dbd0c942471fa510289008
7 changes: 7 additions & 0 deletions java/dagger/android/processor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ load(
"DOCLINT_REFERENCES",
)
load("//tools:maven.bzl", "pom_file", "POM_VERSION")
load("//tools:simple_jar.bzl", "simple_jar")

filegroup(
name = "srcs",
Expand All @@ -33,6 +34,7 @@ java_library(
name = "processor",
srcs = [":srcs"],
javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
resource_jars = [":processor_manifest_files.jar"],
tags = ["maven_coordinates=com.google.dagger:dagger-android-processor:" + POM_VERSION],
deps = [
"@google_bazel_common//third_party/java/guava",
Expand Down Expand Up @@ -69,6 +71,11 @@ java_import(
visibility = ["//visibility:private"],
)

simple_jar(
name = "processor_manifest_files",
srcs = glob(["META-INF/**"]),
)

pom_file(
name = "pom",
artifact_id = "dagger-android-processor",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dagger.android.processor.AndroidProcessor,isolating
7 changes: 7 additions & 0 deletions java/dagger/internal/codegen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package(default_visibility = ["//:src"])

load("//:build_defs.bzl", "DOCLINT_HTML_AND_SYNTAX", "DOCLINT_REFERENCES")
load("//tools:maven.bzl", "pom_file", "POM_VERSION")
load("//tools:simple_jar.bzl", "simple_jar")

EXPERIMENTAL_VISUALIZER_SRCS = ["BindingNetworkVisualizer.java"]

Expand Down Expand Up @@ -305,6 +306,11 @@ java_library(
],
)

simple_jar(
name = "processor_manifest_files",
srcs = glob(["META-INF/**"]),
)

# The processor's "main", if you will
java_library(
name = "processor",
Expand All @@ -330,6 +336,7 @@ java_library(
"ProductionExecutorModuleProcessingStep.java",
],
plugins = CODEGEN_PLUGINS,
resource_jars = [":processor_manifest_files.jar"],
tags = ["maven_coordinates=com.google.dagger:dagger-compiler:" + POM_VERSION],
deps = CODEGEN_DEPS + [
":base",
Expand Down
3 changes: 3 additions & 0 deletions java/dagger/internal/codegen/ComponentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public Set<String> getSupportedOptions() {
options.addAll(CompilerOptions.SUPPORTED_OPTIONS);
options.addAll(spiPlugins.allSupportedOptions());
options.addAll(validationPlugins.allSupportedOptions());
if (processingEnv.getOptions().containsKey("dagger.gradle.incremental")) {
options.add("org.gradle.annotation.processing.isolating");
}
return options.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dagger.internal.codegen.ComponentProcessor,dynamic
31 changes: 31 additions & 0 deletions tools/simple_jar.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2018 The Dagger Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Macro for creating a jar from a set of flat files"""

def simple_jar(name, srcs):
"""Creates a jar out of a set of flat files"""

# TODO(dpb): consider creating a Fileset() under the hood to support srcs from different
# directories
native.genrule(
name = name,
srcs = srcs,
outs = ["%s.jar" % name],
cmd = """
OUT="$$(pwd)/$@"
cd {package_name}
zip "$$OUT" -r * &> /dev/null
""".format(package_name = native.package_name()),
)