aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1757465 - /aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
Date Wed, 24 Aug 2016 06:54:31 GMT
Author: jbonofre
Date: Wed Aug 24 06:54:31 2016
New Revision: 1757465

URL: http://svn.apache.org/viewvc?rev=1757465&view=rev
Log:
[ARIES-1597] blueprint-maven-plugin new option to override generatedDir 

Signed-off-by: Michael Vorburger <vorburger@redhat.com>

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=1757465&r1=1757464&r2=1757465&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
Wed Aug 24 06:54:31 2016
@@ -45,7 +45,7 @@ import java.util.Set;
 /**
  * Generates blueprint from CDI annotations
  */
-@Mojo(name="blueprint-generate", requiresDependencyResolution=ResolutionScope.COMPILE, 
+@Mojo(name="blueprint-generate", requiresDependencyResolution=ResolutionScope.COMPILE,
     defaultPhase=LifecyclePhase.PROCESS_CLASSES, inheritByDefault=false)
 public class GenerateMojo extends AbstractMojo {
 
@@ -54,7 +54,7 @@ public class GenerateMojo extends Abstra
 
     @Parameter(required=true)
     protected List<String> scanPaths;
-    
+
     /**
      * Which extension namespaces should the plugin support
      */
@@ -71,6 +71,13 @@ public class GenerateMojo extends Abstra
     protected String generatedFileName;
 
     /**
+     * Base directory to generate into
+     * (relative to ${project.build.directory}/generated-resources).
+     */
+    @Parameter(defaultValue="OSGI-INF/blueprint/")
+    private String generatedDir;
+
+    /**
      * Specifies the default activation setting that will be defined for components.
      * Default is null, which indicates eager (blueprint default).
      * If LAZY then default-activation will be set to lazy.
@@ -79,6 +86,7 @@ public class GenerateMojo extends Abstra
     @Parameter
     protected Activation defaultActivation;
 
+    @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
         if (scanPaths.size() == 0 || scanPaths.iterator().next() == null) {
             throw new MojoExecutionException("Configuration scanPaths must be set");
@@ -86,10 +94,10 @@ public class GenerateMojo extends Abstra
         if (!buildContext.hasDelta(new File(project.getCompileSourceRoots().iterator().next())))
{
             return;
         }
-        
+
         try {
             ClassFinder finder = createProjectScopeFinder();
-            
+
             Set<Class<?>> classes = FilteredClassFinder.findClasses(finder, scanPaths);
             Context context = new Context(classes);
             context.resolve();
@@ -103,12 +111,13 @@ public class GenerateMojo extends Abstra
 
     private void writeBlueprint(Context context) throws Exception {
         String buildDir = project.getBuild().getDirectory();
-        String generatedDir = buildDir + "/generated-resources";
+        String generatedBaseDir = buildDir + "/generated-resources";
         Resource resource = new Resource();
-        resource.setDirectory(generatedDir);
+        resource.setDirectory(generatedBaseDir);
         project.addResource(resource);
 
-        File file = new File(generatedDir, "OSGI-INF/blueprint/" + generatedFileName);
+        File dir = new File(generatedBaseDir, generatedDir);
+        File file = new File(dir, generatedFileName);
         file.getParentFile().mkdirs();
         System.out.println("Generating blueprint to " + file);
 
@@ -118,7 +127,7 @@ public class GenerateMojo extends Abstra
     }
 
     private ClassFinder createProjectScopeFinder() throws MalformedURLException {
-        List<URL> urls = new ArrayList<URL>();
+        List<URL> urls = new ArrayList<>();
 
         urls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
         for (Object artifactO : project.getArtifacts()) {



Mime
View raw message