Skip to content

Commit

Permalink
[ARIES-1484] Only write blueprint context if any beans are discovered
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/aries/trunk@1724022 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cschneider committed Jan 11, 2016
1 parent 5688330 commit b6819e3
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,35 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

try {
String buildDir = project.getBuild().getDirectory();
String generatedDir = buildDir + "/generated-resources";
Resource resource = new Resource();
resource.setDirectory(generatedDir);
project.addResource(resource);
ClassFinder finder = createProjectScopeFinder();

File file = new File(generatedDir, "OSGI-INF/blueprint/autowire.xml");
file.getParentFile().mkdirs();
System.out.println("Generating blueprint to " + file);
Set<Class<?>> classes = FilteredClassFinder.findClasses(finder, scanPaths);
Context context = new Context(classes);
context.resolve();
OutputStream fos = buildContext.newFileOutputStream(file);
new Generator(context, fos, namespaces).generate();
fos.close();
if (context.getBeans().size() > 0) {
writeBlueprint(context);
}
} catch (Exception e) {
throw new MojoExecutionException("Error building commands help", e);
}
}

private void writeBlueprint(Context context) throws Exception {
String buildDir = project.getBuild().getDirectory();
String generatedDir = buildDir + "/generated-resources";
Resource resource = new Resource();
resource.setDirectory(generatedDir);
project.addResource(resource);

File file = new File(generatedDir, "OSGI-INF/blueprint/autowire.xml");
file.getParentFile().mkdirs();
System.out.println("Generating blueprint to " + file);

OutputStream fos = buildContext.newFileOutputStream(file);
new Generator(context, fos, namespaces).generate();
fos.close();
}

private ClassFinder createProjectScopeFinder() throws MalformedURLException {
List<URL> urls = new ArrayList<URL>();

Expand Down

0 comments on commit b6819e3

Please sign in to comment.