felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r586370 - in /felix/trunk/ipojo: ant/src/main/java/org/apache/felix/ipojo/task/ arch/ core/ manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ plugin/src/main/java/org/apache/felix/ipojo/plugin/
Date Fri, 19 Oct 2007 10:41:20 GMT
Author: clement
Date: Fri Oct 19 03:41:11 2007
New Revision: 586370

URL: http://svn.apache.org/viewvc?rev=586370&view=rev
Log:
Commit the patch for the FELIX-398 issue. 
Adapt a little the patch to propagate the ignoreAnnotation flag to the manipulator.
Update the Ant task to support the ignoreAnnotation attribute.
Now, iPOJO Core and Arch set this flag to true to improve compilation time.

Modified:
    felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
    felix/trunk/ipojo/arch/pom.xml
    felix/trunk/ipojo/core/pom.xml
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
    felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java

Modified: felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java?rev=586370&r1=586369&r2=586370&view=diff
==============================================================================
--- felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java (original)
+++ felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java Fri Oct
19 03:41:11 2007
@@ -45,6 +45,11 @@
      * Output bundle.
      */
     private File m_output;
+
+    /**
+     * Flag describing if we need to ignore annotation of not.
+     */
+    private boolean m_ignoreAnnotations = false;
     
     /**
      * Set the metadata file.
@@ -71,6 +76,14 @@
     }
     
     /**
+     * Set if we need to ignore annotations or not.
+     * @param flag : true if we need to ignore annotations.
+     */
+    public void setIgnoreAnnotations(boolean flag) {
+        m_ignoreAnnotations = flag;
+    }
+    
+    /**
      * Execute the Ant Task.
      * @see org.apache.tools.ant.Task#execute()
      */
@@ -89,8 +102,14 @@
         if (m_metadata == null) {
             m_metadata = new File("./metadata.xml");
             if (!m_metadata.exists()) {
-                System.out.println("No metadata file found - try to use only annotations");
-                m_metadata = null;
+             // Verify if annotations are ignored
+                if (m_ignoreAnnotations) {
+                    System.out.println("No metadata file found - ignore annotations");
+                    return;
+                } else {
+                    System.out.println("No metadata file found - try to use only annotations");
+                    m_metadata = null;
+                }
             } else {
                 System.out.println("Metadata File : " + m_metadata.getAbsolutePath());
             }
@@ -115,6 +134,9 @@
         }
         
         Pojoization pojo = new Pojoization();
+        if (! m_ignoreAnnotations) {
+            pojo.setAnnotationProcessing();
+        }
         pojo.pojoization(m_input, m_output, m_metadata);
         for (int i = 0; i < pojo.getWarnings().size(); i++) {
             System.out.println((String) pojo.getWarnings().get(i));

Modified: felix/trunk/ipojo/arch/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/arch/pom.xml?rev=586370&r1=586369&r2=586370&view=diff
==============================================================================
--- felix/trunk/ipojo/arch/pom.xml (original)
+++ felix/trunk/ipojo/arch/pom.xml Fri Oct 19 03:41:11 2007
@@ -51,7 +51,7 @@
 	              <goal>ipojo-bundle</goal>
                </goals>
             <configuration>
-   				<metadata>metadata.xml</metadata>
+   				<ignoreAnnotations>true</ignoreAnnotations>
             </configuration>
           </execution>
         </executions>

Modified: felix/trunk/ipojo/core/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/pom.xml?rev=586370&r1=586369&r2=586370&view=diff
==============================================================================
--- felix/trunk/ipojo/core/pom.xml (original)
+++ felix/trunk/ipojo/core/pom.xml Fri Oct 19 03:41:11 2007
@@ -90,6 +90,7 @@
                </goals>
             <configuration>
    				<metadata>metadata.xml</metadata>
+   				<ignoreAnnotations>true</ignoreAnnotations>
             </configuration>
           </execution>
         </executions>

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java?rev=586370&r1=586369&r2=586370&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
(original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
Fri Oct 19 03:41:11 2007
@@ -86,6 +86,11 @@
     private List m_referredPackages;
 
     /**
+     * Flag describing if we need of not compute annotations.
+     */
+    private boolean m_ignoreAnnotations;
+
+    /**
      * Add an error in the error list.
      * @param mes : error message.
      */
@@ -104,6 +109,13 @@
     public List getErrors() {
         return m_errors;
     }
+    
+    /**
+     * Activate annotation processing.
+     */
+    public void setAnnotationProcessing() {
+        m_ignoreAnnotations = false;
+    }
 
     /**
      * Manipulate a normal bundle.
@@ -283,7 +295,9 @@
                         in = in2;
                     }
                     currIn.close();
-                    computeAnnotations(in);
+                    if (! m_ignoreAnnotations) {
+                        computeAnnotations(in);
+                    }
                     // Check if we need to manipulate the class
                     for (int i = 0; i < m_components.size(); i++) {
                         ComponentInfo ci = (ComponentInfo) m_components.get(i);

Modified: felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java?rev=586370&r1=586369&r2=586370&view=diff
==============================================================================
--- felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
(original)
+++ felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
Fri Oct 19 03:41:11 2007
@@ -19,11 +19,14 @@
 package org.apache.felix.ipojo.plugin;
 
 import java.io.File;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.felix.ipojo.manipulator.Pojoization;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
 
 /**
  * Package an OSGi jar "bundle" as an "iPOJO bundle".
@@ -64,24 +67,61 @@
     
     /**
      * Metadata file location.
-     * @parameter expression="${metadata}" default-value="metadata.xml"
+     * @parameter alias="metadata" default-value="metadata.xml"
      */
     private String m_metadata;
 
     /**
+     * The Maven project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject m_project;
+
+    /**
+     * Project types which this plugin supports.
+     * @parameter
+     */
+    private List m_supportedProjectTypes = Arrays.asList(new String[]{"bundle"});
+
+    /**
+     * Ignore annotations parameter.
+     * @parameter alias="ignoreAnnotations" default-value="false"
+     */
+    private boolean m_ignoreAnnotations;
+
+    protected MavenProject getProject() {
+        return this.m_project;
+    }
+
+    /**
      * Execute method : launch the pojoization.
      * @throws MojoExecutionException : an exception occurs.
      * @throws MojoFailureException : an failure occurs.
      * @see org.apache.maven.plugin.AbstractMojo#execute()
      */
     public void execute() throws MojoExecutionException, MojoFailureException {
+        // ignore project types not supported, useful when the plugin is configured in the
parent pom
+        if (!this.m_supportedProjectTypes.contains(this.getProject().getArtifact().getType()))
{
+            this.getLog().debug("Ignoring project " + this.getProject().getArtifact() + "
: type " + this.getProject().getArtifact().getType() + " is not supported by ipojo plugin,
supported types are " + this.m_supportedProjectTypes);
+            return;
+        }
+
         getLog().info("Start bundle manipulation");
         // Get metadata file
         File meta = new File(m_outputDirectory + "/" + m_metadata);
         getLog().info("Metadata File : " + meta.getAbsolutePath());
         if (!meta.exists()) {
-            getLog().info("No metadata file found - try to use only annotations");
-            meta = null;
+            // Verify if annotations are ignored
+            if (m_ignoreAnnotations) {
+                getLog().info("No metadata file found - ignore annotations");
+                return;
+            } else {
+                getLog().info("No metadata file found - try to use only annotations");
+                meta = null;
+            }
         }
 
         // Get input bundle
@@ -94,6 +134,7 @@
         File out = new File(m_buildDirectory + "/_out.jar");
         
         Pojoization pojo = new Pojoization();
+        if (!m_ignoreAnnotations) { pojo.setAnnotationProcessing(); }
         pojo.pojoization(in, out, meta);
         for (int i = 0; i < pojo.getWarnings().size(); i++) {
             getLog().warn((String) pojo.getWarnings().get(i));



Mime
View raw message