You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by sp...@apache.org on 2006/06/05 04:39:35 UTC
svn commit: r411643 - in
/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin:
pom.xml
src/main/java/org/apache/geronimo/eclipse/devtools/ManifestDependenciesMojo.java
Author: sppatel
Date: Sun Jun 4 19:39:34 2006
New Revision: 411643
URL: http://svn.apache.org/viewvc?rev=411643&view=rev
Log:
fix manifest parsing when required bundle contains multiple directives
Modified:
geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/pom.xml
geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ManifestDependenciesMojo.java
Modified: geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/pom.xml?rev=411643&r1=411642&r2=411643&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/pom.xml (original)
+++ geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/pom.xml Sun Jun 4 19:39:34 2006
@@ -8,11 +8,21 @@
<version>1.0-SNAPSHOT</version>
<name>Geronimo Devtools Maven Plugin</name>
+ <parent>
+ <groupId>org.apache.geronimo.devtools</groupId>
+ <artifactId>geronimo-eclipse-plugin</artifactId>
+ <version>1.1</version>
+ </parent>
+
<scm>
<connection>scm:svn:https://svn.apache.org/repos/asf/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin</developerConnection>
<url>https://svn.apache.org/repos/asf/geronimo/devtools/eclipse-plugin/trunk/maven-plugins//maven-geronimodevtools-plugin</url>
- </scm>
+ </scm>
+
+ <build>
+ <sourceDirectory>src/main/java</sourceDirectory>
+ </build>
<dependencies>
<dependency>
@@ -44,6 +54,11 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>1.0-alpha-3</version>
+ </dependency>
+ <dependency>
+ <groupId>eclipse</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>3.2.0</version>
</dependency>
</dependencies>
</project>
Modified: geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ManifestDependenciesMojo.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ManifestDependenciesMojo.java?rev=411643&r1=411642&r2=411643&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ManifestDependenciesMojo.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/ManifestDependenciesMojo.java Sun Jun 4 19:39:34 2006
@@ -23,7 +23,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.StringTokenizer;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
@@ -35,6 +34,9 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
+import org.eclipse.osgi.util.ManifestElement;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
/**
* @goal manifestbundles
@@ -84,6 +86,7 @@
private File eclipseHome;
private Set bundleEntries = new HashSet();
+
private Set exportedEntries = new HashSet();
/*
@@ -99,10 +102,10 @@
while (i.hasNext()) {
addExportedBundles((String) i.next());
}
-
+
getLog().debug("Bundle Entries: " + bundleEntries.toString());
getLog().debug("Exported Entries: " + exportedEntries.toString());
-
+
bundleEntries.addAll(exportedEntries);
List excludeList = new ArrayList();
@@ -121,27 +124,31 @@
}
}
- private void addRequiredBundles(Manifest manifest,
- boolean exportedEntriesOnly) {
+ private void addRequiredBundles(Manifest manifest, boolean exportedEntriesOnly) {
String requiredBundles = getRequiredBundles(manifest);
- if (requiredBundles != null) {
- StringTokenizer st = new StringTokenizer(requiredBundles);
- while (st.hasMoreTokens()) {
- String nextToken = st.nextToken(",");
- String bundleId = getBundleId(nextToken);
- if (exportedEntriesOnly) {
- if (export(nextToken)) {
- exportedEntries.add(bundleId);
+ try {
+ ManifestElement[] elements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requiredBundles);
+ if (elements != null) {
+ for (int i = 0; i < elements.length; i++) {
+ ManifestElement element = elements[i];
+ String bundleId = element.getValue();
+ if (exportedEntriesOnly) {
+ String visibility = element.getDirective(Constants.VISIBILITY_DIRECTIVE);
+ if (Constants.VISIBILITY_REEXPORT.equals(visibility)) {
+ exportedEntries.add(bundleId);
+ }
+ } else {
+ bundleEntries.add(bundleId);
}
- } else {
- bundleEntries.add(bundleId);
}
}
+ } catch (BundleException e) {
+ e.printStackTrace();
}
}
private String getRequiredBundles(Manifest manifest) {
- return manifest.getMainAttributes().getValue("Require-Bundle");
+ return manifest.getMainAttributes().getValue(Constants.REQUIRE_BUNDLE);
}
private Manifest getManifestFromFile(File file) {
@@ -154,17 +161,6 @@
e.printStackTrace();
}
return manifest;
- }
-
- private String getBundleId(String element) {
- String[] entry = element.split(";");
- return entry[0].trim();
- }
-
- private boolean export(String element) {
- String[] entry = element.split(";");
- return entry.length > 1
- && entry[1].trim().equals(MANIFEST_REXPORT_DEPENDENCY);
}
private void addExportedBundles(String bundleId) {