Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private void createEipModelConfigurationSource(String packageName, EipModel mode
configClass.setPackage(packageName);
configClass.setName(configName);
configClass.extendSuperType(commonClass);
configClass.addAnnotation(loadClass("org.springframework.boot.context.properties.ConfigurationProperties"))
configClass.addAnnotation(loadAnnotationClass("org.springframework.boot.context.properties.ConfigurationProperties"))
.setStringValue("prefix", propertiesPrefix);
configClass.addImport(Map.class);
configClass.addImport(HashMap.class);
Expand Down Expand Up @@ -884,6 +884,28 @@ private Class loadClass(String loadClassName) throws MojoFailureException {
return optionClass;
}

// try loading annotation class, looking for inner classes if needed
private Class<? extends java.lang.annotation.Annotation> loadAnnotationClass(String loadClassName) throws MojoFailureException {
String currentClassName = loadClassName;
ClassNotFoundException lastException = null;

while (currentClassName != null) {
try {
return getProjectClassLoader().loadClass(currentClassName).asSubclass(java.lang.annotation.Annotation.class);
} catch (ClassNotFoundException e) {
lastException = e;
int dotIndex = currentClassName.lastIndexOf('.');
if (dotIndex == -1) {
currentClassName = null;
} else {
currentClassName = currentClassName.substring(0, dotIndex) + "$" + currentClassName.substring(dotIndex + 1);
}
}
}

throw new MojoFailureException(lastException.getMessage(), lastException);
}

protected DynamicClassLoader getProjectClassLoader() {
if (projectClassLoader == null) {
final List<String> classpathElements;
Expand Down
Loading