felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r602128 - /felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
Date Fri, 07 Dec 2007 15:43:03 GMT
Author: clement
Date: Fri Dec  7 07:43:03 2007
New Revision: 602128

URL: http://svn.apache.org/viewvc?rev=602128&view=rev
Log:
Commit the patch on the issue FELIX-432.
This patch allow to configure generated bundle attachment to the maven project.
The plugin can now generated two jar files. The first one is the bundle that is produced by
Bnd, and the second one is the same bundle, but iPOJOized (manipulated).
That will be useful if I want to test my bundle in a non-ipojo env. Or if the env is not even
OSGi.

Modified:
    felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java

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=602128&r1=602127&r2=602128&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 Dec  7 07:43:03 2007
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -27,10 +27,11 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
 
 /**
  * Package an OSGi jar "bundle" as an "iPOJO bundle".
- * 
+ *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  * @version $Rev$, $Date$
  * @goal ipojo-bundle
@@ -42,7 +43,7 @@
 
     /**
      * The directory for the generated JAR.
-     * 
+     *
      * @parameter expression="${project.build.directory}"
      * @required
      */
@@ -50,7 +51,7 @@
 
     /**
      * The directory containing generated classes.
-     * 
+     *
      * @parameter expression="${project.build.outputDirectory}"
      * @required
      * @readonly
@@ -59,12 +60,12 @@
 
     /**
      * The name of the generated JAR file.
-     * 
+     *
      * @parameter alias="jarName" expression="${project.build.finalName}"
      * @required
      */
     private String m_jarName;
-    
+
     /**
      * Metadata file location.
      * @parameter alias="metadata" default-value="metadata.xml"
@@ -72,6 +73,13 @@
     private String m_metadata;
 
     /**
+     * If set, the manipulated jar will be attached to the project as a separate artifact.
+     *
+     * @parameter alias="classifier" expression="${ipojo.classifier}"
+     */
+    private String m_classifier;
+
+    /**
      * The Maven project.
      *
      * @parameter expression="${project}"
@@ -81,6 +89,13 @@
     private MavenProject m_project;
 
     /**
+     * Used for attaching new artifacts.
+     * @component
+     * @required
+     */
+    private MavenProjectHelper m_helper;
+
+    /**
      * Project types which this plugin supports.
      * @parameter
      */
@@ -111,7 +126,7 @@
 
         getLog().info("Start bundle manipulation");
         // Get metadata file
-        File meta = new File(m_outputDirectory + "/" + m_metadata);
+        File meta = new File(m_outputDirectory + File.separator + m_metadata);
         getLog().info("Metadata File : " + meta.getAbsolutePath());
         if (!meta.exists()) {
             // Verify if annotations are ignored
@@ -125,14 +140,14 @@
         }
 
         // Get input bundle
-        File in = new File(m_buildDirectory + "/" + m_jarName + ".jar");
+        File in = new File(m_buildDirectory + File.separator + m_jarName + ".jar");
         getLog().info("Input Bundle File : " + in.getAbsolutePath());
         if (!in.exists()) {
             throw new MojoExecutionException("the specified bundle file does not exists");
         }
-        
-        File out = new File(m_buildDirectory + "/_out.jar");
-        
+
+        File out = new File(m_buildDirectory + File.separator + "_out.jar");
+
         Pojoization pojo = new Pojoization();
         if (!m_ignoreAnnotations) { pojo.setAnnotationProcessing(); }
         pojo.pojoization(in, out, meta);
@@ -140,8 +155,16 @@
             getLog().warn((String) pojo.getWarnings().get(i));
         }
         if (pojo.getErrors().size() > 0) { throw new MojoExecutionException((String) pojo.getErrors().get(0));
}
-        in.delete();
-        out.renameTo(in);
+
+        if (m_classifier != null) {
+            // The user want to attach the resulting jar
+            // Do not delete in File
+            m_helper.attachArtifact(m_project, "jar", m_classifier, out);
+        } else {
+            // Usual behavior
+            in.delete();
+            out.renameTo(in);
+        }
         getLog().info("Bundle manipulation - SUCCESS");
     }
 



Mime
View raw message