ndsev / zserio

zero sugar, zero fat, zero serialization overhead
https://zserio.org/
BSD 3-Clause "New" or "Revised" License
109 stars 27 forks source link

Consider to implement custom loading of extensions #191

Open mikir opened 4 years ago

mikir commented 4 years ago

Zserio uses Java Extension Mechanism to load all extensions. This implies that all extensions must be available at Java classpath.

There are the following possibilities how to run external independent extension:

  1. To set variable java.ext.dirs in case of Java version <= 1.8.
java -Djava.ext.dirs=EXTENSION_DIR -jar zserio_core.jar
  1. To set Java classpath. In this case, -jar argument cannot be used.
java -cp zserio_core.jar:EXTENSION.JAR zserio.tools.ZserioTool

Both possibilities are not handy or intuitive.

Therefore, consider to implement custom loading of extensions by new zserio command line argument, e..g

java -jar zserio_core.jar -extension EXTENSION.JAR

This will allow considering implementation of custom extension command line arguments which can clash:

java -jar zserio_core.jar -extension zserio_cpp -withoutSourcesAmalgamation -extension zserio_cpp98 -withSourcesAmalgamation
mikir commented 4 years ago

The similar problem is with options -withoutSqlCode, -withoutPubsubCode and -withoutServiceCode. These options do make sense only for code extensions not for documentation or XML extension. So, these options should be implemented by extensions not by core. However, it is not possible now to have the same options in different extensions. This will lead again to have flexible command line which allows the same options for multiple extensions:

java -jar zserio_core.jar -cpp -withoutSqlCode -java -withSqlCode -python -withoutSqlCode

The help could be improved as well. It will be more readable if options will be shown per extension to indicate if the corresponding option is supported by extension or not.