aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1724022 - /aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
Date Mon, 11 Jan 2016 13:40:07 GMT
Author: cschneider
Date: Mon Jan 11 13:40:06 2016
New Revision: 1724022

URL: http://svn.apache.org/viewvc?rev=1724022&view=rev
Log:
[ARIES-1484] Only write blueprint context if any beans are discovered

Modified:
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java?rev=1724022&r1=1724021&r2=1724022&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
Mon Jan 11 13:40:06 2016
@@ -79,27 +79,35 @@ public class GenerateMojo extends Abstra
         }
         
         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>();
 



Mime
View raw message