aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1741936 - in /aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin: FilteredClassFinder.java GenerateMojo.java
Date Mon, 02 May 2016 08:50:18 GMT
Author: cschneider
Date: Mon May  2 08:50:18 2016
New Revision: 1741936

URL: http://svn.apache.org/viewvc?rev=1741936&view=rev
Log:
[ARIES-1539] Allow for setting name of generated file. closes #45

Modified:
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java
    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/FilteredClassFinder.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java?rev=1741936&r1=1741935&r2=1741936&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/FilteredClassFinder.java
Mon May  2 08:50:18 2016
@@ -18,17 +18,16 @@
  */
 package org.apache.aries.blueprint.plugin;
 
+import org.apache.xbean.finder.ClassFinder;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
 import java.lang.annotation.Annotation;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.apache.xbean.finder.ClassFinder;
-import org.springframework.stereotype.Component;
-
 public class FilteredClassFinder {
     
     @SuppressWarnings("unchecked")
@@ -50,12 +49,9 @@ public class FilteredClassFinder {
             for (String packageName : packageNames) {
                 if (clazz.getPackage().getName().startsWith(packageName)) {
                     filteredClasses.add(clazz);
-                    continue;
                 }
             }
         }
-        //System.out.println("Raw: " + rawClasses);
-        //System.out.println("Filtered: " + beanClasses);
         return filteredClasses;
     }
 }

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=1741936&r1=1741935&r2=1741936&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 May  2 08:50:18 2016
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,15 +18,6 @@
  */
 package org.apache.aries.blueprint.plugin;
 
-import java.io.File;
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
 import org.apache.aries.blueprint.plugin.model.Context;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Resource;
@@ -37,8 +28,18 @@ import org.apache.maven.project.MavenPro
 import org.apache.xbean.finder.ClassFinder;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
+import java.io.File;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
 /**
  * Generates blueprint from spring annotations
+ *
  * @goal blueprint-generate
  * @phase process-classes
  * @requiresDependencyResolution compile
@@ -63,8 +64,8 @@ public class GenerateMojo extends Abstra
     
     /**
      * Which extension namespaces should the plugin support
-     * 
-     * @parameter 
+     *
+     * @parameter
      */
     protected Set<String> namespaces;
     
@@ -73,6 +74,13 @@ public class GenerateMojo extends Abstra
      */
     private BuildContext buildContext;
 
+    /**
+     * Name of file to generate, default: autowire.xml
+     *
+     * @parameter
+     */
+    protected String generatedFileName;
+
     public void execute() throws MojoExecutionException, MojoFailureException {
         if (!buildContext.hasDelta(new File(project.getCompileSourceRoots().iterator().next())))
{
             return;
@@ -99,7 +107,9 @@ public class GenerateMojo extends Abstra
         resource.setDirectory(generatedDir);
         project.addResource(resource);
 
-        File file = new File(generatedDir, "OSGI-INF/blueprint/autowire.xml");
+        String fileName = generatedFileName != null ? generatedFileName : "autowire.xml";
+
+        File file = new File(generatedDir, "OSGI-INF/blueprint/" + fileName);
         file.getParentFile().mkdirs();
         System.out.println("Generating blueprint to " + file);
 
@@ -111,12 +121,12 @@ public class GenerateMojo extends Abstra
     private ClassFinder createProjectScopeFinder() throws MalformedURLException {
         List<URL> urls = new ArrayList<URL>();
 
-        urls.add( new File(project.getBuild().getOutputDirectory()).toURI().toURL() );
-        for ( Object artifactO : project.getArtifacts() ) {
-            Artifact artifact = (Artifact)artifactO;
+        urls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
+        for (Object artifactO : project.getArtifacts()) {
+            Artifact artifact = (Artifact) artifactO;
             File file = artifact.getFile();
-            if ( file != null ) {
-                urls.add( file.toURI().toURL() );
+            if (file != null) {
+                urls.add(file.toURI().toURL());
             }
         }
         ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());



Mime
View raw message