Modified the Maven OSGi plugin to require:
<bundleActivator>auto-detect</bundleActivator>
To trigger activator detection. If nothing is specified for the bundle
activator tag, then nothing is done. Also modified my existing pom files
accordingly.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@412400 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.bundlerepository/pom.xml b/org.apache.felix.bundlerepository/pom.xml
index b79ca2f..303b206 100644
--- a/org.apache.felix.bundlerepository/pom.xml
+++ b/org.apache.felix.bundlerepository/pom.xml
@@ -37,6 +37,7 @@
<configuration>
<osgiManifest>
<bundleName>BundleRepository</bundleName>
+ <bundleActivator>auto-detect</bundleActivator>
<bundleDescription>Bundle repository service.</bundleDescription>
<bundleDocUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/</bundleDocUrl>
<bundleUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</bundleUrl>
diff --git a/org.apache.felix.http.jetty/pom.xml b/org.apache.felix.http.jetty/pom.xml
index 307dd4e..28ecbc5 100644
--- a/org.apache.felix.http.jetty/pom.xml
+++ b/org.apache.felix.http.jetty/pom.xml
@@ -43,6 +43,7 @@
<osgiManifest>
<bundleName>HTTP Service</bundleName>
<bundleDescription>An implementation of the OSGi HTTP Service using Jetty.</bundleDescription>
+ <bundleActivator>auto-detect</bundleActivator>
<bundleDocUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/</bundleDocUrl>
<bundleUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</bundleUrl>
<bundleSource>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</bundleSource>
diff --git a/org.apache.felix.shell.gui.plugin/pom.xml b/org.apache.felix.shell.gui.plugin/pom.xml
index 6aeba953..e9f63c7 100644
--- a/org.apache.felix.shell.gui.plugin/pom.xml
+++ b/org.apache.felix.shell.gui.plugin/pom.xml
@@ -45,6 +45,7 @@
<osgiManifest>
<bundleName>ShellGUIPlugin</bundleName>
<bundleDescription>A simple set of plugins for the ShellGUI bundle.</bundleDescription>
+ <bundleActivator>auto-detect</bundleActivator>
<bundleDocUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/</bundleDocUrl>
<bundleUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</bundleUrl>
<bundleSource>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</bundleSource>
diff --git a/org.apache.felix.shell.gui/pom.xml b/org.apache.felix.shell.gui/pom.xml
index acfeae7..5b5ae98 100644
--- a/org.apache.felix.shell.gui/pom.xml
+++ b/org.apache.felix.shell.gui/pom.xml
@@ -27,6 +27,7 @@
<osgiManifest>
<bundleName>ShellGUI</bundleName>
<bundleDescription>A simple plugin-oriented GUI shell.</bundleDescription>
+ <bundleActivator>auto-detect</bundleActivator>
<bundleDocUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/</bundleDocUrl>
<bundleUrl>http://oscar-osgi.sf.net/obr2/shellgui/${pom.artifactId}-${pom.version}.jar</bundleUrl>
<bundleSource>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</bundleSource>
diff --git a/org.apache.felix.shell.tui/pom.xml b/org.apache.felix.shell.tui/pom.xml
index ea45d98..dc095e4 100644
--- a/org.apache.felix.shell.tui/pom.xml
+++ b/org.apache.felix.shell.tui/pom.xml
@@ -33,6 +33,7 @@
<osgiManifest>
<bundleName>ShellTUI</bundleName>
<bundleDescription>A simple textual user interface for Felix' shell service.</bundleDescription>
+ <bundleActivator>auto-detect</bundleActivator>
<bundleDocUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/</bundleDocUrl>
<bundleUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</bundleUrl>
<bundleSource>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</bundleSource>
diff --git a/org.apache.felix.shell/pom.xml b/org.apache.felix.shell/pom.xml
index 5e54af1..0b5d6f8 100644
--- a/org.apache.felix.shell/pom.xml
+++ b/org.apache.felix.shell/pom.xml
@@ -27,6 +27,7 @@
<osgiManifest>
<bundleName>ShellService</bundleName>
<bundleDescription>A simple OSGi command shell service.</bundleDescription>
+ <bundleActivator>auto-detect</bundleActivator>
<bundleDocUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/</bundleDocUrl>
<bundleUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</bundleUrl>
<bundleSource>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</bundleSource>
diff --git a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
index 8213898..4da45a4 100644
--- a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
+++ b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
@@ -40,6 +40,7 @@
*/
public class OsgiJarMojo extends AbstractMojo {
public static final String OSGI_REFERENCES = "osgi.references";
+ public static final String AUTO_DETECT = "auto-detect";
private static final String[] EMPTY_STRING_ARRAY = {};
@@ -243,18 +244,20 @@
private void verifyBundleActivator(Jar mainJar) {
String ba = osgiManifest.getBundleActivator();
- if (ba == null || ba.trim().length() == 0) {
+ if ((ba != null) && ba.equals(AUTO_DETECT)) {
switch ( mainJar.activators.size() ) {
- case 0: break;
- case 1: archiveConfig.addManifestEntry("Bundle-Activator", mainJar.activators.get(0));
- break;
+ case 0:
+ break;
+ case 1:
+ archiveConfig.addManifestEntry("Bundle-Activator", mainJar.activators.get(0));
+ break;
default:
- getLog().info("[OSGi] No Bundle-Activator specified and multiple found" );
- break;
+ getLog().info("[OSGi] Multiple activators found, unable to auto-detect." );
+ break;
}
}
- else {
- if( ! mainJar.activators.contains(ba))
+ else if (ba != null) {
+ if (!mainJar.activators.contains(ba))
getLog().warn("[OSGi] UNABLE TO VERIFY BUNDLE ACTIVATOR: " + ba);
}
}