mirror of
https://github.com/google/nomulus
synced 2026-09-30 19:55:45 +00:00
Make VKeyProcessor an isolating processor (#3240)
Register VKeyProcessor as an ISOLATING incremental annotation processor in META-INF/gradle/incremental.annotation.processors and pass the annotated TypeElement as the originating element when generating VKeyConverter classes via JavaPoet. Previously, because VKeyProcessor was not declared incremental, Gradle disabled incremental Java compilation for both :core:compileJava and :core:compileTestJava, forcing a full recompilation of all ~3,000 source and generated classes in :core on every edit. This is because without knowing that the processor's input is isolated to a single test class, Gradle had to recompile everything. This cuts recompilation time (after you make, say, a one-line change) from like 20-30 seconds to like 3-5 seconds
This commit is contained in:
@@ -105,6 +105,7 @@ public class VKeyProcessor extends AbstractProcessor {
|
||||
}
|
||||
try {
|
||||
createJavaFile(
|
||||
annotatedTypeElement,
|
||||
getPackageName(annotatedTypeElement),
|
||||
String.format(CONVERTER_CLASS_NAME_TEMP, simpleTypeName),
|
||||
TypeName.get(entityType),
|
||||
@@ -118,7 +119,11 @@ public class VKeyProcessor extends AbstractProcessor {
|
||||
}
|
||||
|
||||
private static JavaFile createJavaFile(
|
||||
String packageName, String converterClassName, TypeName entityType, TypeName keyType) {
|
||||
TypeElement annotatedTypeElement,
|
||||
String packageName,
|
||||
String converterClassName,
|
||||
TypeName entityType,
|
||||
TypeName keyType) {
|
||||
ParameterizedTypeName attributeConverter =
|
||||
ParameterizedTypeName.get(
|
||||
ClassName.get("google.registry.persistence.converter", "VKeyConverter"),
|
||||
@@ -143,6 +148,7 @@ public class VKeyProcessor extends AbstractProcessor {
|
||||
|
||||
TypeSpec.Builder classBuilder =
|
||||
TypeSpec.classBuilder(converterClassName)
|
||||
.addOriginatingElement(annotatedTypeElement)
|
||||
.addAnnotation(AnnotationSpec.builder(ClassName.get(Converter.class)).build())
|
||||
.addModifiers(Modifier.FINAL, Modifier.PUBLIC)
|
||||
.superclass(attributeConverter)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
google.registry.processors.VKeyProcessor,ISOLATING
|
||||
Reference in New Issue
Block a user