Skip to content

Commit

Permalink
Allow loading recipes from inner classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Oct 2, 2023
1 parent e900928 commit 164d356
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public ClasspathScanningLoader(Properties properties, String[] acceptPackages) {
*/
public ClasspathScanningLoader(Properties properties, ClassLoader classLoader) {
scanClasses(new ClassGraph()
.ignoreParentClassLoaders()
.overrideClassLoaders(classLoader), classLoader);
.ignoreParentClassLoaders()
.overrideClassLoaders(classLoader), classLoader);

scanYaml(new ClassGraph()
.ignoreParentClassLoaders()
.overrideClassLoaders(classLoader)
.acceptPaths("META-INF/rewrite"),
.ignoreParentClassLoaders()
.overrideClassLoaders(classLoader)
.acceptPaths("META-INF/rewrite"),
properties,
emptyList(),
classLoader);
Expand Down Expand Up @@ -163,10 +163,9 @@ private void scanClasses(ClassGraph classGraph, ClassLoader classLoader) {
private void configureRecipes(ScanResult result, String className) {
for (ClassInfo classInfo : result.getSubclasses(className)) {
Class<?> recipeClass = classInfo.loadClass();
if (recipeClass.getName().equals(DeclarativeRecipe.class.getName())
|| recipeClass.getEnclosingClass() != null
if (recipeClass.getName().equals(DeclarativeRecipe.class.getName()) ||
// `ScanningRecipe` is an example of an abstract `Recipe` subtype
|| (recipeClass.getModifiers() & Modifier.ABSTRACT) != 0) {
(recipeClass.getModifiers() & Modifier.ABSTRACT) != 0) {
continue;
}
Timer.Builder builder = Timer.builder("rewrite.scan.configure.recipe");
Expand Down

0 comments on commit 164d356

Please sign in to comment.