tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1291672 - in /openejb/trunk/maven-plugins: ./ spi-helper-maven-plugin/ spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/ spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/xml/ xbean-xml/ xbe...
Date Tue, 21 Feb 2012 09:25:17 GMT
Author: rmannibucau
Date: Tue Feb 21 09:25:16 2012
New Revision: 1291672

URL: http://svn.apache.org/viewvc?rev=1291672&view=rev
Log:
managing profiles in spi-helper-maven-plugin and splitting xbean-xml in a separated module

Added:
    openejb/trunk/maven-plugins/xbean-xml/
    openejb/trunk/maven-plugins/xbean-xml/pom.xml
    openejb/trunk/maven-plugins/xbean-xml/src/
    openejb/trunk/maven-plugins/xbean-xml/src/main/
    openejb/trunk/maven-plugins/xbean-xml/src/main/java/
    openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/
    openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/
    openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/openejb/
    openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/openejb/xbean/
    openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/openejb/xbean/xml/
    openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/openejb/xbean/xml/Scan.java
    openejb/trunk/maven-plugins/xbean-xml/src/test/
    openejb/trunk/maven-plugins/xbean-xml/src/test/java/
Removed:
    openejb/trunk/maven-plugins/spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/ExtendedAnnotationFinder.java
    openejb/trunk/maven-plugins/spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/xml/
Modified:
    openejb/trunk/maven-plugins/pom.xml
    openejb/trunk/maven-plugins/spi-helper-maven-plugin/pom.xml
    openejb/trunk/maven-plugins/spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/SpiMojo.java

Modified: openejb/trunk/maven-plugins/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/maven-plugins/pom.xml?rev=1291672&r1=1291671&r2=1291672&view=diff
==============================================================================
--- openejb/trunk/maven-plugins/pom.xml (original)
+++ openejb/trunk/maven-plugins/pom.xml Tue Feb 21 09:25:16 2012
@@ -39,6 +39,7 @@
     <module>openejb-embedded-maven-plugin</module>
     <module>maven-util</module>
     <module>spi-helper-maven-plugin</module>
+    <module>xbean-xml</module>
   </modules>
 
   <dependencyManagement>

Modified: openejb/trunk/maven-plugins/spi-helper-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/maven-plugins/spi-helper-maven-plugin/pom.xml?rev=1291672&r1=1291671&r2=1291672&view=diff
==============================================================================
--- openejb/trunk/maven-plugins/spi-helper-maven-plugin/pom.xml (original)
+++ openejb/trunk/maven-plugins/spi-helper-maven-plugin/pom.xml Tue Feb 21 09:25:16 2012
@@ -26,6 +26,16 @@
       <groupId>org.apache.xbean</groupId>
       <artifactId>xbean-finder-shaded</artifactId>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>xbean-xml</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>6.0-3</version>
+    </dependency>
   </dependencies>
 
   <properties>

Modified: openejb/trunk/maven-plugins/spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/SpiMojo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/maven-plugins/spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/SpiMojo.java?rev=1291672&r1=1291671&r2=1291672&view=diff
==============================================================================
--- openejb/trunk/maven-plugins/spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/SpiMojo.java
(original)
+++ openejb/trunk/maven-plugins/spi-helper-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/spi/SpiMojo.java
Tue Feb 21 09:25:16 2012
@@ -5,7 +5,7 @@ import org.apache.maven.plugin.AbstractM
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
-import org.apache.openejb.maven.plugin.spi.xml.Scan;
+import org.apache.openejb.xbean.xml.Scan;
 import org.apache.xbean.finder.Annotated;
 import org.apache.xbean.finder.AnnotationFinder;
 import org.apache.xbean.finder.archive.Archive;
@@ -21,7 +21,10 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -29,6 +32,31 @@ import java.util.Set;
  * @phase compile
  */
 public class SpiMojo extends AbstractMojo {
+    private static final Map<String, Profile> DEFAULT_PROFILES = new HashMap<String,
Profile>();
+
+    static {
+        final Profile jee6 = new Profile(
+                Arrays.asList( // annotations
+                        "javax.ejb.Singleton",
+                        "javax.ejb.Stateful",
+                        "javax.ejb.Stateless",
+                        "javax.enterprise.inject.Specializes",
+                        "javax.annotation.ManagedBean",
+                        "javax.ejb.MessageDriven",
+
+                        "org.apache.openejb.api.LocalClient",
+                        "org.apache.openejb.api.RemoteClient"
+                ),
+                Arrays.asList( // subclasses
+                        "javax.ws.rs.core.Application"
+                ),
+                new ArrayList<String>( // implementations
+                        // no implementations
+                )
+        );
+        DEFAULT_PROFILES.put("jee6", jee6);
+    }
+
     /**
      * @parameter default-value="${project.build.outputDirectory}"
      * @required
@@ -58,6 +86,11 @@ public class SpiMojo extends AbstractMoj
     private List<String> implementations;
 
     /**
+     * @parameter
+     */
+    private List<String> profiles;
+
+    /**
      * @parameter expression="${spi.output}" default-value="META-INF/scan.xml"
      */
     private String outputFilename;
@@ -69,66 +102,98 @@ public class SpiMojo extends AbstractMoj
 
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
+        //
+        // create profiles to use
+        //
+        final List<Profile> profileToUse = new ArrayList<Profile>();
+        if (profiles != null) {
+            for (String profile : profiles) {
+                if (DEFAULT_PROFILES.containsKey(profile)) {
+                    profileToUse.add(DEFAULT_PROFILES.get(profile));
+                } else {
+                    getLog().info("can't find profile " + profile + ", available ones are
" + DEFAULT_PROFILES.keySet());
+                }
+            }
+        }
+        profileToUse.add(new Profile(annotations, subclasses, implementations));
+
+        // the result
+        final Scan scan = new Scan();
+
         try {
             final ClassLoader loader = createClassLoader();
             final Archive archive = new FileArchive(loader, module);
             final AnnotationFinder finder = new AnnotationFinder(archive);
             finder.link();
 
-            final Scan scan = new Scan();
-
             //
             // find classes
             //
 
-            if (annotations != null) {
-                for (String annotation : annotations) {
-                    final Class<? extends Annotation> annClazz = (Class<? extends
Annotation>) load(loader, annotation);
-
-                    if (!useMeta) {
-                        for (Class<?> clazz : finder.findAnnotatedClasses(annClazz))
{
-                            scan.getClassname().add(clazz.getName());
-                        }
-                    } else {
-                        for (Annotated<Class<?>> clazz : finder.findMetaAnnotatedClasses(annClazz))
{
-                            scan.getClassname().add(clazz.get().getName());
+            for (Profile profile : profileToUse) {
+                if (profile.getAnnotations() != null) {
+                    for (String annotation : profile.getAnnotations()) {
+                        final Class<? extends Annotation> annClazz;
+                        try {
+                            annClazz = (Class<? extends Annotation>) load(loader, annotation);
+                        } catch (MojoFailureException mfe) {
+                            getLog().warn("can't find " + annotation);
+                            continue;
                         }
-                    }
 
-                    if (!useMeta) {
-                        for (Field clazz : finder.findAnnotatedFields(annClazz)) {
-                            scan.getClassname().add(clazz.getDeclaringClass().getName());
-                        }
-                    } else {
-                        for (Annotated<Field> clazz : finder.findMetaAnnotatedFields(annClazz))
{
-                            scan.getClassname().add(clazz.get().getDeclaringClass().getName());
+                        if (!useMeta) {
+                            for (Class<?> clazz : finder.findAnnotatedClasses(annClazz))
{
+                                scan.getClassname().add(clazz.getName());
+                            }
+                        } else {
+                            for (Annotated<Class<?>> clazz : finder.findMetaAnnotatedClasses(annClazz))
{
+                                scan.getClassname().add(clazz.get().getName());
+                            }
                         }
-                    }
 
-                    if (!useMeta) {
-                        for (Method clazz : finder.findAnnotatedMethods(annClazz)) {
-                            scan.getClassname().add(clazz.getDeclaringClass().getName());
-                        }
-                    } else {
-                        for (Annotated<Method> clazz : finder.findMetaAnnotatedMethods(annClazz))
{
-                            scan.getClassname().add(clazz.get().getDeclaringClass().getName());
+                        if (!useMeta) {
+                            for (Field clazz : finder.findAnnotatedFields(annClazz)) {
+                                scan.getClassname().add(clazz.getDeclaringClass().getName());
+                            }
+                        } else {
+                            for (Annotated<Field> clazz : finder.findMetaAnnotatedFields(annClazz))
{
+                                scan.getClassname().add(clazz.get().getDeclaringClass().getName());
+                            }
+                        }
+
+                        if (!useMeta) {
+                            for (Method clazz : finder.findAnnotatedMethods(annClazz)) {
+                                scan.getClassname().add(clazz.getDeclaringClass().getName());
+                            }
+                        } else {
+                            for (Annotated<Method> clazz : finder.findMetaAnnotatedMethods(annClazz))
{
+                                scan.getClassname().add(clazz.get().getDeclaringClass().getName());
+                            }
                         }
                     }
                 }
-            }
 
-            if (subclasses != null) {
-                for (String subclass : subclasses) {
-                    for (Class<?> clazz : finder.findSubclasses(load(loader, subclass)))
{
-                        scan.getClassname().add(clazz.getName());
+                if (profile.getSubclasses() != null) {
+                    for (String subclass : profile.getSubclasses()) {
+                        try {
+                            for (Class<?> clazz : finder.findSubclasses(load(loader,
subclass))) {
+                                scan.getClassname().add(clazz.getName());
+                            }
+                        } catch (MojoFailureException mfe) {
+                            getLog().warn("can't find " + subclass);
+                        }
                     }
                 }
-            }
 
-            if (implementations != null) {
-                for (String implementation : implementations) {
-                    for (Class<?> clazz : finder.findImplementations(load(loader, implementation)))
{
-                        scan.getClassname().add(clazz.getName());
+                if (profile.getImplementations() != null) {
+                    for (String implementation : profile.getImplementations()) {
+                        try {
+                            for (Class<?> clazz : finder.findImplementations(load(loader,
implementation))) {
+                                scan.getClassname().add(clazz.getName());
+                            }
+                        } catch (MojoFailureException mfe) {
+                            getLog().warn("can't find " + implementation);
+                        }
                     }
                 }
             }
@@ -188,4 +253,28 @@ public class SpiMojo extends AbstractMoj
         }
         return new URLClassLoader(urls.toArray(new URL[urls.size()]), Thread.currentThread().getContextClassLoader());
     }
+
+    public static final class Profile {
+        private List<String> annotations;
+        private List<String> subclasses;
+        private List<String> implementations;
+
+        public Profile(final List<String> annotations, final List<String> subclasses,
final List<String> implementations) {
+            this.annotations = annotations;
+            this.subclasses = subclasses;
+            this.implementations = implementations;
+        }
+
+        public List<String> getAnnotations() {
+            return annotations;
+        }
+
+        public List<String> getSubclasses() {
+            return subclasses;
+        }
+
+        public List<String> getImplementations() {
+            return implementations;
+        }
+    }
 }

Added: openejb/trunk/maven-plugins/xbean-xml/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/maven-plugins/xbean-xml/pom.xml?rev=1291672&view=auto
==============================================================================
--- openejb/trunk/maven-plugins/xbean-xml/pom.xml (added)
+++ openejb/trunk/maven-plugins/xbean-xml/pom.xml Tue Feb 21 09:25:16 2012
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>maven-plugins-parent</artifactId>
+    <groupId>org.apache.openejb</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>xbean-xml</artifactId>
+  <name>XBean XML</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.xbean</groupId>
+      <artifactId>xbean-finder-shaded</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Added: openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/openejb/xbean/xml/Scan.java
URL: http://svn.apache.org/viewvc/openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/openejb/xbean/xml/Scan.java?rev=1291672&view=auto
==============================================================================
--- openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/openejb/xbean/xml/Scan.java
(added)
+++ openejb/trunk/maven-plugins/xbean-xml/src/main/java/org/apache/openejb/xbean/xml/Scan.java
Tue Feb 21 09:25:16 2012
@@ -0,0 +1,37 @@
+package org.apache.openejb.xbean.xml;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.HashSet;
+import java.util.Set;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Scan {
+    @XmlElementWrapper(name = "classes")
+    @XmlElement(name = "class")
+    private Set<String> classname = new HashSet<String>();
+
+    @XmlElementWrapper(name = "packages")
+    @XmlElement(name = "package")
+    private Set<String> packagename = new HashSet<String>();
+
+    public Set<String> getClassname() {
+        return classname;
+    }
+
+    public void setClassname(Set<String> classname) {
+        this.classname = classname;
+    }
+
+    public Set<String> getPackagename() {
+        return packagename;
+    }
+
+    public void setPackagename(Set<String> packagename) {
+        this.packagename = packagename;
+    }
+}



Mime
View raw message