*/
private MavenProject project;
public void execute() throws MojoExecutionException, MojoFailureException {
try {
final JSONObject descriptor = new JSONObject();
final AnnotationDB annotationDb = new AnnotationDB();
annotationDb.scanArchives(buildOutputDirectory.toURI().toURL());
final Set<String> annotatedClassNames = new HashSet<String>();
addAnnotatedClasses(annotationDb, annotatedClassNames, Adaptable.class);
addAnnotatedClasses(annotationDb, annotatedClassNames, Adaptables.class);
for (final String annotatedClassName : annotatedClassNames) {
getLog().info(String.format("found adaptable annotation on %s", annotatedClassName));
final String pathToClassFile = annotatedClassName.replace('.', '/') + ".class";
final File classFile = new File(buildOutputDirectory, pathToClassFile);
final FileInputStream input = new FileInputStream(classFile);
final ClassReader classReader;
try {
classReader = new ClassReader(input);
} finally {
input.close();
}
final ClassNode classNode = new ClassNode();
classReader.accept(classNode, SKIP_CODE | SKIP_DEBUG | SKIP_FRAMES);
@SuppressWarnings("unchecked")
final List<AnnotationNode> annotations = classNode.invisibleAnnotations;
for (final AnnotationNode annotation : annotations) {
if (ADAPTABLE_DESC.equals(annotation.desc)) {
parseAdaptableAnnotation(annotation, classNode, descriptor);
} else if (ADAPTABLES_DESC.equals(annotation.desc)) {
parseAdaptablesAnnotation(annotation, classNode, descriptor);
}
}
}
final File outputFile = new File(outputDirectory, fileName);
outputFile.getParentFile().mkdirs();
final FileWriter writer = new FileWriter(outputFile);
try {
IOUtil.copy(descriptor.toString(JSON_INDENTATION), writer);
} finally {
IOUtil.close(writer);
}
addResource();