Re: svn commit: r1845933 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java

2018-11-12 Thread Jacques Le Roux

Done :)

Jacques


Le 11/11/2018 à 13:31, Mathieu Lirzin a écrit :

Hello Jacques,

Jacques Le Roux  writes:


So we would

remove ant-scripts folder and its content;

rename framework/base/groovyScript to framework/base/groovyScripts;

move GroovyInit.groovy and GroovyServiceTest.groovy to 
framework/base/groovyScripts and change their paths where used.

And let GroovyBaseScript.groovy where it is

Right?

IMO since ‘GroovyBaseScript.groovy’ is not a java file it should not be
placed in:

  ./framework/service/src/main/java/org/apache/ofbiz/service/engine

but rather in:

  ./framework/service/src/main/groovy/org/apache/ofbiz/service/engine

Since Groovy is not configured in Gradle this might not work OOTB
because the ‘GroovyBaseScript’ will probably not be copied in
‘ofbiz.jar’ and not defined in the classpath of the MANIFEST.

However if we were to apply OFBIZ-10611 [1] which adds the Gradle Groovy
plugin for supporting unit tests written in Groovy beforehand, it should
work gracefully.

Otherwise looks good to me.

[1] https://issues.apache.org/jira/projects/OFBIZ/issues/OFBIZ-10611




Re: Using plain Groovy classes for services.

2018-11-12 Thread Taher Alkhateeb
Hi Mathieu,

Can you explain hat you want to do exactly? How do these services
access the delegator and whatnot?
On Sun, Nov 11, 2018 at 5:32 PM Mathieu Lirzin
 wrote:
>
> Hello,
>
> While I think using Groovy for implementing services is a better choice
> than Java, I am not convinced by the rationale of using Groovy DSL
> features. Here are the various drawbacks I see:
>
>   - The service DSL breaks the function/method local scoping goodness by
> introducing various global variables (parameters, delegator, ...)
>
>   - There is no clear disctinction between services and helper methods
> (private/public)
>
>   - When Unit testing a helper method defined in a DSL script, a
> cumbersome mechanism for accessing the groovy method is required
>
>   - DSL implicit class context abstraction is leaky, for example it is
> hard to understand what is the proper way to define a variable
> outside of a method and how to refer to it from this method.
>
> def foo = "foo"
> def barService() {
> print foo // => ERROR: No such property: foo for class: ...
> }
>
> IMO DSL features introduce accidental complexity with very little
> benefits.  Since plain Groovy classes doesn't suffer from the downsides
> I described above and preserve the Groovy goodness (map literals,
> optional typing, ...), I recommend transitioning from DSL scripts to
> classes.
>
> What do people think?
>
> Thanks.
>
> --
> Mathieu Lirzin
> GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37