Hi, Have folded the many if statements into a method call instead, which looks cleaner IMHO.
Cheers Niclas
Index: src/main/java/org/apache/felix/tools/maven/plugin/OsgiManifest.java =================================================================== --- src/main/java/org/apache/felix/tools/maven/plugin/OsgiManifest.java (revision 409621) +++ src/main/java/org/apache/felix/tools/maven/plugin/OsgiManifest.java (working copy) @@ -21,7 +21,7 @@ /** * Hold values for an OSGi jar "bundle" manifest. - * + * * @author <a href="mailto:[email protected]">Apache Felix Project</a> * @version $Rev$, $Date$ */ @@ -100,147 +100,37 @@ public Properties getEntries() { - if (getBundleCategory() != null) - { - entries.put(BUNDLE_CATEGORY, getBundleCategory()); - } - /* - * if (getBundleClassPath() != null) { entries.put(BUNDLE_CLASSPATH, - * getBundleClassPath()); } + * handle( BUNDLE_CLASSPATH, getBundleClassPath(), null); */ - - if (getBundleCopyright() != null) - { - entries.put(BUNDLE_COPYRIGHT, getBundleCopyright()); - } - - if (getBundleDescription() != null) - { - entries.put(BUNDLE_DESCRIPTION, getBundleDescription()); - } - - if (getBundleName() != null) - { - entries.put(BUNDLE_NAME, getBundleName()); - } - - if (getBundleNativeCode() != null) - { - entries.put(BUNDLE_NATIVECODE, getBundleNativeCode()); - } - - if (getExportPackage() != null) - { - entries.put(EXPORT_PACKAGE, getExportPackage()); - } - - if (getExportService() != null) - { - entries.put(EXPORT_SERVICE, getExportService()); - } - - if (getImportPackage() != null) - { - entries.put(IMPORT_PACKAGE, getImportPackage()); - } - - if (getDynamicImportPackage() != null) - { - entries.put(DYNAMICIMPORT_PACKAGE, getDynamicImportPackage()); - } - - if (getImportService() != null) - { - entries.put(IMPORT_SERVICE, getImportService()); - } - - if (getBundleVendor() != null) - { - entries.put(BUNDLE_VENDOR, getBundleVendor()); - } - - if (getBundleVersion() != null) - { - entries.put(BUNDLE_VERSION, getBundleVersion()); - } - - if (getBundleDocUrl() != null) - { - entries.put(BUNDLE_DOCURL, getBundleDocUrl()); - } - - if (getBundleContactAddress() != null) - { - entries.put(BUNDLE_CONTACTADDRESS, getBundleContactAddress()); - } - - if (getBundleActivator() != null) - { - entries.put(BUNDLE_ACTIVATOR, getBundleActivator()); - } - - if (getBundleUpdateLocation() != null) - { - entries.put(BUNDLE_UPDATELOCATION, getBundleUpdateLocation()); - } - - if (getBundleRequiredExecutionEnvironment() != null) - { - entries.put(BUNDLE_REQUIREDEXECUTIONENVIRONMENT, - getBundleRequiredExecutionEnvironment()); - } - - if (getBundleSymbolicName() != null) - { - entries.put(BUNDLE_SYMBOLICNAME, getBundleSymbolicName()); - } - - if (getBundleLocalization() != null) - { - entries.put(BUNDLE_LOCALIZATION, getBundleLocalization()); - } - - if (getRequireBundle() != null) - { - entries.put(REQUIRE_BUNDLE, getRequireBundle()); - } - - if (getFragmentHost() != null) - { - entries.put(FRAGMENT_HOST, getFragmentHost()); - } - - if (getBundleManifestVersion() != null) - { - entries.put(BUNDLE_MANIFESTVERSION, getBundleManifestVersion()); - } - - if (getBundleUrl() != null) - { - entries.put(BUNDLE_URL, getBundleUrl()); - } - - if (getBundleSource() != null) - { - entries.put(BUNDLE_SOURCE, getBundleSource()); - } - - if (getBundleDate() != null) - { - entries.put(BUNDLE_DATE, getBundleDate()); - } - - if (getMetadataLocation() != null) - { - entries.put(METADATA_LOCATION, getMetadataLocation()); - } - - if (getServiceComponent() != null) - { - entries.put(SERVICE_COMPONENT, getServiceComponent()); - } - + handle( BUNDLE_CATEGORY, getBundleCategory(), null ); + handle( BUNDLE_COPYRIGHT, getBundleCopyright(), null ); + handle( BUNDLE_DESCRIPTION, getBundleDescription(), null ); + handle( BUNDLE_NAME, getBundleName(), null ); + handle( BUNDLE_NATIVECODE, getBundleNativeCode(), null ); + handle( EXPORT_PACKAGE, getExportPackage(), null ); + handle( EXPORT_SERVICE, getExportService(), null ); + handle( IMPORT_PACKAGE, getImportPackage(), null ); + handle( DYNAMICIMPORT_PACKAGE, getDynamicImportPackage(), null ); + handle( IMPORT_SERVICE, getImportService(), null ); + handle( BUNDLE_VENDOR, getBundleVendor(), null ); + handle( BUNDLE_VERSION, getBundleVersion(), null ); + handle( BUNDLE_DOCURL, getBundleDocUrl(), null ); + handle( BUNDLE_CONTACTADDRESS, getBundleContactAddress(), null ); + handle( BUNDLE_ACTIVATOR, getBundleActivator(), null ); + handle( BUNDLE_UPDATELOCATION, getBundleUpdateLocation(), null ); + handle( BUNDLE_REQUIREDEXECUTIONENVIRONMENT, + getBundleRequiredExecutionEnvironment(), null); + handle( BUNDLE_SYMBOLICNAME, getBundleSymbolicName(), null); + handle( BUNDLE_LOCALIZATION, getBundleLocalization(), null); + handle( REQUIRE_BUNDLE, getRequireBundle(), null); + handle( FRAGMENT_HOST, getFragmentHost(), null); + handle( BUNDLE_MANIFESTVERSION, getBundleManifestVersion(), null); + handle( BUNDLE_URL, getBundleUrl(), null); + handle( BUNDLE_SOURCE, getBundleSource(), null); + handle( BUNDLE_DATE, getBundleDate(), null); + handle( METADATA_LOCATION, getMetadataLocation(), null); + handle( SERVICE_COMPONENT, getServiceComponent(), null); return entries; } @@ -254,9 +144,9 @@ this.bundleCategory = bundleCategory; } - /* +/* * public String getBundleClasspath() { return bundleClasspath; } - * + * * public void setBundleClasspath(String bundleClasspath) { * this.bundleClasspath = bundleClasspath; } */ @@ -551,4 +441,21 @@ } return buf.toString(); } + + private void handle( String key, String value, String defaultValue ) + { + if( value == null ) + { + if( defaultValue != null ) + { + entries.put( key, defaultValue ); + } + } + else + { + entries.put( key, value ); + } + + } + } \ No newline at end of file

