Author: carlos
Date: Sun Feb 4 14:56:25 2007
New Revision: 503503
URL: http://svn.apache.org/viewvc?view=rev&rev=503503
Log:
Exclude META-INF contents from packages
Export version of packages from bundle version
Added:
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/aQute/lib/osgi/PatchedBuilder.java
(with props)
maven/sandbox/plugins/maven-bundle-plugin/src/test/resources/org.apache.maven.maven-model_2.1.0.SNAPSHOT.jar
(with props)
Modified:
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java
Added:
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/aQute/lib/osgi/PatchedBuilder.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-bundle-plugin/src/main/java/aQute/lib/osgi/PatchedBuilder.java?view=auto&rev=503503
==============================================================================
---
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/aQute/lib/osgi/PatchedBuilder.java
(added)
+++
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/aQute/lib/osgi/PatchedBuilder.java
Sun Feb 4 14:56:25 2007
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+package aQute.lib.osgi;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Extension of [EMAIL PROTECTED] aQute.lib.osgi.Analyzer} for some patches
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class PatchedBuilder
+ extends Builder
+{
+
+ /**
+ * This method should be in [EMAIL PROTECTED] Analyzer}
+ *
+ * @param dot
+ * @param bundleClasspath
+ * @param contained
+ * @param referred
+ * @param uses
+ * @return
+ * @throws IOException
+ */
+ Map analyzeBundleClasspath( Jar dot, Map bundleClasspath, Map contained,
Map referred, Map uses )
+ throws IOException
+ {
+ Map classSpace = super.analyzeBundleClasspath( dot, bundleClasspath,
contained, referred, uses );
+ String bundleVersion = getProperties().getProperty( BUNDLE_VERSION );
+ for ( Iterator it = contained.entrySet().iterator(); it.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+
+ /* remove packages under META-INF */
+ String packageName = (String) entry.getKey();
+ if ( packageName.startsWith( "META-INF." ) )
+ {
+ it.remove();
+ }
+
+ /* set package versions to bundle version values */
+ if ( bundleVersion != null )
+ {
+ Map values = (Map) entry.getValue();
+ if ( values.get( "version" ) == null )
+ {
+ values.put( "version", bundleVersion );
+ }
+ }
+
+ }
+ return classSpace;
+ }
+
+}
Propchange:
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/aQute/lib/osgi/PatchedBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/aQute/lib/osgi/PatchedBuilder.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified:
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java?view=diff&rev=503503&r1=503502&r2=503503
==============================================================================
---
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
(original)
+++
maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
Sun Feb 4 14:56:25 2007
@@ -144,7 +144,7 @@
properties.putAll(instructions);
- Builder builder = new Builder();
+ PatchedBuilder builder = new PatchedBuilder();
builder.setBase(baseDir);
builder.setProperties(properties);
builder.setClasspath(classpath);
Modified:
maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java?view=diff&rev=503503&r1=503502&r2=503503
==============================================================================
---
maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java
(original)
+++
maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java
Sun Feb 4 14:56:25 2007
@@ -19,7 +19,15 @@
* under the License.
*/
-import junit.framework.TestCase;
+import java.io.File;
+
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.PlexusTestCase;
+
+import aQute.lib.osgi.Analyzer;
+import aQute.lib.osgi.Jar;
+import aQute.lib.osgi.PatchedBuilder;
/**
* Test for [EMAIL PROTECTED] BundlePlugin}.
@@ -28,7 +36,7 @@
* @version $Id$
*/
public class BundlePluginTest
- extends TestCase
+ extends PlexusTestCase
{
BundlePlugin plugin = new BundlePlugin();
@@ -57,7 +65,7 @@
osgiVersion = plugin.convertVersionToOsgi( "2.1.3.4" );
assertEquals( "2.1.3.4", osgiVersion );
-
+
osgiVersion = plugin.convertVersionToOsgi( "4aug2000r7-dev" );
assertEquals( "0.0.0.4aug2000r7_dev", osgiVersion );
@@ -68,4 +76,26 @@
assertEquals( "1.0.0.alpha_16_20070122_203121_13", osgiVersion );
}
+ public void testReadExportedModules()
+ throws Exception
+ {
+ String osgiBundleFileName =
"org.apache.maven.maven-model_2.1.0.SNAPSHOT.jar";
+ File osgiBundleFile = new File( getBasedir(), "src/test/resources/" +
osgiBundleFileName );
+
+ assertTrue( osgiBundleFile.exists() );
+
+ MavenProject project = new MavenProjectStub();
+ project.setGroupId( "group" );
+ project.setArtifactId( "artifact" );
+ project.setVersion( "1.1.0.0" );
+
+ PatchedBuilder builder = new PatchedBuilder();
+ Jar jar = new Jar( "name", osgiBundleFile );
+ builder.setClasspath( new Jar[] { jar } );
+
+ builder.setProperty( Analyzer.EXPORT_PACKAGE, "*" );
+ builder.build();
+
+ assertEquals( 3, builder.getExports().size() );
+ }
}
Added:
maven/sandbox/plugins/maven-bundle-plugin/src/test/resources/org.apache.maven.maven-model_2.1.0.SNAPSHOT.jar
URL:
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-bundle-plugin/src/test/resources/org.apache.maven.maven-model_2.1.0.SNAPSHOT.jar?view=auto&rev=503503
==============================================================================
Binary file - no diff available.
Propchange:
maven/sandbox/plugins/maven-bundle-plugin/src/test/resources/org.apache.maven.maven-model_2.1.0.SNAPSHOT.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream