Author: gcc
Date: Mon Aug 22 13:49:02 2011
New Revision: 1160266

URL: http://svn.apache.org/viewvc?rev=1160266&view=rev
Log:
ARIES-733
Added support for Use-Bundle generation into the APPLICATION.MF.  Configured 
using plug-in configuration as follows:

<configuration> 
  <instructions> 
    <Use-Bundle>org.acme.my.Bundle;version="[1.0.0, 1.1.0)"</Use-Bundle> 
  </instructions> 
</configuration> 

Simply takes the value from the element and write it out in the Use-Bundle 
header.  E.g. the above becomes

Use-Bundle: org.acme.my.Bundle;version="[1.0.0, 1.1.0)"

Does not perform any validation of the Use-Bundle entry against any of the 
project dependencies.

Added:
    
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub4.java
    
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-without-manifest/
    
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-without-manifest/plugin-config.xml
Modified:
    
aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java
    
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java
    
aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact01/1.0-SNAPSHOT/maven-artifact01-1.0-SNAPSHOT.jar
    
aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact02/1.0-SNAPSHOT/maven-artifact02-1.0-SNAPSHOT.jar
    
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-with-descriptor/plugin-config.xml

Modified: 
aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java?rev=1160266&r1=1160265&r2=1160266&view=diff
==============================================================================
--- 
aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java
 (original)
+++ 
aries/trunk/eba-maven-plugin/src/main/java/org/apache/aries/plugin/eba/EbaMojo.java
 Mon Aug 22 13:49:02 2011
@@ -69,6 +69,7 @@ public class EbaMojo
     private static final String APPLICATION_CONTENT = "Application-Content";
     private static final String APPLICATION_EXPORTSERVICE = 
"Application-ExportService";
     private static final String APPLICATION_IMPORTSERVICE = 
"Application-ImportService";
+    private static final String APPLICATION_USEBUNDLE = "Use-Bundle";
 
     /**
      * Coverter for maven pom values to OSGi manifest values (pulled in from 
the maven-bundle-plugin)
@@ -434,6 +435,11 @@ public class EbaMojo
                                FileUtils.fileAppend(fileName, 
APPLICATION_IMPORTSERVICE + ": "
                                                + 
instructions.get(APPLICATION_IMPORTSERVICE) + "\n");
                        }
+                       if (instructions.containsKey(APPLICATION_USEBUNDLE)) {
+                               FileUtils.fileAppend(fileName, 
APPLICATION_USEBUNDLE + ": "
+                                               + 
instructions.get(APPLICATION_USEBUNDLE) + "\n");
+                       }
+                        // Add any use bundle entry
 
                } catch (Exception e) {
                        throw new MojoExecutionException(

Modified: 
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java?rev=1160266&r1=1160265&r2=1160266&view=diff
==============================================================================
--- 
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java
 (original)
+++ 
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/EbaMojoTest.java
 Mon Aug 22 13:49:02 2011
@@ -19,7 +19,9 @@ package org.apache.aries.plugin.eba;
  * under the License.
  */
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
@@ -202,6 +204,83 @@ public class EbaMojoTest
         assertEquals("Missing files: " + expectedFiles,  0, missing);
     }
 
+    public void testApplicationManifestGeneration()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(),
+                                 
"target/test-classes/unit/basic-eba-without-manifest/plugin-config.xml" );
+
+        EbaMojo mojo = ( EbaMojo ) lookupMojo( "eba", testPom );
+
+        assertNotNull( mojo );
+
+        String finalName = ( String ) getVariableValueFromObject( mojo, 
"finalName" );
+
+        String workDir = ( String ) getVariableValueFromObject( mojo, 
"workDirectory" );
+
+        String outputDir = ( String ) getVariableValueFromObject( mojo, 
"outputDirectory" );
+
+        mojo.execute();
+
+
+        //check the generated eba file
+        File ebaFile = new File( outputDir, finalName + ".eba" );
+
+        assertTrue( ebaFile.exists() );
+
+        //expected files/directories inside the eba file
+        List expectedFiles = new ArrayList();
+
+        expectedFiles.add( 
"META-INF/maven/org.apache.maven.test/maven-eba-test/pom.properties" );
+        expectedFiles.add( 
"META-INF/maven/org.apache.maven.test/maven-eba-test/pom.xml" );
+        expectedFiles.add( 
"META-INF/maven/org.apache.maven.test/maven-eba-test/" );
+        expectedFiles.add( "META-INF/maven/org.apache.maven.test/" );
+        expectedFiles.add( "META-INF/maven/" );
+        expectedFiles.add( "META-INF/APPLICATION.MF" );
+        expectedFiles.add( "META-INF/" );
+        expectedFiles.add( "maven-artifact01-1.0-SNAPSHOT.jar" );
+        expectedFiles.add( "maven-artifact02-1.0-SNAPSHOT.jar" );
+
+        ZipFile eba = new ZipFile( ebaFile );
+
+        Enumeration entries = eba.getEntries();
+
+        assertTrue( entries.hasMoreElements() );
+
+        int missing = getSizeOfExpectedFiles(entries, expectedFiles);
+        assertEquals("Missing files: " + expectedFiles,  0, missing);
+
+       //Test Application-ImportService Application-ExportService and 
Use-Bundle inclusion
+        ZipEntry entry = eba.getEntry("META-INF/APPLICATION.MF");
+        BufferedReader br = new BufferedReader(new 
InputStreamReader(eba.getInputStream(entry)));
+
+        String appServiceExport = new String("Application-ExportService: 
test.ExportService");
+        String appServiceImport = new String("Application-ImportService: 
test.ImportService");
+        String useBundle = new String("Use-Bundle: 
org.apache.aries.test.Bundle;version=1.0.0-SNAPSHOT");
+        Boolean foundAppExport=false;
+        Boolean foundAppImport=false;
+        Boolean foundUseBundle=false;
+        
+        String line;
+        while ((line = br.readLine()) != null) {
+               if (line.contains(new String("Application-ExportService"))) {
+                       assertEquals(appServiceExport, line);
+                       foundAppExport = true;
+               }
+               if (line.contains(new String("Application-ImportService"))) {
+                       assertEquals(appServiceImport, line);
+                       foundAppImport = true;
+               }
+               if (line.contains(new String("Use-Bundle"))) {
+                       assertEquals(useBundle, line);
+                       foundUseBundle = true;
+               }
+               }
+        assertTrue("Found Application-ExportService:", foundAppExport);
+        assertTrue("Found Application-ImportService:", foundAppImport);
+        assertTrue("Found Use-Bundle:", foundUseBundle);
+    }
+
     private int getSizeOfExpectedFiles( Enumeration entries, List 
expectedFiles )
     {
         while( entries.hasMoreElements() )

Added: 
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub4.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub4.java?rev=1160266&view=auto
==============================================================================
--- 
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub4.java
 (added)
+++ 
aries/trunk/eba-maven-plugin/src/test/java/org/apache/aries/plugin/eba/stubs/EbaMavenProjectStub4.java
 Mon Aug 22 13:49:02 2011
@@ -0,0 +1,31 @@
+package org.apache.aries.plugin.eba.stubs;
+
+/*
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+public class EbaMavenProjectStub4
+    extends EbaMavenProjectStub
+{
+    public File getFile()
+    {
+        return new File( getBasedir(), 
"src/test/resources/unit/basic-eba-without-manifest/plugin-config.xml" );
+    }
+}

Modified: 
aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact01/1.0-SNAPSHOT/maven-artifact01-1.0-SNAPSHOT.jar
URL: 
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact01/1.0-SNAPSHOT/maven-artifact01-1.0-SNAPSHOT.jar?rev=1160266&r1=1160265&r2=1160266&view=diff
==============================================================================
Files 
aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact01/1.0-SNAPSHOT/maven-artifact01-1.0-SNAPSHOT.jar
 (original) and 
aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact01/1.0-SNAPSHOT/maven-artifact01-1.0-SNAPSHOT.jar
 Mon Aug 22 13:49:02 2011 differ

Modified: 
aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact02/1.0-SNAPSHOT/maven-artifact02-1.0-SNAPSHOT.jar
URL: 
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact02/1.0-SNAPSHOT/maven-artifact02-1.0-SNAPSHOT.jar?rev=1160266&r1=1160265&r2=1160266&view=diff
==============================================================================
Files 
aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact02/1.0-SNAPSHOT/maven-artifact02-1.0-SNAPSHOT.jar
 (original) and 
aries/trunk/eba-maven-plugin/src/test/remote-repo/org/apache/maven/test/maven-artifact02/1.0-SNAPSHOT/maven-artifact02-1.0-SNAPSHOT.jar
 Mon Aug 22 13:49:02 2011 differ

Modified: 
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-with-descriptor/plugin-config.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-with-descriptor/plugin-config.xml?rev=1160266&r1=1160265&r2=1160266&view=diff
==============================================================================
--- 
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-with-descriptor/plugin-config.xml
 (original)
+++ 
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-with-descriptor/plugin-config.xml
 Mon Aug 22 13:49:02 2011
@@ -26,11 +26,11 @@ under the License.
                  
<ebaSourceDirectory>${basedir}/src/test/resources/unit/basic-eba-with-descriptor/src/main/eba</ebaSourceDirectory>
                  
<applicationManifestFile>${basedir}/src/test/resources/unit/basic-eba-with-descriptor/src/main/eba/META-INF/APPLICATION.MF</applicationManifestFile>
                  <includeJar>false</includeJar>
-          <addMavenDescriptor>true</addMavenDescriptor>
-          <includeEmptyDirs>true</includeEmptyDirs>
+                  <addMavenDescriptor>true</addMavenDescriptor>
+                  <includeEmptyDirs>true</includeEmptyDirs>
                  
<manifestFile>${basedir}/src/test/resources/unit/basic-eba-with-descriptor/src/main/eba/META-INF/MANIFEST.MF</manifestFile>
                  
<workDirectory>${basedir}/target/unit/basic-eba-with-descriptor/target/eba-test-with-descriptor</workDirectory>
-          
<sharedResources>${basedir}/target/unit/basic-eba-with-descriptor/target/maven-shared-archive-resources</sharedResources>
+                  
<sharedResources>${basedir}/target/unit/basic-eba-with-descriptor/target/maven-shared-archive-resources</sharedResources>
                  
<outputDirectory>${basedir}/target/unit/basic-eba-with-descriptor/target</outputDirectory>
                  <finalName>test-eba-with-descriptor</finalName>
                  <project 
implementation="org.apache.aries.plugin.eba.stubs.EbaMavenProjectStub2" />

Added: 
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-without-manifest/plugin-config.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-without-manifest/plugin-config.xml?rev=1160266&view=auto
==============================================================================
--- 
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-without-manifest/plugin-config.xml
 (added)
+++ 
aries/trunk/eba-maven-plugin/src/test/resources/unit/basic-eba-without-manifest/plugin-config.xml
 Mon Aug 22 13:49:02 2011
@@ -0,0 +1,45 @@
+<!--
+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
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>eba-maven-plugin</artifactId>
+               <configuration>
+                 
<ebaSourceDirectory>${basedir}/src/test/resources/unit/basic-eba-without-manifest/src/main/eba</ebaSourceDirectory>
+                  <generateManifest>true</generateManifest>
+                  <instructions>
+                     
<Application-ExportService>test.ExportService</Application-ExportService>
+                     
<Application-ImportService>test.ImportService</Application-ImportService>
+                     
<Use-Bundle>org.apache.aries.test.Bundle;version=1.0.0-SNAPSHOT</Use-Bundle>
+                  </instructions>
+                 <includeJar>false</includeJar>
+                  <addMavenDescriptor>true</addMavenDescriptor>
+                  <includeEmptyDirs>true</includeEmptyDirs>
+                 
<workDirectory>${basedir}/target/unit/basic-eba-without-manifest/target/eba-test-without-manifest</workDirectory>
+                  
<sharedResources>${basedir}/target/unit/basic-eba-without-manifest/target/maven-shared-archive-resources</sharedResources>
+                 
<outputDirectory>${basedir}/target/unit/basic-eba-without-manifest/target</outputDirectory>
+                 <finalName>test-eba-without-manifest</finalName>
+                 <project 
implementation="org.apache.aries.plugin.eba.stubs.EbaMavenProjectStub4" />
+               </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>


Reply via email to