mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Support incremental annotation processing with Gradle
Closes gh-22150
This commit is contained in:
parent
27c458ca26
commit
62aa8ce107
@ -0,0 +1 @@
|
|||||||
|
org.springframework.boot.autoconfigureprocessor.AutoConfigureAnnotationProcessor,aggregating
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.boot.configurationprocessor.fieldvalues.javac;
|
package org.springframework.boot.configurationprocessor.fieldvalues.javac;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import javax.annotation.processing.ProcessingEnvironment;
|
import javax.annotation.processing.ProcessingEnvironment;
|
||||||
@ -38,10 +39,21 @@ final class Trees extends ReflectionWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Trees instance(ProcessingEnvironment env) throws Exception {
|
static Trees instance(ProcessingEnvironment env) throws Exception {
|
||||||
ClassLoader classLoader = env.getClass().getClassLoader();
|
try {
|
||||||
Class<?> type = findClass(classLoader, "com.sun.source.util.Trees");
|
ClassLoader classLoader = env.getClass().getClassLoader();
|
||||||
Method method = findMethod(type, "instance", ProcessingEnvironment.class);
|
Class<?> type = findClass(classLoader, "com.sun.source.util.Trees");
|
||||||
return new Trees(method.invoke(null, env));
|
Method method = findMethod(type, "instance", ProcessingEnvironment.class);
|
||||||
|
return new Trees(method.invoke(null, env));
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
return instance(unwrap(env));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ProcessingEnvironment unwrap(ProcessingEnvironment wrapper) throws Exception {
|
||||||
|
Field delegateField = wrapper.getClass().getDeclaredField("delegate");
|
||||||
|
delegateField.setAccessible(true);
|
||||||
|
return (ProcessingEnvironment) delegateField.get(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor,aggregating
|
Loading…
Reference in New Issue
Block a user