felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r432246 - in /incubator/felix/sandbox/akarasulu/itest: maven-felix-integration/pom.xml maven-felix-integration/src/main/java/org/apache/felix/integration/FelixRunMojo.java simple-test/pom.xml
Date Thu, 17 Aug 2006 14:13:39 GMT
Author: akarasulu
Date: Thu Aug 17 07:13:38 2006
New Revision: 432246

URL: http://svn.apache.org/viewvc?rev=432246&view=rev
Log:
making mojo delete old felix cache directory if present before start and allowing for user
specified exclusions to autostart list

Modified:
    incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml
    incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixRunMojo.java
    incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml

Modified: incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml?rev=432246&r1=432245&r2=432246&view=diff
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml (original)
+++ incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/pom.xml Thu Aug 17 07:13:38
2006
@@ -16,7 +16,12 @@
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>2.0</version>
-    </dependency>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.0.5</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.framework</artifactId>

Modified: incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixRunMojo.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixRunMojo.java?rev=432246&r1=432245&r2=432246&view=diff
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixRunMojo.java
(original)
+++ incubator/felix/sandbox/akarasulu/itest/maven-felix-integration/src/main/java/org/apache/felix/integration/FelixRunMojo.java
Thu Aug 17 07:13:38 2006
@@ -2,10 +2,14 @@
 
 
 import java.io.File;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.felix.framework.Felix;
 import org.apache.felix.framework.util.MutablePropertyResolver;
@@ -15,6 +19,7 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
 
 
 /**
@@ -56,15 +61,39 @@
     private MavenProject project;
 
     /**
+     * @parameter
+     */
+    private List exclusions;
+    
+    /**
      * The felix container used to run the integration tests.
      */
     private Felix felixContainer = new Felix();
 
-    
+
     public void execute() throws MojoExecutionException, MojoFailureException
     {
-        getLog().info( "felix.cache.dir=" + felixCacheDir.getAbsolutePath() );
+        // -------------------------------------------------------------------
+        // Clean out the old cache directory if it exists
+        // -------------------------------------------------------------------
         
+        if ( felixCacheDir.exists() )
+        {
+            try
+            {
+                FileUtils.forceDelete( felixCacheDir );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoFailureException( "failed to delete old Felix cache directory:
" 
+                    + felixCacheDir.getAbsolutePath() );
+            }
+        }
+
+        // -------------------------------------------------------------------
+        // Build the properties we will stuff into the resolver
+        // -------------------------------------------------------------------
+
         Properties props = new Properties();
         props.put( "felix.cache.dir", felixCacheDir.getAbsolutePath() );
         props.put( "felix.cache.profile", felixCacheProfile );
@@ -84,16 +113,16 @@
             e.printStackTrace();
         }
         
+        // -------------------------------------------------------------------
+        // Start up Felix with resolver and shut it down
+        // -------------------------------------------------------------------
+
         MutablePropertyResolver resolver = new MutablePropertyResolverImpl(props);
-        
         felixContainer.start( resolver, new ArrayList() );
-
         getLog().info( "-=============================-" );
         getLog().info( "| Felix: successfully started |" );
         getLog().info( "-=============================-" );
-        
         felixContainer.shutdown();
-        
         getLog().info( "-==============================-" );
         getLog().info( "| Felix: successfully shutdown |" );
         getLog().info( "-==============================-" );
@@ -102,23 +131,70 @@
     
     public String getAutoStart() throws MalformedURLException
     {
+        List included = new ArrayList();
+        List excluded = new ArrayList();
+        if ( exclusions == null )
+        {
+            exclusions = Collections.EMPTY_LIST;
+        }
+        
         StringBuffer buf = new StringBuffer();
+        StringBuffer keyBuf = new StringBuffer();
         for ( Iterator ii = project.getDependencyArtifacts().iterator(); ii.hasNext(); /**/)

         {
             Artifact dep = ( Artifact ) ii.next();
+            keyBuf.setLength( 0 );
+            keyBuf.append( dep.getGroupId() ).append( ":" ).append( dep.getArtifactId() );
+            String depKey = keyBuf.toString();
+            
+            // -------------------------------------------------------------------
+            // Add only provided dependent artifacts that have not been excluded
+            // -------------------------------------------------------------------
+            
             if ( dep.getScope().equalsIgnoreCase( "provided" ) )
             {
-                if ( dep.getArtifactId().equalsIgnoreCase( "org.osgi.core" ) )
+                if ( dep.getArtifactId().equalsIgnoreCase( "org.osgi.core" ) ||
+                     exclusions.contains( depKey ) )
                 {
+                    excluded.add( depKey );
                     continue;
                 }
                 
+                included.add( depKey );
                 buf.append( dep.getFile().toURL() );
                 buf.append( " " );
             }
         }
         
-         buf.append( felixTestBundle.toURL() );
+        keyBuf.setLength( 0 );
+        keyBuf.append( project.getGroupId() ).append( ":" ).append( project.getArtifactId()
);
+        String depKey = keyBuf.toString();
+        included.add( depKey );
+        buf.append( felixTestBundle.toURL() );
+        
+        // -------------------------------------------------------------------
+        // Report what was included and what was excluded
+        // -------------------------------------------------------------------
+        
+        getLog().info( "" );
+        getLog().info( "\t\tJars/Bundles Included for Autostart" );
+        getLog().info( "\t\t-----------------------------------" );
+        getLog().info( "" );
+        for ( Iterator ii = included.iterator(); ii.hasNext(); /**/ )
+        {
+            getLog().info( "\t\t" + ( String ) ii.next() );
+        }
+        getLog().info( "" );
+        getLog().info( "" );
+        getLog().info( "\t\tJars/Bundles Excluded from Autostart" );
+        getLog().info( "\t\t------------------------------------" );
+        getLog().info( "" );
+        for ( Iterator ii = excluded.iterator(); ii.hasNext(); /**/ )
+        {
+            getLog().info( "\t\t" + ( String ) ii.next() );
+        }
+        getLog().info( "" );
+        getLog().info( "" );
         return buf.toString();
     }
 }

Modified: incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml?rev=432246&r1=432245&r2=432246&view=diff
==============================================================================
--- incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml (original)
+++ incubator/felix/sandbox/akarasulu/itest/simple-test/pom.xml Thu Aug 17 07:13:38 2006
@@ -15,6 +15,14 @@
       <version>0.8.0-SNAPSHOT</version>
       <scope>provided</scope>
     </dependency>
+    
+    <!-- adding this as a test for exclusions: not a bundle so we want to exclude in run
-->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
@@ -26,6 +34,9 @@
              <id>run</id>
              <configuration>
                <felixCacheDir>${basedir}/target/.felix</felixCacheDir>
+               <exclusions>
+                 <exclusion>junit:junit</exclusion>
+               </exclusions>
              </configuration>
              <goals>
                <goal>run</goal>



Mime
View raw message