Skip to content

Commit

Permalink
Enable gradle incremental annotation processing for tritium-processor (
Browse files Browse the repository at this point in the history
…#1085)

Enable gradle incremental annotation processing for tritium-processor
  • Loading branch information
carterkozak authored May 13, 2021
1 parent b399530 commit 07df603
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1085.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Enable gradle incremental annotation processing for tritium-processor
links:
- https://github.com/palantir/tritium/pull/1085
3 changes: 0 additions & 3 deletions tritium-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ dependencies {
compile 'com.google.code.findbugs:jsr305'
compile 'com.palantir.safe-logging:preconditions'

annotationProcessor 'com.google.auto.service:auto-service'
compileOnly 'com.google.auto.service:auto-service-annotations'

testImplementation 'com.google.testing.compile:compile-testing'
testImplementation 'com.google.guava:guava'
testImplementation 'org.assertj:assertj-core'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.palantir.tritium.processor;

import com.google.auto.common.GeneratedAnnotations;
import com.google.auto.service.AutoService;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
Expand Down Expand Up @@ -53,7 +52,6 @@
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
Expand All @@ -72,7 +70,6 @@
import javax.lang.model.util.Types;
import javax.tools.Diagnostic.Kind;

@AutoService(Processor.class)
public final class TritiumAnnotationProcessor extends AbstractProcessor {

private static final String DELEGATE_NAME = "delegate";
Expand Down Expand Up @@ -213,7 +210,9 @@ private JavaFile generate(
}
}

TypeSpec.Builder specBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
TypeSpec.Builder specBuilder = TypeSpec.classBuilder(className)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addOriginatingElement(typeElement);

GeneratedAnnotations.generatedAnnotation(elements, SourceVersion.latest())
.ifPresent(te -> specBuilder.addAnnotation(AnnotationSpec.builder(ClassName.get(te))
Expand Down Expand Up @@ -328,6 +327,12 @@ public Void visitExecutable(ExecutableElement method, Void _param) {
.addStatement("return builder(delegate).withTaggedMetrics(registry).withTracing().build()")
.build());

if (specBuilder.originatingElements.size() != 1) {
messager.printMessage(
Kind.ERROR,
"The generated type must have exactly one originating element: " + specBuilder.originatingElements,
typeElement);
}
return JavaFile.builder(packageName, specBuilder.build())
.skipJavaLangImports(true)
.indent(" ")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.palantir.tritium.processor.TritiumAnnotationProcessor,ISOLATING
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.palantir.tritium.processor.TritiumAnnotationProcessor

0 comments on commit 07df603

Please sign in to comment.