Reducing the openHAB binary distribution with 200kb by stripping `.jar:META-INF/maven/*`

Removing the directory META-INF/maven from all .jar files reduces the size of generated files. I tried running these stripped .jar files for some time and could not see run-time downsides.

It can be tried on an installed system with openHAB 5.2.1

Before

$ du -sc --apparent-size $(find /usr/share/openhab/runtime/system/org/openhab -name '*.jar')
…
29364   total (28.67 MB)

Strip META-INF/maven from all org/openhab .jar files

Stop openHAB, clean the cache and then:

$ for i in $(find /usr/share/openhab/runtime/system/org/openhab -name '*.jar'); do \
  zip $i -d "META-INF/maven/*"; \
  chown openhab:openhab $i; \
  done

After

$ du -sc --apparent-size $(find /usr/share/openhab/runtime/system/org/openhab -name '*.jar')
…
29141   total (28.46 MB)

Adjusting the build process to avoid adding META-INF/maven/

--- a/bundles/pom.xml
+++ b/bundles/pom.xml
@@ -145,6 +145,7 @@
           <configuration>
             <archive>
               <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+              <addMavenDescriptor>false</addMavenDescriptor>
             </archive>
             <skipIfEmpty>true</skipIfEmpty>
           </configuration>

That’s it!

200kb? That does not seem material

He came late to us. Had this been 40 or 50 years ago you wouldn’t be saying that haha

True. I started my carrier in 1986 when 640k was “all you would ever need”