Hello,

The plugin mechanism has various issues that make distributing and
extending OFBiz inconvenient and complex.  Here are some examples of the
problems I identified:

1. Binary distribution of OFBiz needs to include both the Jar and the
   ‘ofbiz.home’ directory which make deployment more complex

2. Gradle multi-project feature is overly complex (try to understand
   “build.gradle”...) and proves to be limited and brittle in practice
   (ex. adding an extra Gradle plugin in a subproject can easily break
   the build with obscure errors)

3. The plugin mechanism is hardly coupled with Gradle which breaks its
   API regularly. This means that plugins cannot choose their build
   system (Maven, Leinigen, SBT) and cannot expect their plugins to work
   with various version of OFBiz reliably.

4. There is no flexibility to install plugins outside of the ‘plugins’
   directory of $OFBIZ_HOME.

5. Plugins and Framework bytecode is distributed in the same JAR when we
   would want instead to independently compile and distribute them.


Here is a *big* change that I am considering for OFBiz to fixes those
issues by leveraging the Java platform which already provides everything
that we need to fix those issues:

 - Distributing OFBiz in a Jar with its XML files inside to fix #1 would
   allow developpers to extend the framework without compiling it which
   removes the hard dependency on Gradle which fixes #2 and #3 and make
   the build process snappier.

 - the classpath can be used to compose an arbitrary list of plugins
   from various location which fixes #4.

 - The ServiceLoader class [1] is a standard and stable extensibility
   mechanism based on JAR metadata which can be used to scan the
   available OFBiz components available across multiple JARs that can
   replace Gradle complex component bundling to fix #5.

The biggest challenge with this solution is that we need to do a huge
work of adapting OFBiz to to use location independant resources [3] when
loading XML and GroovyScript files.

However what this effort would would bring is a convenient and decoupled
way to extend OFBiz by simply declaring a dependency to the framework
and dependant reusable plugins from the project plugin build tool like
that:

    // myApplicationProjectPlugin/build.gradle
    dependencies {
        implementation "org.apache.ofbiz:ofbiz-framework:18.12"
        implementation "org.example:reusable-ofbiz-plugin:0.8"
        ...
    }

Would people welcome such change?

Thanks.

[1] https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html
[2] https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

Reply via email to